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 bda6ce3c authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Merge pull request #677 from Adyen/develop

Release 6.0.0
parents 524a9911 16ce9c74
...@@ -92,7 +92,7 @@ class CronMessage implements \Magento\Framework\Notification\MessageInterface ...@@ -92,7 +92,7 @@ class CronMessage implements \Magento\Framework\Notification\MessageInterface
*/ */
public function getText() public function getText()
{ {
$urlNotificationsOverview = $this->backendHelper->getUrl("adyen/NotificationsOverview/index"); $urlNotificationsOverview = $this->backendHelper->getUrl("adyen/notifications/overview");
$message = __('You have <a href="%1">%2 unprocessed notification(s)</a>. Please check your Cron', $urlNotificationsOverview, $this->_cronCheck); $message = __('You have <a href="%1">%2 unprocessed notification(s)</a>. Please check your Cron', $urlNotificationsOverview, $this->_cronCheck);
$urlMagento = "http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html"; $urlMagento = "http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html";
$urlAdyen = "https://docs.adyen.com/developers/plugins/magento-2/set-up-the-plugin-in-magento#step2runcron"; $urlAdyen = "https://docs.adyen.com/developers/plugins/magento-2/set-up-the-plugin-in-magento#step2runcron";
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Api;
interface AdyenOrderPaymentStatusInterface
{
/**
* @param string $orderId
* @return string
*/
public function getOrderPaymentStatus($orderId);
}
...@@ -44,22 +44,30 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -44,22 +44,30 @@ class Success extends \Magento\Framework\View\Element\Template
*/ */
protected $_orderFactory; protected $_orderFactory;
/**
* @var \Magento\Framework\Pricing\Helper\Data
*/
public $priceHelper;
/** /**
* Success constructor. * Success constructor.
* *
* @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Framework\Pricing\Helper\Data $priceHelper
* @param array $data * @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
\Magento\Checkout\Model\Session $checkoutSession, \Magento\Checkout\Model\Session $checkoutSession,
\Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Pricing\Helper\Data $priceHelper,
array $data = [] array $data = []
) { ) {
$this->_checkoutSession = $checkoutSession; $this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->priceHelper = $priceHelper;
parent::__construct($context, $data); parent::__construct($context, $data);
} }
...@@ -96,10 +104,10 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -96,10 +104,10 @@ class Success extends \Magento\Framework\View\Element\Template
/** /**
* @return null|\string[] * @return null|\string[]
*/ */
public function getBoletoPdfUrl() public function getBoletoData()
{ {
if ($this->isBoletoPayment()) { if ($this->isBoletoPayment()) {
return $this->getOrder()->getPayment()->getAdditionalInformation('url'); return $this->getOrder()->getPayment()->getAdditionalInformation('action');
} }
return null; return null;
} }
...@@ -129,10 +137,14 @@ class Success extends \Magento\Framework\View\Element\Template ...@@ -129,10 +137,14 @@ class Success extends \Magento\Framework\View\Element\Template
public function getMultibancoData() public function getMultibancoData()
{ {
$result = []; $result = [];
if (!empty($this->getOrder()->getPayment()) && if (empty($this->getOrder()->getPayment())) {
!empty($this->getOrder()->getPayment()->getAdditionalInformation('comprafacil.entity')) return $result;
}
$action = $this->getOrder()->getPayment()->getAdditionalInformation('action');
if (!empty($action["paymentMethodType"]) &&
(strcmp($action["paymentMethodType"], 'multibanco') === 0)
) { ) {
$result = $this->getOrder()->getPayment()->getAdditionalInformation(); $result = $action;
} }
return $result; return $result;
......
...@@ -82,6 +82,7 @@ class TransactionAuthorization implements ClientInterface ...@@ -82,6 +82,7 @@ class TransactionAuthorization implements ClientInterface
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage(); $response['error'] = $e->getMessage();
} }
return $response; return $response;
} }
} }
...@@ -30,29 +30,19 @@ use Magento\Payment\Gateway\Http\ClientInterface; ...@@ -30,29 +30,19 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/ */
class TransactionCancel implements ClientInterface class TransactionCancel implements ClientInterface
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/** /**
* PaymentRequest constructor. * PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\Model\Context $context, \Adyen\Payment\Helper\Data $adyenHelper
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) { ) {
$this->_encryptor = $encryptor; $this->adyenHelper = $adyenHelper;
$this->_adyenHelper = $adyenHelper;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient();
} }
/** /**
...@@ -62,16 +52,16 @@ class TransactionCancel implements ClientInterface ...@@ -62,16 +52,16 @@ class TransactionCancel implements ClientInterface
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{ {
$request = $transferObject->getBody(); $request = $transferObject->getBody();
// call lib // call lib
$service = new \Adyen\Service\Modification($this->_client); $service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
try { try {
$response = $service->cancel($request); $response = $service->cancel($request);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
$response = null; $response['error'] = $e->getMessage();
} }
return $response; return $response;
} }
} }
...@@ -30,32 +30,19 @@ use Magento\Payment\Gateway\Http\ClientInterface; ...@@ -30,32 +30,19 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/ */
class TransactionCapture implements ClientInterface class TransactionCapture implements ClientInterface
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/** /**
* PaymentRequest constructor. * PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\Model\Context $context, \Adyen\Payment\Helper\Data $adyenHelper
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) { ) {
$this->_encryptor = $encryptor; $this->adyenHelper = $adyenHelper;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient();
} }
/** /**
...@@ -65,17 +52,17 @@ class TransactionCapture implements ClientInterface ...@@ -65,17 +52,17 @@ class TransactionCapture implements ClientInterface
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{ {
$request = $transferObject->getBody(); $request = $transferObject->getBody();
// call lib // call lib
$service = new \Adyen\Service\Modification($this->_client); $service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
try { try {
$response = $service->capture($request); $response = $service->capture($request);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
$this->_adyenLogger->error($e); // add this for now not in the lib yet $response['error'] = $e->getMessage();
$response = null;
} }
return $response; return $response;
} }
} }
...@@ -30,29 +30,20 @@ use Magento\Payment\Gateway\Http\ClientInterface; ...@@ -30,29 +30,20 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/ */
class TransactionRefund implements ClientInterface class TransactionRefund implements ClientInterface
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/** /**
* PaymentRequest constructor. * PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/ */
public function __construct( public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient(); \Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper;
} }
/** /**
...@@ -66,12 +57,13 @@ class TransactionRefund implements ClientInterface ...@@ -66,12 +57,13 @@ class TransactionRefund implements ClientInterface
foreach ($requests as $request) { foreach ($requests as $request) {
// call lib // call lib
$service = new \Adyen\Service\Modification($this->_client); $service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
try { try {
$responses[] = $service->refund($request); $responses[] = $service->refund($request);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
$responses[] = null; $responses[] = array('error' => $e->getMessage());
} }
} }
return $responses; return $responses;
......
...@@ -56,6 +56,10 @@ class TransferFactory implements TransferFactoryInterface ...@@ -56,6 +56,10 @@ class TransferFactory implements TransferFactoryInterface
$this->transferBuilder->setHeaders($request['headers']); $this->transferBuilder->setHeaders($request['headers']);
} }
if (!empty($request['clientConfig'])) {
$this->transferBuilder->setClientConfig($request['clientConfig']);
}
$transfer = $this->transferBuilder $transfer = $this->transferBuilder
->setBody($request['body']) ->setBody($request['body'])
->build(); ->build();
......
...@@ -64,7 +64,7 @@ class CancelDataBuilder implements BuilderInterface ...@@ -64,7 +64,7 @@ class CancelDataBuilder implements BuilderInterface
"reference" => $order->getOrderIncrementId(), "reference" => $order->getOrderIncrementId(),
"originalReference" => $pspReference "originalReference" => $pspReference
]; ];
$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
return $request; return $request;
} }
} }
...@@ -81,13 +81,11 @@ class CaptureDataBuilder implements BuilderInterface ...@@ -81,13 +81,11 @@ class CaptureDataBuilder implements BuilderInterface
$openInvoiceFields = $this->getOpenInvoiceData($payment); $openInvoiceFields = $this->getOpenInvoiceData($payment);
$requestBody["additionalData"] = $openInvoiceFields; $requestBody["additionalData"] = $openInvoiceFields;
} }
$request['body'] = $requestBody; $request['body'] = $requestBody;
$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
return $request; return $request;
} }
/** /**
* @param $payment * @param $payment
* @return mixed * @return mixed
......
...@@ -192,7 +192,7 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -192,7 +192,7 @@ class CheckoutDataBuilder implements BuilderInterface
} }
$request['body'] = $requestBody; $request['body'] = $requestBody;
return $request; return $request;
} }
...@@ -241,14 +241,14 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -241,14 +241,14 @@ class CheckoutDataBuilder implements BuilderInterface
// Discount cost // Discount cost
if ($discountAmount != 0) { if ($discountAmount != 0) {
$description = __('Total Discount'); $description = __('Discount');
$itemAmount = $this->adyenHelper->formatAmount($discountAmount, $currency); $itemAmount = -$this->adyenHelper->formatAmount($discountAmount, $currency);
$itemVatAmount = "0"; $itemVatAmount = "0";
$itemVatPercentage = "0"; $itemVatPercentage = "0";
$numberOfItems = 1; $numberOfItems = 1;
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'itemId' => 'totalDiscount', 'id' => 'Discount',
'amountExcludingTax' => $itemAmount, 'amountExcludingTax' => $itemAmount,
'taxAmount' => $itemVatAmount, 'taxAmount' => $itemVatAmount,
'description' => $description, 'description' => $description,
...@@ -272,7 +272,7 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -272,7 +272,7 @@ class CheckoutDataBuilder implements BuilderInterface
if ($priceExcludingTax !== 0) { if ($priceExcludingTax !== 0) {
$formattedTaxPercentage = $cart->getShippingAddress()->getShippingTaxAmount() / $priceExcludingTax * 100 * 100; $formattedTaxPercentage = $cart->getShippingAddress()->getShippingTaxAmount() / $priceExcludingTax * 100 * 100;
} }
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'itemId' => 'shippingCost', 'itemId' => 'shippingCost',
'amountExcludingTax' => $formattedPriceExcludingTax, 'amountExcludingTax' => $formattedPriceExcludingTax,
......
...@@ -173,9 +173,8 @@ class RefundDataBuilder implements BuilderInterface ...@@ -173,9 +173,8 @@ class RefundDataBuilder implements BuilderInterface
$requestBody[0]["additionalData"] = $openInvoiceFields; $requestBody[0]["additionalData"] = $openInvoiceFields;
} }
} }
$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
$request['body'] = $requestBody; $request['body'] = $requestBody;
return $request; return $request;
} }
......
...@@ -61,9 +61,14 @@ class CancelResponseValidator extends AbstractValidator ...@@ -61,9 +61,14 @@ class CancelResponseValidator extends AbstractValidator
// The available response codes that the API can return in case of successfull cancellation // The available response codes that the API can return in case of successfull cancellation
$expectedResponses = ['[cancelOrRefund-received]', '[cancel-received]']; $expectedResponses = ['[cancelOrRefund-received]', '[cancel-received]'];
if (!in_array($response['response'], $expectedResponses)) { if (empty($response['response']) || !in_array($response['response'], $expectedResponses)) {
$errorMsg = __('Error with cancellation'); $errorMsg = __('Error with cancellation');
$this->adyenLogger->error($errorMsg); $this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg; $errorMessages[] = $errorMsg;
} }
......
...@@ -58,9 +58,14 @@ class CaptureResponseValidator extends AbstractValidator ...@@ -58,9 +58,14 @@ class CaptureResponseValidator extends AbstractValidator
$isValid = true; $isValid = true;
$errorMessages = []; $errorMessages = [];
if ($response['response'] != '[capture-received]') { if (empty($response['response']) || $response['response'] != '[capture-received]') {
$errorMsg = __('Error with capture'); $errorMsg = __('Error with capture');
$this->adyenLogger->error($errorMsg); $this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg; $errorMessages[] = $errorMsg;
} }
......
...@@ -67,7 +67,7 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -67,7 +67,7 @@ class CheckoutResponseValidator extends AbstractValidator
$isValid = true; $isValid = true;
$errorMessages = []; $errorMessages = [];
// validate result // validate result
if (isset($response['resultCode'])) { if (!empty($response['resultCode'])) {
switch ($response['resultCode']) { switch ($response['resultCode']) {
case "IdentifyShopper": case "IdentifyShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']); $payment->setAdditionalInformation('threeDSType', $response['resultCode']);
...@@ -89,6 +89,7 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -89,6 +89,7 @@ class CheckoutResponseValidator extends AbstractValidator
} }
} }
} elseif (!empty($response['additionalData']['comprafacil.entity'])) { } elseif (!empty($response['additionalData']['comprafacil.entity'])) {
//Multibanco resultCode has changed after checkout v49 and comprafacil.entity is not received anymore
foreach ($response['additionalData'] as $key => $value) { foreach ($response['additionalData'] as $key => $value) {
if (strpos($key, 'comprafacil') === 0) { if (strpos($key, 'comprafacil') === 0) {
$payment->setAdditionalInformation($key, $value); $payment->setAdditionalInformation($key, $value);
...@@ -105,31 +106,11 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -105,31 +106,11 @@ class CheckoutResponseValidator extends AbstractValidator
$payment->setAdditionalInformation('pspReference', $response['pspReference']); $payment->setAdditionalInformation('pspReference', $response['pspReference']);
break; break;
case "PresentToShopper": case "PresentToShopper":
$payment->setAdditionalInformation('pspReference', $response['pspReference']); if (!empty($response['action'])) {
// set additionalData $payment->setAdditionalInformation('action', $response['action']);
if (isset($response['outputDetails']) && is_array($response['outputDetails'])) { }
if (!empty($response['pspReference'])) {
$outputDetails = $response['outputDetails']; $payment->setAdditionalInformation('pspReference', $response['pspReference']);
if (isset($outputDetails['boletobancario.dueDate'])) {
$payment->setAdditionalInformation(
'dueDate',
$outputDetails['boletobancario.dueDate']
);
}
if (isset($outputDetails['boletobancario.expirationDate'])) {
$payment->setAdditionalInformation(
'expirationDate',
$outputDetails['boletobancario.expirationDate']
);
}
if (isset($outputDetails['boletobancario.url'])) {
$payment->setAdditionalInformation(
'url',
$outputDetails['boletobancario.url']
);
}
} }
break; break;
case "RedirectShopper": case "RedirectShopper":
...@@ -212,6 +193,11 @@ class CheckoutResponseValidator extends AbstractValidator ...@@ -212,6 +193,11 @@ class CheckoutResponseValidator extends AbstractValidator
} }
} else { } else {
$errorMsg = __('Error with payment method please select different payment method.'); $errorMsg = __('Error with payment method please select different payment method.');
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
} }
......
...@@ -68,7 +68,7 @@ class GeneralResponseValidator extends AbstractValidator ...@@ -68,7 +68,7 @@ class GeneralResponseValidator extends AbstractValidator
$errorMessages = []; $errorMessages = [];
// validate result // validate result
if ($response && isset($response['resultCode'])) { if (!empty($response['resultCode'])) {
switch ($response['resultCode']) { switch ($response['resultCode']) {
case "Authorised": case "Authorised":
$payment->setAdditionalInformation('pspReference', $response['pspReference']); $payment->setAdditionalInformation('pspReference', $response['pspReference']);
...@@ -139,9 +139,14 @@ class GeneralResponseValidator extends AbstractValidator ...@@ -139,9 +139,14 @@ class GeneralResponseValidator extends AbstractValidator
} }
} else { } else {
$errorMsg = __('Error with payment method please select different payment method.'); $errorMsg = __('Error with payment method please select different payment method.');
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
} }
return $this->createResult($isValid, $errorMessages); return $this->createResult($isValid, $errorMessages);
} }
} }
...@@ -59,9 +59,14 @@ class RefundResponseValidator extends AbstractValidator ...@@ -59,9 +59,14 @@ class RefundResponseValidator extends AbstractValidator
$errorMessages = []; $errorMessages = [];
foreach ($responses as $response) { foreach ($responses as $response) {
if ($response['response'] != '[refund-received]') { if (empty($response['response']) || $response['response'] != '[refund-received]') {
$errorMsg = __('Error with refund'); $errorMsg = __('Error with refund');
$this->adyenLogger->error($errorMsg); $this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg; $errorMessages[] = $errorMsg;
} }
} }
......
...@@ -1834,7 +1834,7 @@ class Data extends AbstractHelper ...@@ -1834,7 +1834,7 @@ class Data extends AbstractHelper
*/ */
public function getCurrentLocaleCode($storeId) public function getCurrentLocaleCode($storeId)
{ {
$localeCode = $this->getAdyenAbstractConfigData('shopper_locale', $storeId); $localeCode = $this->getAdyenHppConfigData('shopper_locale', $storeId);
if ($localeCode != "") { if ($localeCode != "") {
return $localeCode; return $localeCode;
} }
......
...@@ -85,6 +85,11 @@ class PaymentMethods extends AbstractHelper ...@@ -85,6 +85,11 @@ class PaymentMethods extends AbstractHelper
*/ */
protected $themeProvider; protected $themeProvider;
/**
* @var \Magento\Quote\Model\Quote
*/
protected $quote;
/** /**
* PaymentMethods constructor. * PaymentMethods constructor.
* *
...@@ -133,41 +138,51 @@ class PaymentMethods extends AbstractHelper ...@@ -133,41 +138,51 @@ class PaymentMethods extends AbstractHelper
{ {
// get quote from quoteId // get quote from quoteId
$quote = $this->quoteRepository->getActive($quoteId); $quote = $this->quoteRepository->getActive($quoteId);
$store = $quote->getStore();
$paymentMethods = $this->fetchAlternativeMethods($store, $country); // If quote cannot be found early return the empty paymentMethods array
if (empty($quote)) {
return [];
}
$this->setQuote($quote);
$paymentMethods = $this->fetchAlternativeMethods($country);
return $paymentMethods; return $paymentMethods;
} }
/** /**
* @param $store
* @param $country * @param $country
* @return array * @return array
*/ */
protected function fetchAlternativeMethods($store, $country) protected function fetchAlternativeMethods($country)
{ {
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData('merchant_account'); $quote = $this->getQuote();
$store = $quote->getStore();
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData('merchant_account', $store->getId());
if (!$merchantAccount) { if (!$merchantAccount) {
return []; return [];
} }
$currencyCode = $this->getCurrentCurrencyCode($store);
$adyFields = [ $adyFields = [
"channel" => "Web", "channel" => "Web",
"merchantAccount" => $merchantAccount, "merchantAccount" => $merchantAccount,
"countryCode" => $this->getCurrentCountryCode($store, $country), "countryCode" => $this->getCurrentCountryCode($store, $country),
"amount" => [ "amount" => [
"currency" => $this->getCurrentCurrencyCode($store), "currency" => $currencyCode,
"value" => (int)$this->adyenHelper->formatAmount( "value" => (int)$this->adyenHelper->formatAmount(
$this->getCurrentPaymentAmount(), $this->getCurrentPaymentAmount(),
$this->getCurrentCurrencyCode($store) $currencyCode
), ),
], ],
"shopperReference" => $this->getCurrentShopperReference(), "shopperReference" => $this->getCurrentShopperReference(),
"shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId()) "shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId())
]; ];
$billingAddress = $this->getQuote()->getBillingAddress(); $billingAddress = $quote->getBillingAddress();
if (!empty($billingAddress)) { if (!empty($billingAddress)) {
if ($customerTelephone = trim($billingAddress->getTelephone())) { if ($customerTelephone = trim($billingAddress->getTelephone())) {
...@@ -319,7 +334,7 @@ class PaymentMethods extends AbstractHelper ...@@ -319,7 +334,7 @@ class PaymentMethods extends AbstractHelper
{ {
// initialize the adyen client // initialize the adyen client
$client = $this->adyenHelper->initializeAdyenClient($this->getQuote()->getStoreId()); $client = $this->adyenHelper->initializeAdyenClient($store->getId());
// initialize service // initialize service
$service = $this->adyenHelper->createAdyenCheckoutService($client); $service = $this->adyenHelper->createAdyenCheckoutService($client);
...@@ -342,7 +357,15 @@ class PaymentMethods extends AbstractHelper ...@@ -342,7 +357,15 @@ class PaymentMethods extends AbstractHelper
*/ */
protected function getQuote() protected function getQuote()
{ {
return $this->session->getQuote(); return $this->quote;
}
/**
* @param \Magento\Quote\Model\Quote $quote
*/
protected function setQuote(\Magento\Quote\Model\Quote $quote)
{
$this->quote = $quote;
} }
/** /**
...@@ -389,4 +412,4 @@ class PaymentMethods extends AbstractHelper ...@@ -389,4 +412,4 @@ class PaymentMethods extends AbstractHelper
return $responseData; return $responseData;
} }
} }
\ No newline at end of file
...@@ -13,23 +13,22 @@ ...@@ -13,23 +13,22 @@
* ############# * #############
* ############ * ############
* *
* Adyen Payment module (https://www.adyen.com/) * Adyen Payment Module
* *
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/) * Copyright (c) 2020 Adyen B.V.
* See LICENSE.txt for license details. * This file is open source and available under the MIT license.
* See the LICENSE file for more info.
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Plugin; namespace Adyen\Payment\Model;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider; use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider; use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider;
class PaymentInformationManagement class AdyenOrderPaymentStatus implements \Adyen\Payment\Api\AdyenOrderPaymentStatusInterface
{ {
/** /**
* @var \Magento\Sales\Api\OrderRepositoryInterface * @var \Magento\Sales\Api\OrderRepositoryInterface
*/ */
...@@ -46,7 +45,8 @@ class PaymentInformationManagement ...@@ -46,7 +45,8 @@ class PaymentInformationManagement
protected $adyenHelper; protected $adyenHelper;
/** /**
* PaymentInformationManagement constructor. * AdyenOrderPaymentStatus constructor.
*
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
...@@ -62,32 +62,31 @@ class PaymentInformationManagement ...@@ -62,32 +62,31 @@ class PaymentInformationManagement
} }
/** /**
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject * @param string $orderId
* @param $result * @return bool|string
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/ */
public function afterSavePaymentInformationAndPlaceOrder( public function getOrderPaymentStatus($orderId)
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject, {
$result $order = $this->orderRepository->get($orderId);
) { $payment = $order->getPayment();
try {
$order = $this->orderRepository->get($result); if ($payment->getMethod() === AdyenCcConfigProvider::CODE ||
$payment = $order->getPayment(); $payment->getMethod() === AdyenOneclickConfigProvider::CODE
) {
$additionalInformation = $payment->getAdditionalInformation();
if ($payment->getMethod() === AdyenCcConfigProvider::CODE || $type = null;
$payment->getMethod() === AdyenOneclickConfigProvider::CODE if (!empty($additionalInformation['threeDSType'])) {
) { $type = $additionalInformation['threeDSType'];
return $this->adyenHelper->buildThreeDS2ProcessResponseJson($payment->getAdditionalInformation('threeDSType'), }
$payment->getAdditionalInformation('threeDS2Token'));
} else { $token = null;
return $result; if (!empty($additionalInformation['threeDS2Token'])) {
$token = $additionalInformation['threeDS2Token'];
} }
} catch (NoSuchEntityException $e) {
$this->adyenLogger->error("Exception: " . $e->getMessage());
throw new \Magento\Framework\Exception\LocalizedException(__('This order no longer exists.'));
}
return $result; return $this->adyenHelper->buildThreeDS2ProcessResponseJson($type, $token);
}
return true;
} }
} }
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Plugin;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
class GuestPaymentInformationManagement
{
/**
* @var \Magento\Sales\Api\OrderRepositoryInterface
*/
protected $orderRepository;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $adyenLogger;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $adyenHelper;
/**
* GuestPaymentInformationManagement constructor.
*
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->orderRepository = $orderRepository;
$this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
}
/**
* @param \Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject
* @param $result
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function afterSavePaymentInformationAndPlaceOrder(
\Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject,
$result
) {
try {
$order = $this->orderRepository->get($result);
$payment = $order->getPayment();
if ($payment->getMethod() === AdyenCcConfigProvider::CODE) {
return $this->adyenHelper->buildThreeDS2ProcessResponseJson(
$payment->getAdditionalInformation('threeDSType'),
$payment->getAdditionalInformation('threeDS2Token')
);
} else {
return $result;
}
} catch (NoSuchEntityException $e) {
$this->adyenLogger->error("Exception: " . $e->getMessage());
throw new \Magento\Framework\Exception\LocalizedException(__('This order no longer exists.'));
}
return $result;
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "5.4.0", "version": "6.0.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
} }
], ],
"require": { "require": {
"adyen/php-api-library": "~4.1", "adyen/php-api-library": "~6",
"magento/framework": ">=101.0.8 <102 || >=102.0.1", "magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*", "magento/module-vault": "101.*",
"magento/module-paypal": "100.3.*" "magento/module-paypal": ">=100.2.6"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~6.5.0", "phpunit/phpunit": "~6.5.0",
......
...@@ -660,6 +660,7 @@ ...@@ -660,6 +660,7 @@
<item name="payment" xsi:type="string">Adyen\Payment\Gateway\Request\PaymentDataBuilder</item> <item name="payment" xsi:type="string">Adyen\Payment\Gateway\Request\PaymentDataBuilder</item>
<item name="browserinfo" xsi:type="string">Adyen\Payment\Gateway\Request\BrowserInfoDataBuilder</item> <item name="browserinfo" xsi:type="string">Adyen\Payment\Gateway\Request\BrowserInfoDataBuilder</item>
<item name="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\ApplePayAuthorizationDataBuilder</item> <item name="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\ApplePayAuthorizationDataBuilder</item>
<item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringDataBuilder</item>
</argument> </argument>
</arguments> </arguments>
</virtualType> </virtualType>
...@@ -1026,15 +1027,11 @@ ...@@ -1026,15 +1027,11 @@
type="Adyen\Payment\Model\AdyenThreeDS2Process"/> type="Adyen\Payment\Model\AdyenThreeDS2Process"/>
<preference for="Adyen\Payment\Api\AdyenOriginKeyInterface" <preference for="Adyen\Payment\Api\AdyenOriginKeyInterface"
type="Adyen\Payment\Model\AdyenOriginKey"/> type="Adyen\Payment\Model\AdyenOriginKey"/>
<preference for="Adyen\Payment\Api\AdyenOrderPaymentStatusInterface"
type="Adyen\Payment\Model\AdyenOrderPaymentStatus"/>
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface"> <type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/> <plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</type> </type>
<type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
<plugin name="AdyenPaymentInformationManagementAddPaymentInfo" type="Adyen\Payment\Plugin\PaymentInformationManagement" sortOrder="10"/>
</type>
<type name="Magento\Checkout\Api\GuestPaymentInformationManagementInterface">
<plugin name="AdyenGuestPaymentInformationManagementAddPaymentInfo" type="Adyen\Payment\Plugin\GuestPaymentInformationManagement" sortOrder="10"/>
</type>
<!--Notifications overview--> <!--Notifications overview-->
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory"> <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
...@@ -1050,5 +1047,4 @@ ...@@ -1050,5 +1047,4 @@
<argument name="resourceModel" xsi:type="string">Adyen\Payment\Model\ResourceModel\Notification</argument> <argument name="resourceModel" xsi:type="string">Adyen\Payment\Model\ResourceModel\Notification</argument>
</arguments> </arguments>
</virtualType> </virtualType>
</config> </config>
...@@ -71,4 +71,11 @@ ...@@ -71,4 +71,11 @@
<resource ref="anonymous"/> <resource ref="anonymous"/>
</resources> </resources>
</route> </route>
</routes>
\ No newline at end of file <route url="/V1/adyen/orders/:orderId/payment-status" method="GET">
<service class="Adyen\Payment\Api\AdyenOrderPaymentStatusInterface" method="getOrderPaymentStatus"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
...@@ -69,7 +69,7 @@ $_isDemoMode = $block->isDemoMode(); ...@@ -69,7 +69,7 @@ $_isDemoMode = $block->isDemoMode();
<?php endif; ?> <?php endif; ?>
<?php if($_info->getAdditionalInformation('lastname') != ""): ?> <?php if($_info->getAdditionalInformation('lastname') != ""): ?>
<div> <div>
<?php echo __('Firstname: %1', $_info->getAdditionalInformation('lastname')) ?> <?php echo __('Lastname: %1', $_info->getAdditionalInformation('lastname')) ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
......
view/base/web/images/logos/klarna.png

1.9 KB | W: | H:

view/base/web/images/logos/klarna.png

1.16 KB | W: | H:

view/base/web/images/logos/klarna.png
view/base/web/images/logos/klarna.png
view/base/web/images/logos/klarna.png
view/base/web/images/logos/klarna.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -26,9 +26,12 @@ ...@@ -26,9 +26,12 @@
*/ */
?> ?>
<?php if ($block->isBoletoPayment()) : ?> <?php if ($block->isBoletoPayment()) : ?>
<?php
$boletoData = $block->getBoletoData();
?>
<p> <p>
<?php echo $block->escapeHtml(__('Boleto PDF: ')); ?> <?php echo $block->escapeHtml(__('Boleto PDF: ')); ?>
<a href="<?php echo $block->escapeUrl($block->getBoletoPdfUrl()); ?>"> <a href="<?php echo $block->escapeUrl($boletoData['downloadUrl']); ?>">
<?php echo $block->escapeHtml(__('Click here to download the Boleto PDF')); ?> <?php echo $block->escapeHtml(__('Click here to download the Boleto PDF')); ?>
</a> </a>
</p> </p>
...@@ -97,35 +100,35 @@ ...@@ -97,35 +100,35 @@
<table> <table>
<tbody> <tbody>
<?php if (!empty($multibancoData['comprafacil.entity'])) : ?> <?php if (strcmp($multibancoData['paymentMethodType'], 'multibanco') === 0) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Entity')); ?></th> <th><?php echo $block->escapeHtml(__('Entity')); ?></th>
<td><?php echo $multibancoData['comprafacil.entity'] ?></td> <td><?php echo $multibancoData['entity'] ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.reference'])) : ?> <?php if (!empty($multibancoData['reference'])) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Reference')); ?></th> <th><?php echo $block->escapeHtml(__('Reference')); ?></th>
<td><?php echo $multibancoData['comprafacil.reference'] ?></td> <td><?php echo $multibancoData['reference'] ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.amount'])) : ?> <?php if (!empty($multibancoData['totalAmount'])) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Amount')); ?></th> <th><?php echo $block->escapeHtml(__('Amount')); ?></th>
<td><?php echo $multibancoData['comprafacil.amount'] ?></td> <td><?php echo $block->priceHelper->currency($multibancoData['totalAmount']['value']) //TODO: This value is showing as it comes from the API call and based on the currency the decimal point could be wrong until the Checkout Component is implemented ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.deadline'])) : ?> <?php if (!empty($multibancoData['expiresAt'])) : ?>
<tr> <tr>
<th><?php echo $block->escapeHtml(__('Payment deadline')); ?></th> <th><?php echo $block->escapeHtml(__('Payment deadline')); ?></th>
<td><?php echo $multibancoData['comprafacil.deadline'] ?> <?php echo $block->escapeHtml(__('Days')); ?></td> <td><?php echo $multibancoData['expiresAt'] ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
</table> </table>
<?php endif; ?> <?php endif; ?>
\ No newline at end of file
...@@ -113,6 +113,12 @@ ...@@ -113,6 +113,12 @@
margin-right: 10px; margin-right: 10px;
} }
@supports not (-webkit-appearance: -apple-pay-button) {
#apple-pay-payment-method {
display: none;
}
}
.apple-pay-button-with-text { .apple-pay-button-with-text {
--apple-pay-scale: 1.5625; /* (height / 32) */ --apple-pay-scale: 1.5625; /* (height / 32) */
display: inline-flex; display: inline-flex;
...@@ -1237,11 +1243,13 @@ ...@@ -1237,11 +1243,13 @@
height:100%; height:100%;
width:100% width:100%
} }
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05{ .adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05{
overflow:hidden; overflow:hidden;
padding-top:56.25%; padding-top:56.25%;
position:relative position:relative
} }
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05 .adyen-checkout__iframe--threeDSIframe{ .adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05 .adyen-checkout__iframe--threeDSIframe{
border:0; border:0;
height:100%; height:100%;
...@@ -1613,15 +1621,20 @@ ...@@ -1613,15 +1621,20 @@
/* Checkout component Adyen styling end */ /* Checkout component Adyen styling end */
/* never show the close button as this will result in errors */ /* never show the close button as this will result in errors */
.threeDS2Modal .action-close {display:none; } .threeDS2Modal .action-close {
display:none;
}
.threeDS2Modal #threeDS2Container { .threeDS2Modal #threeDS2Container {
margin-bottom: 5rem; margin-bottom: 5rem;
} }
.adyen-checkout__threeds2, .adyen-checkout__threeds2__challenge { .adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05 .adyen-checkout__iframe--threeDSIframe{
height:100%; position: relative;
min-height: 400px;
} }
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05{
overflow:auto;
padding-top: 0;
}
...@@ -61,10 +61,17 @@ define( ...@@ -61,10 +61,17 @@ define(
} }
} }
).fail( ).fail(
function (response) { function () {
self.setPaymentMethods([]); self.setPaymentMethods([]);
} }
) )
},
getOrderPaymentStatus: function (orderId) {
var serviceUrl = urlBuilder.createUrl('/adyen/orders/:orderId/payment-status', {
orderId: orderId
});
return storage.get(serviceUrl);
} }
}; };
} }
......
...@@ -38,9 +38,30 @@ define( ...@@ -38,9 +38,30 @@ define(
'Magento_Checkout/js/action/select-payment-method', 'Magento_Checkout/js/action/select-payment-method',
'Adyen_Payment/js/threeds2-js-utils', 'Adyen_Payment/js/threeds2-js-utils',
'Adyen_Payment/js/model/threeds2', 'Adyen_Payment/js/model/threeds2',
'Magento_Checkout/js/model/error-processor' 'Magento_Checkout/js/model/error-processor',
'Adyen_Payment/js/model/adyen-payment-service'
], ],
function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installmentsHelper, url, VaultEnabler, urlBuilder, storage, fullScreenLoader, setPaymentMethodAction, selectPaymentMethodAction, threeDS2Utils, threeds2, errorProcessor) { function (
$,
ko,
Component,
customer,
creditCardData,
additionalValidators,
quote,
installmentsHelper,
url,
VaultEnabler,
urlBuilder,
storage,
fullScreenLoader,
setPaymentMethodAction,
selectPaymentMethodAction,
threeDS2Utils,
threeds2,
errorProcessor,
adyenPaymentService
) {
'use strict'; 'use strict';
...@@ -103,7 +124,7 @@ define( ...@@ -103,7 +124,7 @@ define(
* set up the installments * set up the installments
*/ */
renderSecureFields: function () { renderSecureFields: function () {
let self = this; var self = this;
if (!self.getOriginKey()) { if (!self.getOriginKey()) {
return; return;
...@@ -112,8 +133,8 @@ define( ...@@ -112,8 +133,8 @@ define(
self.installments(0); self.installments(0);
// installments // installments
let allInstallments = self.getAllInstallments(); var allInstallments = self.getAllInstallments();
let cardNode = document.getElementById('cardContainer'); var cardNode = document.getElementById('cardContainer');
self.cardComponent = self.checkout.create('card', { self.cardComponent = self.checkout.create('card', {
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
...@@ -146,15 +167,15 @@ define( ...@@ -146,15 +167,15 @@ define(
if (creditCardType) { if (creditCardType) {
// If the credit card type is already set, check if it changed or not // If the credit card type is already set, check if it changed or not
if (!self.creditCardType() || self.creditCardType() && self.creditCardType() != creditCardType) { if (!self.creditCardType() || self.creditCardType() && self.creditCardType() != creditCardType) {
let numberOfInstallments = []; var numberOfInstallments = [];
if (creditCardType in allInstallments) { if (creditCardType in allInstallments) {
// get for the creditcard the installments // get for the creditcard the installments
let installmentCreditcard = allInstallments[creditCardType]; var installmentCreditcard = allInstallments[creditCardType];
let grandTotal = quote.totals().grand_total; var grandTotal = quote.totals().grand_total;
let precision = quote.getPriceFormat().precision; var precision = quote.getPriceFormat().precision;
let currencyCode = quote.totals().quote_currency_code; var currencyCode = quote.totals().quote_currency_code;
numberOfInstallments = installmentsHelper.getInstallmentsWithPrices(installmentCreditcard, grandTotal, precision, currencyCode); numberOfInstallments = installmentsHelper.getInstallmentsWithPrices(installmentCreditcard, grandTotal, precision, currencyCode);
} }
...@@ -224,12 +245,13 @@ define( ...@@ -224,12 +245,13 @@ define(
var popupModal = $('#threeDS2Modal').modal({ var popupModal = $('#threeDS2Modal').modal({
// disable user to hide popup // disable user to hide popup
clickableOverlay: false, clickableOverlay: false,
responsive: true,
innerScroll: false,
// empty buttons, we don't need that // empty buttons, we don't need that
buttons: [], buttons: [],
modalClass: 'threeDS2Modal' modalClass: 'threeDS2Modal'
}); });
popupModal.modal("openModal"); popupModal.modal("openModal");
self.threeDS2ChallengeComponent = self.checkout self.threeDS2ChallengeComponent = self.checkout
...@@ -239,7 +261,6 @@ define( ...@@ -239,7 +261,6 @@ define(
onComplete: function (result) { onComplete: function (result) {
self.threeDS2ChallengeComponent.unmount(); self.threeDS2ChallengeComponent.unmount();
self.closeModal(popupModal); self.closeModal(popupModal);
fullScreenLoader.startLoader(); fullScreenLoader.startLoader();
threeds2.processThreeDS2(result.data).done(function (responseJSON) { threeds2.processThreeDS2(result.data).done(function (responseJSON) {
self.validateThreeDS2OrPlaceOrder(responseJSON); self.validateThreeDS2OrPlaceOrder(responseJSON);
...@@ -338,7 +359,10 @@ define( ...@@ -338,7 +359,10 @@ define(
).done( ).done(
function (response) { function (response) {
self.afterPlaceOrder(); self.afterPlaceOrder();
self.validateThreeDS2OrPlaceOrder(response); adyenPaymentService.getOrderPaymentStatus(response)
.done(function (responseJSON) {
self.validateThreeDS2OrPlaceOrder(responseJSON)
});
} }
); );
} }
...@@ -481,7 +505,12 @@ define( ...@@ -481,7 +505,12 @@ define(
} }
var countryId = quote.billingAddress().countryId; var countryId = quote.billingAddress().countryId;
var currencyCode = quote.totals().quote_currency_code; var currencyCode = quote.totals().quote_currency_code;
return currencyCode === "BRL" && countryId === "BR"; var allowedCurrenciesByCountry = {
'BR': 'BRL',
'MX': 'MXN'
};
return allowedCurrenciesByCountry[countryId] &&
currencyCode === allowedCurrenciesByCountry[countryId];
}, },
setPlaceOrderHandler: function (handler) { setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
......
...@@ -180,16 +180,6 @@ define( ...@@ -180,16 +180,6 @@ define(
result.placeRedirectOrder = function placeRedirectOrder(data) { result.placeRedirectOrder = function placeRedirectOrder(data) {
return self.placeRedirectOrder(data); return self.placeRedirectOrder(data);
}; };
/**
* Set and get if the place order action is allowed
* Sets the placeOrderAllowed observable and the original isPlaceOrderActionAllowed as well
* @param bool
* @returns {*}
*/
result.isPlaceOrderAllowed = function (bool) {
self.isPlaceOrderActionAllowed(bool);
return result.placeOrderAllowed(bool);
};
/** /**
* Set and get if the place order action is allowed * Set and get if the place order action is allowed
......
...@@ -40,9 +40,32 @@ define( ...@@ -40,9 +40,32 @@ define(
'mage/storage', 'mage/storage',
'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/place-order',
'Adyen_Payment/js/model/threeds2', 'Adyen_Payment/js/model/threeds2',
'Magento_Checkout/js/model/error-processor' 'Magento_Checkout/js/model/error-processor',
'Adyen_Payment/js/model/adyen-payment-service'
], ],
function (ko, _, $, Component, selectPaymentMethodAction, additionalValidators, quote, checkoutData, redirectOnSuccessAction, layout, Messages, url, threeDS2Utils, fullScreenLoader, setPaymentMethodAction, urlBuilder, storage, placeOrderAction, threeds2, errorProcessor) { function (
ko,
_,
$,
Component,
selectPaymentMethodAction,
additionalValidators,
quote,
checkoutData,
redirectOnSuccessAction,
layout,
Messages,
url,
threeDS2Utils,
fullScreenLoader,
setPaymentMethodAction,
urlBuilder,
storage,
placeOrderAction,
threeds2,
errorProcessor,
adyenPaymentService
) {
'use strict'; 'use strict';
...@@ -210,7 +233,10 @@ define( ...@@ -210,7 +233,10 @@ define(
).done( ).done(
function (response) { function (response) {
self.afterPlaceOrder(); self.afterPlaceOrder();
self.validateThreeDS2OrPlaceOrder(response); adyenPaymentService.getOrderPaymentStatus(response)
.done(function (responseJSON) {
self.validateThreeDS2OrPlaceOrder(responseJSON)
});
} }
); );
} }
...@@ -334,6 +360,8 @@ define( ...@@ -334,6 +360,8 @@ define(
var popupModal = $('#threeDS2ModalOneClick').modal({ var popupModal = $('#threeDS2ModalOneClick').modal({
// disable user to hide popup // disable user to hide popup
clickableOverlay: false, clickableOverlay: false,
responsive: true,
innerScroll: false,
// empty buttons, we don't need that // empty buttons, we don't need that
buttons: [], buttons: [],
modalClass: 'threeDS2Modal' modalClass: 'threeDS2Modal'
......
...@@ -60,15 +60,15 @@ define( ...@@ -60,15 +60,15 @@ define(
}, },
initialize: function () { initialize: function () {
this._super(); this._super();
let self = this; var self = this;
// installments // installments
let allInstallments = self.getAllInstallments(); var allInstallments = self.getAllInstallments();
let grandTotal = quote.totals().grand_total; var grandTotal = quote.totals().grand_total;
let precision = quote.getPriceFormat().precision; var precision = quote.getPriceFormat().precision;
let currencyCode = quote.totals().quote_currency_code; var currencyCode = quote.totals().quote_currency_code;
let numberOfInstallments = installmentsHelper.getInstallmentsWithPrices(allInstallments, grandTotal, precision, currencyCode); var numberOfInstallments = installmentsHelper.getInstallmentsWithPrices(allInstallments, grandTotal, precision, currencyCode);
if (numberOfInstallments) { if (numberOfInstallments) {
self.installments(numberOfInstallments); self.installments(numberOfInstallments);
...@@ -86,7 +86,7 @@ define( ...@@ -86,7 +86,7 @@ define(
serviceUrl = urlBuilder.createUrl('/adyen/initiate', {}); serviceUrl = urlBuilder.createUrl('/adyen/initiate', {});
fullScreenLoader.startLoader(); fullScreenLoader.startLoader();
let payload = { var payload = {
"payload": JSON.stringify({ "payload": JSON.stringify({
terminal_id: self.terminalId(), terminal_id: self.terminalId(),
number_of_installments: self.installment() number_of_installments: self.installment()
...@@ -129,10 +129,10 @@ define( ...@@ -129,10 +129,10 @@ define(
) )
}, },
getConnectedTerminals: function() { getConnectedTerminals: function() {
let connectedTerminals = []; var connectedTerminals = [];
const connectedTerminalsList = window.checkoutConfig.payment.adyenPos.connectedTerminals; const connectedTerminalsList = window.checkoutConfig.payment.adyenPos.connectedTerminals;
for (let i = 0; i < connectedTerminalsList.length; i++) { for (var i = 0; i < connectedTerminalsList.length; i++) {
connectedTerminals.push( connectedTerminals.push(
{ {
key: connectedTerminalsList[i], key: connectedTerminalsList[i],
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
--> -->
<!-- ko if: isApplePayAllowed() --> <!-- ko if: isApplePayAllowed() -->
<div id="apple-pay-payment-method">
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}, visible: isApplePayVisible()"> <div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}, visible: isApplePayVisible()">
<div class="payment-method-title field choice"> <div class="payment-method-title field choice">
<input type="radio" <input type="radio"
...@@ -60,4 +62,5 @@ ...@@ -60,4 +62,5 @@
</div> </div>
</div> </div>
<!--/ko--> </div>
\ No newline at end of file <!--/ko-->
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