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 0c9dad61 authored by Alexandros Moraitis's avatar Alexandros Moraitis Committed by GitHub

[PW-3288] Google pay 3DS redirect (#870)

* google pay 3ds redirect

* Add the success page in the google pay config

* Fix code smell suggested from sonarcloud

* Remove google pay vault code

* Remove the response build method

* Remove unused parameter
parent 9cf251f3
......@@ -25,6 +25,7 @@
namespace Adyen\Payment\Model;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Adyen\Payment\Model\Ui\AdyenGooglePayConfigProvider;
use Adyen\Payment\Model\Ui\AdyenHppConfigProvider;
use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider;
......@@ -102,6 +103,15 @@ class AdyenOrderPaymentStatus implements \Adyen\Payment\Api\AdyenOrderPaymentSta
return json_encode(['action' => $additionalInformation['action']]);
}
}
/**
* If payment method is google pay
*/
if ($payment->getMethod() === AdyenGooglePayConfigProvider::CODE) {
$additionalInformation = $payment->getAdditionalInformation();
if (!empty($additionalInformation['threeDSType'])) {
return json_encode(['type' => $additionalInformation['threeDSType']]);
}
}
return true;
}
......
......@@ -97,6 +97,10 @@ class AdyenGooglePayConfigProvider implements ConfigProviderInterface
self::CODE => [
'isActive' => true,
'redirectUrl' => $this->urlBuilder->getUrl(
'adyen/process/redirect/',
['_secure' => $this->_getRequest()->isSecure()]
),
'successUrl' => $this->urlBuilder->getUrl(
'checkout/onepage/success/',
['_secure' => $this->_getRequest()->isSecure()]
)
......
......@@ -34,9 +34,10 @@ define(
'Magento_Checkout/js/model/full-screen-loader',
'mage/url',
'Magento_Vault/js/view/payment/vault-enabler',
'Adyen_Payment/js/model/adyen-payment-service',
'adyenCheckout'
],
function (ko, $, Component, placeOrderAction, additionalValidators, quote, urlBuilder, fullScreenLoader, url, VaultEnabler, AdyenCheckout) {
function (ko, $, Component, placeOrderAction, additionalValidators, quote, urlBuilder, fullScreenLoader, url, VaultEnabler, adyenPaymentService,AdyenCheckout) {
'use strict';
/**
......@@ -128,13 +129,16 @@ define(
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.afterPlaceOrder();
window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
}
);
function (orderId) {
self.afterPlaceOrder();
adyenPaymentService.getOrderPaymentStatus(orderId)
.done(function (responseJSON) {
self.validateThreeDSOrPlaceOrder(responseJSON)
});
}
);
}
},
buttonColor: 'black', // default/black/white
buttonType: 'long', // long/short
......@@ -150,6 +154,22 @@ define(
self.googlePayAllowed(false);
});
},
/**
* Based on the response we can start a 3DS2 validation or place the order
* @param responseJSON
*/
validateThreeDSOrPlaceOrder: function (responseJSON) {
var response = JSON.parse(responseJSON);
var googlepayRedirectUrl = '';
if (response && response.type === 'RedirectShopper') {
googlepayRedirectUrl = window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl
} else {
window.location.replace(url.build(
googlepayRedirectUrl = window.checkoutConfig.payment[quote.paymentMethod().method].successUrl
));
}
window.location.replace(url.build(googlepayRedirectUrl));
},
isGooglePayAllowed: function () {
if (this.googlePayAllowed()) {
return true;
......
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