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
*/
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);
$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";
......
<?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
*/
protected $_orderFactory;
/**
* @var \Magento\Framework\Pricing\Helper\Data
*/
public $priceHelper;
/**
* Success constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Framework\Pricing\Helper\Data $priceHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Pricing\Helper\Data $priceHelper,
array $data = []
) {
$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->priceHelper = $priceHelper;
parent::__construct($context, $data);
}
......@@ -96,10 +104,10 @@ class Success extends \Magento\Framework\View\Element\Template
/**
* @return null|\string[]
*/
public function getBoletoPdfUrl()
public function getBoletoData()
{
if ($this->isBoletoPayment()) {
return $this->getOrder()->getPayment()->getAdditionalInformation('url');
return $this->getOrder()->getPayment()->getAdditionalInformation('action');
}
return null;
}
......@@ -129,10 +137,14 @@ class Success extends \Magento\Framework\View\Element\Template
public function getMultibancoData()
{
$result = [];
if (!empty($this->getOrder()->getPayment()) &&
!empty($this->getOrder()->getPayment()->getAdditionalInformation('comprafacil.entity'))
if (empty($this->getOrder()->getPayment())) {
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;
......
......@@ -82,6 +82,7 @@ class TransactionAuthorization implements ClientInterface
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
return $response;
}
}
......@@ -30,29 +30,19 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/
class TransactionCancel implements ClientInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
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 = []
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient();
$this->adyenHelper = $adyenHelper;
}
/**
......@@ -62,16 +52,16 @@ class TransactionCancel implements ClientInterface
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
// call lib
$service = new \Adyen\Service\Modification($this->_client);
$service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
try {
$response = $service->cancel($request);
} catch (\Adyen\AdyenException $e) {
$response = null;
$response['error'] = $e->getMessage();
}
return $response;
}
}
......@@ -30,32 +30,19 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/
class TransactionCapture implements ClientInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
$this->_client = $this->_adyenHelper->initializeAdyenClient();
$this->adyenHelper = $adyenHelper;
}
/**
......@@ -65,15 +52,15 @@ class TransactionCapture implements ClientInterface
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
// call lib
$service = new \Adyen\Service\Modification($this->_client);
$service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
try {
$response = $service->capture($request);
} catch (\Adyen\AdyenException $e) {
$this->_adyenLogger->error($e); // add this for now not in the lib yet
$response = null;
$response['error'] = $e->getMessage();
}
return $response;
......
......@@ -30,29 +30,20 @@ use Magento\Payment\Gateway\Http\ClientInterface;
*/
class TransactionRefund implements ClientInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
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
foreach ($requests as $request) {
// call lib
$service = new \Adyen\Service\Modification($this->_client);
$service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
try {
$responses[] = $service->refund($request);
} catch (\Adyen\AdyenException $e) {
$responses[] = null;
$responses[] = array('error' => $e->getMessage());
}
}
return $responses;
......
......@@ -56,6 +56,10 @@ class TransferFactory implements TransferFactoryInterface
$this->transferBuilder->setHeaders($request['headers']);
}
if (!empty($request['clientConfig'])) {
$this->transferBuilder->setClientConfig($request['clientConfig']);
}
$transfer = $this->transferBuilder
->setBody($request['body'])
->build();
......
......@@ -64,7 +64,7 @@ class CancelDataBuilder implements BuilderInterface
"reference" => $order->getOrderIncrementId(),
"originalReference" => $pspReference
];
$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
return $request;
}
}
......@@ -81,13 +81,11 @@ class CaptureDataBuilder implements BuilderInterface
$openInvoiceFields = $this->getOpenInvoiceData($payment);
$requestBody["additionalData"] = $openInvoiceFields;
}
$request['body'] = $requestBody;
$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
return $request;
}
/**
* @param $payment
* @return mixed
......
......@@ -241,14 +241,14 @@ class CheckoutDataBuilder implements BuilderInterface
// Discount cost
if ($discountAmount != 0) {
$description = __('Total Discount');
$itemAmount = $this->adyenHelper->formatAmount($discountAmount, $currency);
$description = __('Discount');
$itemAmount = -$this->adyenHelper->formatAmount($discountAmount, $currency);
$itemVatAmount = "0";
$itemVatPercentage = "0";
$numberOfItems = 1;
$formFields['lineItems'][] = [
'itemId' => 'totalDiscount',
'id' => 'Discount',
'amountExcludingTax' => $itemAmount,
'taxAmount' => $itemVatAmount,
'description' => $description,
......
......@@ -173,9 +173,8 @@ class RefundDataBuilder implements BuilderInterface
$requestBody[0]["additionalData"] = $openInvoiceFields;
}
}
$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
$request['body'] = $requestBody;
return $request;
}
......
......@@ -61,9 +61,14 @@ class CancelResponseValidator extends AbstractValidator
// The available response codes that the API can return in case of successfull cancellation
$expectedResponses = ['[cancelOrRefund-received]', '[cancel-received]'];
if (!in_array($response['response'], $expectedResponses)) {
if (empty($response['response']) || !in_array($response['response'], $expectedResponses)) {
$errorMsg = __('Error with cancellation');
$this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg;
}
......
......@@ -58,9 +58,14 @@ class CaptureResponseValidator extends AbstractValidator
$isValid = true;
$errorMessages = [];
if ($response['response'] != '[capture-received]') {
if (empty($response['response']) || $response['response'] != '[capture-received]') {
$errorMsg = __('Error with capture');
$this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg;
}
......
......@@ -67,7 +67,7 @@ class CheckoutResponseValidator extends AbstractValidator
$isValid = true;
$errorMessages = [];
// validate result
if (isset($response['resultCode'])) {
if (!empty($response['resultCode'])) {
switch ($response['resultCode']) {
case "IdentifyShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
......@@ -89,6 +89,7 @@ class CheckoutResponseValidator extends AbstractValidator
}
}
} 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) {
if (strpos($key, 'comprafacil') === 0) {
$payment->setAdditionalInformation($key, $value);
......@@ -105,31 +106,11 @@ class CheckoutResponseValidator extends AbstractValidator
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "PresentToShopper":
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
// set additionalData
if (isset($response['outputDetails']) && is_array($response['outputDetails'])) {
$outputDetails = $response['outputDetails'];
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']
);
if (!empty($response['action'])) {
$payment->setAdditionalInformation('action', $response['action']);
}
if (!empty($response['pspReference'])) {
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
}
break;
case "RedirectShopper":
......@@ -212,6 +193,11 @@ class CheckoutResponseValidator extends AbstractValidator
}
} else {
$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));
}
......
......@@ -68,7 +68,7 @@ class GeneralResponseValidator extends AbstractValidator
$errorMessages = [];
// validate result
if ($response && isset($response['resultCode'])) {
if (!empty($response['resultCode'])) {
switch ($response['resultCode']) {
case "Authorised":
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
......@@ -139,6 +139,11 @@ class GeneralResponseValidator extends AbstractValidator
}
} else {
$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));
}
......
......@@ -59,9 +59,14 @@ class RefundResponseValidator extends AbstractValidator
$errorMessages = [];
foreach ($responses as $response) {
if ($response['response'] != '[refund-received]') {
if (empty($response['response']) || $response['response'] != '[refund-received]') {
$errorMsg = __('Error with refund');
$this->adyenLogger->error($errorMsg);
if (!empty($response['error'])) {
$this->adyenLogger->error($response['error']);
}
$errorMessages[] = $errorMsg;
}
}
......
......@@ -1834,7 +1834,7 @@ class Data extends AbstractHelper
*/
public function getCurrentLocaleCode($storeId)
{
$localeCode = $this->getAdyenAbstractConfigData('shopper_locale', $storeId);
$localeCode = $this->getAdyenHppConfigData('shopper_locale', $storeId);
if ($localeCode != "") {
return $localeCode;
}
......
......@@ -85,6 +85,11 @@ class PaymentMethods extends AbstractHelper
*/
protected $themeProvider;
/**
* @var \Magento\Quote\Model\Quote
*/
protected $quote;
/**
* PaymentMethods constructor.
*
......@@ -133,41 +138,51 @@ class PaymentMethods extends AbstractHelper
{
// get quote from 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;
}
/**
* @param $store
* @param $country
* @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) {
return [];
}
$currencyCode = $this->getCurrentCurrencyCode($store);
$adyFields = [
"channel" => "Web",
"merchantAccount" => $merchantAccount,
"countryCode" => $this->getCurrentCountryCode($store, $country),
"amount" => [
"currency" => $this->getCurrentCurrencyCode($store),
"currency" => $currencyCode,
"value" => (int)$this->adyenHelper->formatAmount(
$this->getCurrentPaymentAmount(),
$this->getCurrentCurrencyCode($store)
$currencyCode
),
],
"shopperReference" => $this->getCurrentShopperReference(),
"shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId())
];
$billingAddress = $this->getQuote()->getBillingAddress();
$billingAddress = $quote->getBillingAddress();
if (!empty($billingAddress)) {
if ($customerTelephone = trim($billingAddress->getTelephone())) {
......@@ -319,7 +334,7 @@ class PaymentMethods extends AbstractHelper
{
// initialize the adyen client
$client = $this->adyenHelper->initializeAdyenClient($this->getQuote()->getStoreId());
$client = $this->adyenHelper->initializeAdyenClient($store->getId());
// initialize service
$service = $this->adyenHelper->createAdyenCheckoutService($client);
......@@ -342,7 +357,15 @@ class PaymentMethods extends AbstractHelper
*/
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;
}
/**
......
......@@ -13,23 +13,22 @@
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
* 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\Plugin;
namespace Adyen\Payment\Model;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider;
class PaymentInformationManagement
class AdyenOrderPaymentStatus implements \Adyen\Payment\Api\AdyenOrderPaymentStatusInterface
{
/**
* @var \Magento\Sales\Api\OrderRepositoryInterface
*/
......@@ -46,7 +45,8 @@ class PaymentInformationManagement
protected $adyenHelper;
/**
* PaymentInformationManagement constructor.
* AdyenOrderPaymentStatus constructor.
*
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
......@@ -62,32 +62,31 @@ class PaymentInformationManagement
}
/**
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
* @param $result
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
* @param string $orderId
* @return bool|string
*/
public function afterSavePaymentInformationAndPlaceOrder(
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
$result
) {
try {
$order = $this->orderRepository->get($result);
public function getOrderPaymentStatus($orderId)
{
$order = $this->orderRepository->get($orderId);
$payment = $order->getPayment();
if ($payment->getMethod() === AdyenCcConfigProvider::CODE ||
$payment->getMethod() === AdyenOneclickConfigProvider::CODE
) {
return $this->adyenHelper->buildThreeDS2ProcessResponseJson($payment->getAdditionalInformation('threeDSType'),
$payment->getAdditionalInformation('threeDS2Token'));
} else {
return $result;
$additionalInformation = $payment->getAdditionalInformation();
$type = null;
if (!empty($additionalInformation['threeDSType'])) {
$type = $additionalInformation['threeDSType'];
}
} catch (NoSuchEntityException $e) {
$this->adyenLogger->error("Exception: " . $e->getMessage());
throw new \Magento\Framework\Exception\LocalizedException(__('This order no longer exists.'));
$token = null;
if (!empty($additionalInformation['threeDS2Token'])) {
$token = $additionalInformation['threeDS2Token'];
}
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 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "5.4.0",
"version": "6.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
......@@ -14,10 +14,10 @@
}
],
"require": {
"adyen/php-api-library": "~4.1",
"adyen/php-api-library": "~6",
"magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*",
"magento/module-paypal": "100.3.*"
"magento/module-paypal": ">=100.2.6"
},
"require-dev": {
"phpunit/phpunit": "~6.5.0",
......
......@@ -660,6 +660,7 @@
<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="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\ApplePayAuthorizationDataBuilder</item>
<item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringDataBuilder</item>
</argument>
</arguments>
</virtualType>
......@@ -1026,15 +1027,11 @@
type="Adyen\Payment\Model\AdyenThreeDS2Process"/>
<preference for="Adyen\Payment\Api\AdyenOriginKeyInterface"
type="Adyen\Payment\Model\AdyenOriginKey"/>
<preference for="Adyen\Payment\Api\AdyenOrderPaymentStatusInterface"
type="Adyen\Payment\Model\AdyenOrderPaymentStatus"/>
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</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-->
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
......@@ -1050,5 +1047,4 @@
<argument name="resourceModel" xsi:type="string">Adyen\Payment\Model\ResourceModel\Notification</argument>
</arguments>
</virtualType>
</config>
......@@ -71,4 +71,11 @@
<resource ref="anonymous"/>
</resources>
</route>
<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();
<?php endif; ?>
<?php if($_info->getAdditionalInformation('lastname') != ""): ?>
<div>
<?php echo __('Firstname: %1', $_info->getAdditionalInformation('lastname')) ?>
<?php echo __('Lastname: %1', $_info->getAdditionalInformation('lastname')) ?>
</div>
<?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 @@
*/
?>
<?php if ($block->isBoletoPayment()) : ?>
<?php
$boletoData = $block->getBoletoData();
?>
<p>
<?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')); ?>
</a>
</p>
......@@ -97,31 +100,31 @@
<table>
<tbody>
<?php if (!empty($multibancoData['comprafacil.entity'])) : ?>
<?php if (strcmp($multibancoData['paymentMethodType'], 'multibanco') === 0) : ?>
<tr>
<th><?php echo $block->escapeHtml(__('Entity')); ?></th>
<td><?php echo $multibancoData['comprafacil.entity'] ?></td>
<td><?php echo $multibancoData['entity'] ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.reference'])) : ?>
<?php if (!empty($multibancoData['reference'])) : ?>
<tr>
<th><?php echo $block->escapeHtml(__('Reference')); ?></th>
<td><?php echo $multibancoData['comprafacil.reference'] ?></td>
<td><?php echo $multibancoData['reference'] ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.amount'])) : ?>
<?php if (!empty($multibancoData['totalAmount'])) : ?>
<tr>
<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>
<?php endif; ?>
<?php if (!empty($multibancoData['comprafacil.deadline'])) : ?>
<?php if (!empty($multibancoData['expiresAt'])) : ?>
<tr>
<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>
<?php endif; ?>
</tbody>
......
......@@ -113,6 +113,12 @@
margin-right: 10px;
}
@supports not (-webkit-appearance: -apple-pay-button) {
#apple-pay-payment-method {
display: none;
}
}
.apple-pay-button-with-text {
--apple-pay-scale: 1.5625; /* (height / 32) */
display: inline-flex;
......@@ -1237,11 +1243,13 @@
height:100%;
width:100%
}
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05{
overflow:hidden;
padding-top:56.25%;
position:relative
}
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05 .adyen-checkout__iframe--threeDSIframe{
border:0;
height:100%;
......@@ -1613,15 +1621,20 @@
/* Checkout component Adyen styling end */
/* never show the close button as this will result in errors */
.threeDS2Modal .action-close {display:none; }
.threeDS2Modal .action-close {
display:none;
}
.threeDS2Modal #threeDS2Container {
margin-bottom: 5rem;
}
.adyen-checkout__threeds2, .adyen-checkout__threeds2__challenge {
height:100%;
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05 .adyen-checkout__iframe--threeDSIframe{
position: relative;
min-height: 400px;
}
.adyen-checkout__threeds2__challenge.adyen-checkout__threeds2__challenge--05{
overflow:auto;
padding-top: 0;
}
......@@ -61,10 +61,17 @@ define(
}
}
).fail(
function (response) {
function () {
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(
'Magento_Checkout/js/action/select-payment-method',
'Adyen_Payment/js/threeds2-js-utils',
'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';
......@@ -103,7 +124,7 @@ define(
* set up the installments
*/
renderSecureFields: function () {
let self = this;
var self = this;
if (!self.getOriginKey()) {
return;
......@@ -112,8 +133,8 @@ define(
self.installments(0);
// installments
let allInstallments = self.getAllInstallments();
let cardNode = document.getElementById('cardContainer');
var allInstallments = self.getAllInstallments();
var cardNode = document.getElementById('cardContainer');
self.cardComponent = self.checkout.create('card', {
originKey: self.getOriginKey(),
......@@ -146,15 +167,15 @@ define(
if (creditCardType) {
// If the credit card type is already set, check if it changed or not
if (!self.creditCardType() || self.creditCardType() && self.creditCardType() != creditCardType) {
let numberOfInstallments = [];
var numberOfInstallments = [];
if (creditCardType in allInstallments) {
// get for the creditcard the installments
let installmentCreditcard = allInstallments[creditCardType];
let grandTotal = quote.totals().grand_total;
let precision = quote.getPriceFormat().precision;
let currencyCode = quote.totals().quote_currency_code;
var installmentCreditcard = allInstallments[creditCardType];
var grandTotal = quote.totals().grand_total;
var precision = quote.getPriceFormat().precision;
var currencyCode = quote.totals().quote_currency_code;
numberOfInstallments = installmentsHelper.getInstallmentsWithPrices(installmentCreditcard, grandTotal, precision, currencyCode);
}
......@@ -224,12 +245,13 @@ define(
var popupModal = $('#threeDS2Modal').modal({
// disable user to hide popup
clickableOverlay: false,
responsive: true,
innerScroll: false,
// empty buttons, we don't need that
buttons: [],
modalClass: 'threeDS2Modal'
});
popupModal.modal("openModal");
self.threeDS2ChallengeComponent = self.checkout
......@@ -239,7 +261,6 @@ define(
onComplete: function (result) {
self.threeDS2ChallengeComponent.unmount();
self.closeModal(popupModal);
fullScreenLoader.startLoader();
threeds2.processThreeDS2(result.data).done(function (responseJSON) {
self.validateThreeDS2OrPlaceOrder(responseJSON);
......@@ -338,7 +359,10 @@ define(
).done(
function (response) {
self.afterPlaceOrder();
self.validateThreeDS2OrPlaceOrder(response);
adyenPaymentService.getOrderPaymentStatus(response)
.done(function (responseJSON) {
self.validateThreeDS2OrPlaceOrder(responseJSON)
});
}
);
}
......@@ -481,7 +505,12 @@ define(
}
var countryId = quote.billingAddress().countryId;
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) {
this.placeOrderHandler = handler;
......
......@@ -180,16 +180,6 @@ define(
result.placeRedirectOrder = function 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
......
......@@ -40,9 +40,32 @@ define(
'mage/storage',
'Magento_Checkout/js/action/place-order',
'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';
......@@ -210,7 +233,10 @@ define(
).done(
function (response) {
self.afterPlaceOrder();
self.validateThreeDS2OrPlaceOrder(response);
adyenPaymentService.getOrderPaymentStatus(response)
.done(function (responseJSON) {
self.validateThreeDS2OrPlaceOrder(responseJSON)
});
}
);
}
......@@ -334,6 +360,8 @@ define(
var popupModal = $('#threeDS2ModalOneClick').modal({
// disable user to hide popup
clickableOverlay: false,
responsive: true,
innerScroll: false,
// empty buttons, we don't need that
buttons: [],
modalClass: 'threeDS2Modal'
......
......@@ -60,15 +60,15 @@ define(
},
initialize: function () {
this._super();
let self = this;
var self = this;
// installments
let allInstallments = self.getAllInstallments();
let grandTotal = quote.totals().grand_total;
let precision = quote.getPriceFormat().precision;
let currencyCode = quote.totals().quote_currency_code;
var allInstallments = self.getAllInstallments();
var grandTotal = quote.totals().grand_total;
var precision = quote.getPriceFormat().precision;
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) {
self.installments(numberOfInstallments);
......@@ -86,7 +86,7 @@ define(
serviceUrl = urlBuilder.createUrl('/adyen/initiate', {});
fullScreenLoader.startLoader();
let payload = {
var payload = {
"payload": JSON.stringify({
terminal_id: self.terminalId(),
number_of_installments: self.installment()
......@@ -129,10 +129,10 @@ define(
)
},
getConnectedTerminals: function() {
let connectedTerminals = [];
var 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(
{
key: connectedTerminalsList[i],
......
......@@ -21,7 +21,9 @@
* Author: Adyen <magento@adyen.com>
*/
-->
<!-- 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-title field choice">
<input type="radio"
......@@ -60,4 +62,5 @@
</div>
</div>
</div>
<!--/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