Commit 14c25f45 authored by Attila Kiss's avatar Attila Kiss Committed by GitHub

[PW-3174] Use the generic component for card payments (#840)

* Use bundle instead of the component

* Store action and additionalData from /payments response

* [WIP] handle paymentDetails for card payments

* Remove custom redirect page

The checkout redirect component does the redirect for both 3DS1(now) and
alternative payment(WIP)

* Store and return details

Store action, resultCode, additionalData, pspReference, nad paymentData

* Show challenge in a popup for 3DS2
parent 89409fb6
This diff is collapsed.
......@@ -148,7 +148,6 @@ class Redirect extends \Magento\Framework\App\Action\Action
if ($order->getPayment()) {
$active = $order->getPayment()->getAdditionalInformation('3dActive');
$success = $order->getPayment()->getAdditionalInformation('3dSuccess');
$checkoutAPM = $order->getPayment()->getAdditionalInformation('checkoutAPM');
}
// check if 3D secure is active. If not just go to success page
......@@ -247,27 +246,7 @@ class Redirect extends \Magento\Framework\App\Action\Action
$this->_redirect($this->_adyenHelper->getAdyenAbstractConfigData('return_path'));
}
} else {
$this->_adyenLogger->addAdyenResult("Customer was redirected to bank for 3D-secure validation.");
$order->addStatusHistoryComment(
__(
'Customer was redirected to bank for 3D-secure validation. Once the shopper authenticated,
the order status will be updated accordingly.
<br />Make sure that your notifications are being processed!
<br />If the order is stuck on this status, the shopper abandoned the session.
The payment can be seen as unsuccessful.
<br />The order can be automatically cancelled based on the OFFER_CLOSED notification.
Please contact Adyen Support to enable this.'
)
)->save();
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
} elseif (!empty($checkoutAPM)) {
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
} else {
$this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
}
......
......@@ -69,25 +69,27 @@ class CheckoutResponseValidator extends AbstractValidator
// validate result
if (!empty($response['resultCode'])) {
$payment->setAdditionalInformation('resultCode', $response['resultCode']);
switch ($response['resultCode']) {
case "IdentifyShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$payment->setAdditionalInformation(
'threeDS2Token',
$response['authentication']['threeds2.fingerprintToken']
);
$payment->setAdditionalInformation('adyenPaymentData', $response['paymentData']);
break;
case "ChallengeShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$payment->setAdditionalInformation(
'threeDS2Token',
$response['authentication']['threeds2.challengeToken']
);
if (!empty($response['action'])) {
$payment->setAdditionalInformation('action', $response['action']);
}
if (!empty($response['additionalData'])) {
$payment->setAdditionalInformation('additionalData', $response['additionalData']);
}
if (!empty($response['pspReference'])) {
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
}
if (!empty($response['paymentData'])) {
$payment->setAdditionalInformation('adyenPaymentData', $response['paymentData']);
break;
}
switch ($response['resultCode']) {
case "Authorised":
case "Received":
// TODO refactor since the full additionalData is stored in additionalInformation already
// For banktransfers store all bankTransfer details
if (!empty($response['additionalData']['bankTransfer.owner'])) {
foreach ($response['additionalData'] as $key => $value) {
......@@ -115,21 +117,14 @@ class CheckoutResponseValidator extends AbstractValidator
}
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "IdentifyShopper":
case "ChallengeShopper":
case "PresentToShopper":
if (!empty($response['action'])) {
$payment->setAdditionalInformation('action', $response['action']);
}
if (!empty($response['pspReference'])) {
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
}
break;
case 'Pending':
$payment->setAdditionalInformation('adyenPaymentData', $response['paymentData']);
if (!empty($response['action'])) {
$payment->setAdditionalInformation('action', $response['action']);
}
// nothing extra
break;
case "RedirectShopper":
// TODO refactor this resultCode handling
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$redirectUrl = null;
......
......@@ -100,15 +100,50 @@ class PaymentResponseHandler
$this->adyenLogger->error("Payment details call failed, paymentsResponse is empty");
return false;
}
if (!empty($paymentsResponse['resultCode']))
$payment->setAdditionalInformation('resultCode', $paymentsResponse['resultCode']);
if (!empty($paymentsResponse['action'])) {
$payment->setAdditionalInformation('action', $paymentsResponse['action']);
}
if (!empty($paymentsResponse['additionalData'])) {
$payment->setAdditionalInformation('additionalData', $paymentsResponse['additionalData']);
}
if (!empty($paymentsResponse['pspReference'])) {
$payment->setAdditionalInformation('pspReference', $paymentsResponse['pspReference']);
}
if (!empty($paymentsResponse['paymentData'])) {
$payment->setAdditionalInformation('adyenPaymentData', $paymentsResponse['paymentData']);
}
switch ($paymentsResponse['resultCode']) {
case self::PRESENT_TO_SHOPPER:
case self::PENDING:
case self::RECEIVED:
$payment->setAdditionalInformation("paymentsResponse", $paymentsResponse);
break;
//We don't need to handle these resultCodes
case self::AUTHORISED:
case self::REDIRECT_SHOPPER:
$this->adyenLogger->addAdyenResult("Customer was redirected.");
if ($order) {
$order->addStatusHistoryComment(
__(
'Customer was redirected to an external payment page. (In case of card payments the shopper is redirected to the bank for 3D-secure validation.) Once the shopper is authenticated,
the order status will be updated accordingly.
<br />Make sure that your notifications are being processed!
<br />If the order is stuck on this status, the shopper abandoned the session.
The payment can be seen as unsuccessful.
<br />The order can be automatically cancelled based on the OFFER_CLOSED notification.
Please contact Adyen Support to enable this.'
)
)->save();
}
break;
case self::AUTHORISED:
case self::IDENTIFY_SHOPPER:
case self::CHALLENGE_SHOPPER:
break;
......
......@@ -151,6 +151,17 @@ class AdyenPaymentDetails implements AdyenPaymentDetailsInterface
$this->checkoutSession->restoreQuote();
throw new LocalizedException(__('The payment is REFUSED.'));
}
return json_encode($this->paymentResponseHandler->formatPaymentResponse($paymentDetails['resultCode']));
$action = null;
if (!empty($paymentDetails['action'])) {
$action = $paymentDetails['action'];
}
$additionalData = null;
if (!empty($paymentDetails['additionalData'])) {
$additionalData = $paymentDetails['additionalData'];
}
return json_encode($this->paymentResponseHandler->formatPaymentResponse($paymentDetails['resultCode'], $action, $additionalData));
}
}
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="root">
<block class="Adyen\Payment\Block\Redirect\Redirect" name="adyen-redirect-form" template="redirect/redirect.phtml" cacheable="false"/>
</container>
</layout>
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
?>
<?php
if ($block->getRedirectMethod() == "GET") { ?>
<body>
<script>
window.location.replace("<?= $block->escapeJs($block->getRedirectUrl()); ?>");
</script>
</body>
<?php
} else { ?>
<body onload="document.getElementById('3dform').submit();">
<form method="POST" action="<?= $block->escapeHtml($block->getRedirectUrl()); ?>" id="3dform">
<input type="hidden" name="PaReq" value="<?= $block->escapeHtml($block->getPaReq()); ?>"/>
<input type="hidden" name="MD" value="<?= $block->escapeHtml($block->getMd()); ?>"/>
<input type="hidden" name="TermUrl" value="<?= $block->escapeHtml($block->getTermUrl()); ?>"/>
<noscript>
<br>
<br>
<div style="text-align: center">
<h1>Processing your 3-D Secure Transaction</h1>
<p>Please click continue to continue the processing of your 3-D Secure transaction.</p>
<input type="submit" class="button" value="continue"/>
</div>
</noscript>
</form>
</body>
<?php
} ?>
\ No newline at end of file
......@@ -38,7 +38,6 @@ define(
'Magento_Ui/js/model/messages',
'Adyen_Payment/js/model/payment-details',
'Magento_Checkout/js/model/error-processor',
'adyenCheckout',
'Adyen_Payment/js/bundle'
],
function(
......@@ -59,7 +58,6 @@ define(
Messages,
paymentDetails,
errorProcessor,
AdyenCheckout,
AdyenComponent
) {
'use strict';
......
......@@ -42,9 +42,7 @@ define(
'Adyen_Payment/js/model/payment-details',
'Magento_Checkout/js/model/error-processor',
'Adyen_Payment/js/model/adyen-payment-service',
'adyenCheckout',
]
'Adyen_Payment/js/bundle';
'Adyen_Payment/js/bundle',
],
function(
......@@ -69,8 +67,7 @@ function(
paymentDetails,
errorProcessor,
adyenPaymentService,
AdyenCheckout,
AdyenComponent,
AdyenComponent
) {
'use strict';
......
......@@ -95,9 +95,9 @@
<div class="checkout-component-dock" afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div>
</div>
<div id="threeDS2Wrapper">
<div id="threeDS2Modal">
<div id="threeDS2Container"></div>
<div id="cc_actionModalWrapper">
<div id="cc_actionModal">
<div id="cc_actionContainer"></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