We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit a0baf50a authored by rikterbeek's avatar rikterbeek

Refactor code to get Adyen CC api working

parent d4486a92
...@@ -7,6 +7,7 @@ class Index extends \Magento\Framework\App\Action\Action ...@@ -7,6 +7,7 @@ class Index extends \Magento\Framework\App\Action\Action
{ {
public function execute() public function execute()
{ {
echo 'test';die();
$this->_view->loadLayout(); $this->_view->loadLayout();
$this->_view->getLayout()->initMessages(); $this->_view->getLayout()->initMessages();
$this->_view->renderLayout(); $this->_view->renderLayout();
......
...@@ -58,7 +58,7 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -58,7 +58,7 @@ class PaymentRequest extends \Magento\Framework\Object
"paymentRequest.merchantAccount" => $merchantAccount, "paymentRequest.merchantAccount" => $merchantAccount,
"paymentRequest.amount.currency" => "EUR", "paymentRequest.amount.currency" => "EUR",
"paymentRequest.amount.value" => "199", "paymentRequest.amount.value" => "199",
"paymentRequest.reference" => "TEST-PAYMENT-" . date("Y-m-d-H:i:s"), "paymentRequest.reference" => $order->getIncrementId(),
"paymentRequest.shopperIP" => "ShopperIPAddress", "paymentRequest.shopperIP" => "ShopperIPAddress",
"paymentRequest.shopperEmail" => "TheShopperEmailAddress", "paymentRequest.shopperEmail" => "TheShopperEmailAddress",
"paymentRequest.shopperReference" => "YourReference", "paymentRequest.shopperReference" => "YourReference",
...@@ -110,9 +110,13 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -110,9 +110,13 @@ class PaymentRequest extends \Magento\Framework\Object
throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . $results)); throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . $results));
} }
throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . print_r($results, true)));
parse_str($results,$results);
// throw new \Magento\Framework\Exception\LocalizedException(__('HTTP Status code' . print_r($results, true)));
parse_str($results, $results);
$this->_logger->critical("result is" . print_r($results,true));
curl_close($ch); curl_close($ch);
......
...@@ -97,7 +97,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -97,7 +97,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
public function isAvailable($quote = null) public function isAvailable($quote = null)
{ {
$this->_logger->critical("IS AVAILABLE!! IS TRUE"); $this->_logger->critical("CC IS AVAILABLE!! IS TRUE");
return true; return true;
} }
...@@ -110,7 +110,10 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -110,7 +110,10 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/ */
public function assignData($data) public function assignData($data)
{ {
print_r($data);die(); $this->_logger->critical("Assign data!!:" . print_r($data, true));
return parent::assignData($data);
//// print_r($data);die();
// $this->_logger->critical("TEST in validate FUNTION !!:");
} }
public function validate() public function validate()
...@@ -160,10 +163,19 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -160,10 +163,19 @@ class Cc extends \Magento\Payment\Model\Method\Cc
break; break;
} }
$this->_logger->critical("HIERRR result is " . print_r($response,true));
if (!empty($response)) { if (!empty($response)) {
print_r($response);die(); $this->_logger->critical("NOT EMPTY ");
// print_r($response);die();
// $this->_processResponse($payment, $response, $request); // $this->_processResponse($payment, $response, $request);
} else { } else {
$this->_logger->critical(" EMPTY response");
throw new \Magento\Framework\Exception\LocalizedException(__('Empty result.')); throw new \Magento\Framework\Exception\LocalizedException(__('Empty result.'));
} }
......
...@@ -33,7 +33,52 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -33,7 +33,52 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
protected $_canAuthorize = true; protected $_canAuthorize = true;
protected $_isInitializeNeeded = true; protected $_isInitializeNeeded = true;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param Logger $logger
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
\Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Payment\Model\Method\Logger $logger,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
$context,
$registry,
$extensionFactory,
$customAttributeFactory,
$paymentData,
$scopeConfig,
$logger,
$resource,
$resourceCollection,
$data
);
$this->_urlBuilder = $urlBuilder;
}
public function isAvailable($quote = null)
{
$this->_logger->critical("HPP IS AVAILABLE!! IS TRUE");
return true;
}
public function initialize($paymentAction, $stateObject) public function initialize($paymentAction, $stateObject)
{ {
...@@ -79,24 +124,17 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -79,24 +124,17 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
// return \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE; // return \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE;
// } // }
/** /**
* Checkout order place redirect URL getter * Checkout redirect URL getter for onepage checkout (hardcode)
* *
* @see \Magento\Checkout\Controller\Onepage::savePaymentAction()
* @see \Magento\Quote\Model\Quote\Payment::getCheckoutRedirectUrl()
* @return string * @return string
*/ */
public function getOrderPlaceRedirectUrl() public function getCheckoutRedirectUrl()
{ {
$this->_logger->critical("getOrderPlaceRedirectUrl"); // return $this->_urlBuilder->getUrl('paypal/payflowexpress/start');
$method = $this->getMethodInstance(); return $this->_urlBuilder->getUrl('adyen/process/redirect');
if ($method) {
$this->_logger->critical("getOrderPlaceRedirectUrl url is:" . $method->getConfigData('order_place_redirect_url'));
return $method->getConfigData('order_place_redirect_url');
} else {
$this->_logger->critical("ELSE:");
return "http://www.google.com/";
}
return '';
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<arguments> <arguments>
<argument name="configProviders" xsi:type="array"> <argument name="configProviders" xsi:type="array">
<item name="adyen_cc_config_provider" xsi:type="object">AdyenCcConfigProvider</item> <item name="adyen_cc_config_provider" xsi:type="object">AdyenCcConfigProvider</item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item>
</argument> </argument>
</arguments> </arguments>
</type> </type>
......
...@@ -3,5 +3,8 @@ ...@@ -3,5 +3,8 @@
<route id="hello" frontName="hello"> <route id="hello" frontName="hello">
<module name="Adyen_Payment" /> <module name="Adyen_Payment" />
</route> </route>
<route id="adyen" frontName="adyen">
<module name="Adyen_Payment" />
</route>
</router> </router>
</config> </config>
\ No newline at end of file
...@@ -6,54 +6,72 @@ ...@@ -6,54 +6,72 @@
/*global define*/ /*global define*/
define( define(
[ [
'jquery', 'Magento_Payment/js/view/payment/cc-form',
'Magento_Payment/js/view/payment/iframe', 'Magento_Checkout/js/action/set-payment-information',
'Magento_Checkout/js/action/set-payment-information'
], ],
function ($, Component, setPaymentInformationAction) { function (Component, setPaymentInformationAction) {
'use strict'; 'use strict';
return Component.extend({ return Component.extend({
defaults: { defaults: {
template: 'Adyen_Payment/payment/cc-form' template: 'Adyen_Payment/payment/cc-form',
creditCardOwner: ''
},
initObservable: function () {
this._super()
.observe([
'creditCardType',
'creditCardExpYear',
'creditCardExpMonth',
'creditCardNumber',
'creditCardVerificationNumber',
'creditCardSsStartMonth',
'creditCardSsStartYear',
'selectedCardType',
'creditCardOwner'
]);
return this;
}, },
placeOrderHandler: null, placeOrderHandler: null,
validateHandler: null, validateHandler: null,
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function(handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
}, },
setValidateHandler: function(handler) { setValidateHandler: function(handler) {
this.validateHandler = handler; this.validateHandler = handler;
}, },
context: function() {
return this;
},
isShowLegend: function() {
return true;
},
getCode: function() { getCode: function() {
return 'adyen_cc'; return 'adyen_cc';
}, },
getData: function() {
return {
'method': this.item.method,
'cc_type': this.creditCardType(),
'cc_exp_year': this.creditCardExpYear(),
'cc_exp_month': this.creditCardExpMonth(),
'cc_number': this.creditCardNumber(),
'cc_owner' : this.creditCardOwner(),
additional_data: {
'cc_cid': this.creditCardVerificationNumber(),
'cc_ss_start_month': this.creditCardSsStartMonth(),
'cc_ss_start_year': this.creditCardSsStartYear()
}
};
},
isActive: function() { isActive: function() {
return true; return true;
}, },
getTitle: function() {
placeOrder: function() { return 'Adyen cc';
var self = this; },
if (this.validateHandler()) { getControllerName: function() {
this.isPlaceOrderActionAllowed(false); return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
$.when(setPaymentInformationAction()).done(function() { },
self.placeOrderHandler(); getPlaceOrderUrl: function() {
}).fail(function() { return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
self.isPlaceOrderActionAllowed(true); },
}); context: function() {
} return this;
} },
}); });
} }
); );
......
...@@ -6,13 +6,22 @@ ...@@ -6,13 +6,22 @@
/*global define*/ /*global define*/
define( define(
[ [
'Magento_Checkout/js/view/payment/default' 'jquery',
'Magento_Checkout/js/view/payment/default',
'Adyen_Payment/js/action/set-payment-method'
], ],
function (Component) { function ($, Component, setPaymentMethodAction) {
'use strict'; 'use strict';
return Component.extend({ return Component.extend({
defaults: { defaults: {
template: 'Adyen_Payment/payment/hpp-form' template: 'Adyen_Payment/payment/hpp-form'
},
/** Redirect to adyen */
continueToAdyen: function () {
//update payment method information if additional data was changed
this.selectPaymentMethod();
setPaymentMethodAction();
return false;
} }
}); });
} }
......
...@@ -12,48 +12,26 @@ ...@@ -12,48 +12,26 @@
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/> data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label data-bind="attr: {'for': getCode()}" class="label"><span data-bind="text: getTitle()"></span></label> <label data-bind="attr: {'for': getCode()}" class="label"><span data-bind="text: getTitle()"></span></label>
</div> </div>
<div class="payment-method-content"> <div class="payment-method-content">
<div class="payment-method-billing-address"> <fieldset class="fieldset" data-bind='attr: {id: "payment_form_" + getCode()}'>
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) --> <div class="payment-method-note">
<!-- ko text: $t('You will be redirected to the Adyen website.') --><!-- /ko -->
</div>
</fieldset>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
</div> </div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
<form class="form" id="co-transparent-form" action="#" method="post" data-bind="mageInit: { type="submit"
'transparent':{ data-bind="click: continueToAdyen, enable: (getCode() == isChecked())"
'context': context(), disabled>
'controller': getControllerName(), <span data-bind="text: $t('Continue to Adyen')"></span>
'gateway': getCode(), </button>
'orderSaveUrl':getPlaceOrderUrl(),
'cgiUrl': getCgiUrl(),
'dateDelim': getDateDelim(),
'cardFieldsMap': getCardFieldsMap(),
'nativeAction': getSaveOrderUrl()
}, 'validation':[]}">
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div> </div>
</form> </div>
</div> </div>
</div> </div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment