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 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
*/
private $adyenLogger;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* GooglePayAuthorizationDataBuilder constructor.
*
......@@ -46,10 +51,12 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger;
$this->storeManager = $storeManager;
}
public function build(array $buildSubject)
......@@ -57,6 +64,8 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
$requestBody = [];
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
/** @var \Magento\Sales\Model\Order $order */
$order = $payment->getOrder();
$token = $payment->getAdditionalInformation('token');
$requestBody['paymentMethod']['type'] = 'paywithgoogle';
......@@ -67,6 +76,10 @@ class GooglePayAuthorizationDataBuilder implements BuilderInterface
$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;
return $request;
......
......@@ -161,18 +161,40 @@ define(
* @param responseJSON
*/
validateThreeDSOrPlaceOrder: function (responseJSON) {
var self = this;
var response = JSON.parse(responseJSON);
if (response && response.type === 'RedirectShopper') {
// TODO do redirect with the component
window.location.replace(url.build(
window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl
));
if (!!response.isFinal) {
// Status is final redirect to the redirectUrl
$.mage.redirect(
window.checkoutConfig.payment[quote.paymentMethod().method].successUrl,
);
} else {
window.location.replace(url.build(
window.checkoutConfig.payment[quote.paymentMethod().method].successUrl
));
// render component
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 () {
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