We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 2a276782 authored by Attila Kiss's avatar Attila Kiss Committed by GitHub

handle 3DS1 with Google pay (#930)

parent 847bb848
...@@ -39,6 +39,11 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface ...@@ -39,6 +39,11 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
*/ */
private $adyenLogger; private $adyenLogger;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/** /**
* GooglePayAuthorizationDataBuilder constructor. * GooglePayAuthorizationDataBuilder constructor.
* *
...@@ -46,10 +51,12 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface ...@@ -46,10 +51,12 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Store\Model\StoreManagerInterface $storeManager
) { ) {
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->storeManager = $storeManager;
} }
public function build(array $buildSubject) public function build(array $buildSubject)
...@@ -57,6 +64,8 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface ...@@ -57,6 +64,8 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
$requestBody = []; $requestBody = [];
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
/** @var \Magento\Sales\Model\Order $order */
$order = $payment->getOrder();
$token = $payment->getAdditionalInformation('token'); $token = $payment->getAdditionalInformation('token');
$requestBody['paymentMethod']['type'] = 'paywithgoogle'; $requestBody['paymentMethod']['type'] = 'paywithgoogle';
...@@ -67,6 +76,10 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface ...@@ -67,6 +76,10 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
$this->adyenLogger->addAdyenDebug("PaymentToken is empty"); $this->adyenLogger->addAdyenDebug("PaymentToken is empty");
} }
$requestBody['returnUrl'] = $this->storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_LINK
) . 'adyen/transparent/redirect?merchantReference=' . $order->getIncrementId();
$request['body'] = $requestBody; $request['body'] = $requestBody;
return $request; return $request;
......
...@@ -161,18 +161,40 @@ define( ...@@ -161,18 +161,40 @@ define(
* @param responseJSON * @param responseJSON
*/ */
validateThreeDSOrPlaceOrder: function (responseJSON) { validateThreeDSOrPlaceOrder: function (responseJSON) {
var self = this;
var response = JSON.parse(responseJSON); var response = JSON.parse(responseJSON);
if (response && response.type === 'RedirectShopper') {
// TODO do redirect with the component if (!!response.isFinal) {
window.location.replace(url.build( // Status is final redirect to the redirectUrl
window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl $.mage.redirect(
)); window.checkoutConfig.payment[quote.paymentMethod().method].successUrl,
);
} else { } else {
window.location.replace(url.build( // render component
window.checkoutConfig.payment[quote.paymentMethod().method].successUrl self.renderActionComponent(response.action);
));
} }
}, },
renderActionComponent: function(action) {
var self = this;
var actionNode = document.getElementById('ActionContainer');
fullScreenLoader.stopLoader();
self.popupModal = $('#ActionModal').modal({
// disable user to hide popup
clickableOverlay: false,
responsive: true,
innerScroll: false,
// empty buttons, we don't need that
buttons: [],
modalClass: 'ActionModal',
});
self.popupModal.modal('openModal');
self.actionComponent = self.checkoutComponent.createFromAction(
action).mount(actionNode);
},
isGooglePayAllowed: function () { isGooglePayAllowed: function () {
return !!this.googlePayAllowed(); return !!this.googlePayAllowed();
}, },
......
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