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 798c6448 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #214 from Adyen/develop

Hotfix release 2.1.3
parents 01469611 91682aa1
**Magento version**: x.y.z
**Plugin version**: x.y.z
**Description**
<!--
- please provide description of the issue. In case of bug report, please provide the necessary steps to reproduce.
- For merchant specific requests, please use https://support.adyen.com
-->
\ No newline at end of file
**Description**
<!-- Please provide a description of the changes proposed in the Pull Request -->
**Tested scenarios**
<!-- Description of tested scenarios -->
**Fixed issue**: <!-- #-prefixed issue number -->
\ No newline at end of file
...@@ -84,7 +84,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -84,7 +84,8 @@ class Redirect extends \Magento\Payment\Block\Form
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Tax\Model\Config $taxConfig, \Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Model\Calculation $taxCalculation \Magento\Tax\Model\Calculation $taxCalculation
) { )
{
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession; $this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data); parent::__construct($context, $data);
...@@ -131,7 +132,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -131,7 +132,8 @@ class Redirect extends \Magento\Payment\Block\Form
} else { } else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
$this->_order->getPayment()->getAdditionalInformation('brand_code') $this->_order->getPayment()->getAdditionalInformation('brand_code')
)) { )
) {
$url = "https://test.adyen.com/hpp/skipDetails.shtml"; $url = "https://test.adyen.com/hpp/skipDetails.shtml";
} else { } else {
$url = "https://test.adyen.com/hpp/details.shtml"; $url = "https://test.adyen.com/hpp/details.shtml";
...@@ -148,7 +150,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -148,7 +150,8 @@ class Redirect extends \Magento\Payment\Block\Form
} else { } else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
$this->_order->getPayment()->getAdditionalInformation('brand_code') $this->_order->getPayment()->getAdditionalInformation('brand_code')
)) { )
) {
$url = "https://live.adyen.com/hpp/skipDetails.shtml"; $url = "https://live.adyen.com/hpp/skipDetails.shtml";
} else { } else {
$url = "https://live.adyen.com/hpp/details.shtml"; $url = "https://live.adyen.com/hpp/details.shtml";
...@@ -158,7 +161,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -158,7 +161,7 @@ class Redirect extends \Magento\Payment\Block\Form
break; break;
} }
} }
} catch(Exception $e) { } catch (Exception $e) {
// do nothing for now // do nothing for now
throw($e); throw($e);
} }
...@@ -203,7 +206,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -203,7 +206,8 @@ class Redirect extends \Magento\Payment\Block\Form
// if directory lookup is enabled use the billingaddress as countrycode // if directory lookup is enabled use the billingaddress as countrycode
if ($countryCode == false) { if ($countryCode == false) {
if ($this->_order->getBillingAddress() && if ($this->_order->getBillingAddress() &&
$this->_order->getBillingAddress()->getCountryId() != "") { $this->_order->getBillingAddress()->getCountryId() != ""
) {
$countryCode = $this->_order->getBillingAddress()->getCountryId(); $countryCode = $this->_order->getBillingAddress()->getCountryId();
} }
} }
...@@ -274,8 +278,6 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -274,8 +278,6 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields = $this->setOpenInvoiceData($formFields); $formFields = $this->setOpenInvoiceData($formFields);
$formFields['shopper.gender'] = $this->getGenderText($this->_order->getCustomerGender()); $formFields['shopper.gender'] = $this->getGenderText($this->_order->getCustomerGender());
$dob = $this->_order->getCustomerDob(); $dob = $this->_order->getCustomerDob();
if ($dob) { if ($dob) {
$formFields['shopper.dateOfBirthDayOfMonth'] = trim($this->_getDate($dob, 'd')); $formFields['shopper.dateOfBirthDayOfMonth'] = trim($this->_getDate($dob, 'd'));
...@@ -285,6 +287,10 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -285,6 +287,10 @@ class Redirect extends \Magento\Payment\Block\Form
// For klarna acceptPrivacyPolicy to skip HPP page // For klarna acceptPrivacyPolicy to skip HPP page
if ($brandCode == "klarna") { if ($brandCode == "klarna") {
$ssn = $this->_order->getPayment()->getAdditionalInformation('ssn');
if (!empty($ssn)) {
$formFields['shopper.socialSecurityNumber'] = $ssn;
}
// // needed for DE and AT // // needed for DE and AT
$formFields['klarna.acceptPrivacyPolicy'] = 'true'; $formFields['klarna.acceptPrivacyPolicy'] = 'true';
} }
...@@ -318,13 +324,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -318,13 +324,9 @@ class Redirect extends \Magento\Payment\Block\Form
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true)); $this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
} }
} catch(Exception $e) { } catch (Exception $e) {
// do nothing for now // do nothing for now
} }
// echo "GENDER" . $this->_order->getCustomerGender();
//
// print_r($formFields);die();
return $formFields; return $formFields;
} }
...@@ -336,9 +338,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -336,9 +338,7 @@ class Redirect extends \Magento\Payment\Block\Form
protected function setBillingAddressData($formFields) protected function setBillingAddressData($formFields)
{ {
$billingAddress = $this->_order->getBillingAddress(); $billingAddress = $this->_order->getBillingAddress();
if ($billingAddress) { if ($billingAddress) {
$formFields['shopper.firstName'] = trim($billingAddress->getFirstname()); $formFields['shopper.firstName'] = trim($billingAddress->getFirstname());
$middleName = trim($billingAddress->getMiddlename()); $middleName = trim($billingAddress->getMiddlename());
if ($middleName != "") { if ($middleName != "") {
...@@ -347,7 +347,6 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -347,7 +347,6 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['shopper.lastName'] = trim($billingAddress->getLastname()); $formFields['shopper.lastName'] = trim($billingAddress->getLastname());
$formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone()); $formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone());
$street = $this->_adyenHelper->getStreet($billingAddress); $street = $this->_adyenHelper->getStreet($billingAddress);
if (isset($street['name']) && $street['name'] != "") { if (isset($street['name']) && $street['name'] != "") {
...@@ -467,7 +466,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -467,7 +466,7 @@ class Redirect extends \Magento\Payment\Block\Form
// Calculate vat percentage // Calculate vat percentage
$itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent()); $itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent());
$numberOfItems = (int) $item->getQtyOrdered(); $numberOfItems = (int)$item->getQtyOrdered();
$formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount, $formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems); $itemVatAmount, $itemVatPercentage, $numberOfItems);
...@@ -515,7 +514,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -515,7 +514,7 @@ class Redirect extends \Magento\Payment\Block\Form
$itemVatAmount, $itemVatPercentage, $numberOfItems); $itemVatAmount, $itemVatPercentage, $numberOfItems);
} }
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for ".$formFields['merchantReference']; $formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference'];
$formFields['openinvoicedata.numberOfLines'] = $count; $formFields['openinvoicedata.numberOfLines'] = $count;
return $formFields; return $formFields;
...@@ -535,8 +534,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -535,8 +534,9 @@ class Redirect extends \Magento\Payment\Block\Form
*/ */
protected function setOpenInvoiceLineData($formFields, $count, $currencyCode, $description, $itemAmount, protected function setOpenInvoiceLineData($formFields, $count, $currencyCode, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems $itemVatAmount, $itemVatPercentage, $numberOfItems
) { )
$linename = "line".$count; {
$linename = "line" . $count;
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode; $formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode;
$formFields['openinvoicedata.' . $linename . '.description'] = $description; $formFields['openinvoicedata.' . $linename . '.description'] = $description;
$formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount; $formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount;
...@@ -545,7 +545,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -545,7 +545,8 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems; $formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems;
if ($this->_adyenHelper->isVatCategoryHigh($this->_order->getPayment()->getAdditionalInformation( if ($this->_adyenHelper->isVatCategoryHigh($this->_order->getPayment()->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE))) { \Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE))
) {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High"; $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
} else { } else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None"; $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
......
...@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Command; ...@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Command;
use Magento\Payment\Gateway\Command; use Magento\Payment\Gateway\Command;
use Magento\Payment\Gateway\CommandInterface; use Magento\Payment\Gateway\CommandInterface;
class PayByMailCommand implements CommandInterface class PayByMailCommand implements CommandInterface
{ {
...@@ -34,11 +35,6 @@ class PayByMailCommand implements CommandInterface ...@@ -34,11 +35,6 @@ class PayByMailCommand implements CommandInterface
*/ */
protected $_adyenHelper; protected $_adyenHelper;
/**
* @var ResolverInterface
*/
protected $_resolver;
/** /**
* @var \Adyen\Payment\Logger\AdyenLogger * @var \Adyen\Payment\Logger\AdyenLogger
*/ */
...@@ -53,11 +49,9 @@ class PayByMailCommand implements CommandInterface ...@@ -53,11 +49,9 @@ class PayByMailCommand implements CommandInterface
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Locale\ResolverInterface $resolver,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger
) { ) {
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_resolver = $resolver;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
} }
/** /**
...@@ -134,6 +128,7 @@ class PayByMailCommand implements CommandInterface ...@@ -134,6 +128,7 @@ class PayByMailCommand implements CommandInterface
$realOrderId = $order->getRealOrderId(); $realOrderId = $order->getRealOrderId();
$orderCurrencyCode = $order->getOrderCurrencyCode(); $orderCurrencyCode = $order->getOrderCurrencyCode();
$storeId = $order->getStore()->getId();
// check if paybymail has it's own skin // check if paybymail has it's own skin
$skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code')); $skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code'));
...@@ -141,18 +136,20 @@ class PayByMailCommand implements CommandInterface ...@@ -141,18 +136,20 @@ class PayByMailCommand implements CommandInterface
// use HPP skin and HMAC // use HPP skin and HMAC
$skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code'); $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code');
$hmacKey = $this->_adyenHelper->getHmac(); $hmacKey = $this->_adyenHelper->getHmac();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale', $storeId));
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code', $storeId));
} else { } else {
// use pay_by_mail skin and hmac // use pay_by_mail skin and hmac
$hmacKey = $this->_adyenHelper->getHmacPayByMail(); $hmacKey = $this->_adyenHelper->getHmacPayByMail();
} }
$amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode); $amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account')); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId));
$shopperEmail = $order->getCustomerEmail(); $shopperEmail = $order->getCustomerEmail();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale'));
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_resolver->getLocale(); // get locale from store
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code')); $shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_adyenHelper->getStoreLocale($storeId);
$countryCode = (!empty($countryCode)) ? $countryCode : false; $countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode // if directory lookup is enabled use the billingadress as countrycode
...@@ -164,7 +161,7 @@ class PayByMailCommand implements CommandInterface ...@@ -164,7 +161,7 @@ class PayByMailCommand implements CommandInterface
} }
} }
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days'); $deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days', $storeId);
$deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5; $deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5;
$formFields = []; $formFields = [];
...@@ -184,9 +181,9 @@ class PayByMailCommand implements CommandInterface ...@@ -184,9 +181,9 @@ class PayByMailCommand implements CommandInterface
$formFields['shopperEmail'] = $shopperEmail; $formFields['shopperEmail'] = $shopperEmail;
// recurring // recurring
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type')); $recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId));
$sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity'); $sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity', $storeId);
if ($sessionValidity == "") { if ($sessionValidity == "") {
$sessionValidity = 3; $sessionValidity = 3;
......
...@@ -816,4 +816,9 @@ class Data extends AbstractHelper ...@@ -816,4 +816,9 @@ class Data extends AbstractHelper
return $this->_assetRepo->createAsset($fileId, $params); return $this->_assetRepo->createAsset($fileId, $params);
} }
public function getStoreLocale($storeId) {
$path = \Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE;
return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
} }
\ No newline at end of file
...@@ -336,9 +336,9 @@ class PaymentMethods extends AbstractHelper ...@@ -336,9 +336,9 @@ class PaymentMethods extends AbstractHelper
return $locale; return $locale;
} }
// should have the vulue if not fall back to default // should have the value if not fall back to default
$localeCode = $this->_config->getValue( $localeCode = $this->_config->getValue(
Data::XML_PATH_DEFAULT_LOCALE, \Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES, \Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode() $store->getCode()
); );
......
...@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model; ...@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model;
use Magento\Framework\Webapi\Exception; use Magento\Framework\Webapi\Exception;
use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Framework\App\Area; use Magento\Framework\App\Area;
use Magento\Framework\App\AreaList; use Magento\Framework\App\AreaList;
use Magento\Framework\Phrase\Renderer\Placeholder; use Magento\Framework\Phrase\Renderer\Placeholder;
...@@ -71,6 +72,11 @@ class Cron ...@@ -71,6 +72,11 @@ class Cron
*/ */
protected $_orderSender; protected $_orderSender;
/**
* @var InvoiceSender
*/
protected $_invoiceSender;
/** /**
* @var \Magento\Framework\DB\TransactionFactory * @var \Magento\Framework\DB\TransactionFactory
*/ */
...@@ -180,6 +186,7 @@ class Cron ...@@ -180,6 +186,7 @@ class Cron
* @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param OrderSender $orderSender * @param OrderSender $orderSender
* @param InvoiceSender $invoiceSender
* @param \Magento\Framework\DB\TransactionFactory $transactionFactory * @param \Magento\Framework\DB\TransactionFactory $transactionFactory
* @param Billing\AgreementFactory $billingAgreementFactory * @param Billing\AgreementFactory $billingAgreementFactory
* @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory * @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
...@@ -195,6 +202,7 @@ class Cron ...@@ -195,6 +202,7 @@ class Cron
\Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\OrderFactory $orderFactory,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
OrderSender $orderSender, OrderSender $orderSender,
InvoiceSender $invoiceSender,
\Magento\Framework\DB\TransactionFactory $transactionFactory, \Magento\Framework\DB\TransactionFactory $transactionFactory,
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory, \Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory, \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
...@@ -209,6 +217,7 @@ class Cron ...@@ -209,6 +217,7 @@ class Cron
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_orderSender = $orderSender; $this->_orderSender = $orderSender;
$this->_invoiceSender = $invoiceSender;
$this->_transactionFactory = $transactionFactory; $this->_transactionFactory = $transactionFactory;
$this->_billingAgreementFactory = $billingAgreementFactory; $this->_billingAgreementFactory = $billingAgreementFactory;
$this->_billingAgreementCollectionFactory = $billingAgreementCollectionFactory; $this->_billingAgreementCollectionFactory = $billingAgreementCollectionFactory;
...@@ -226,7 +235,7 @@ class Cron ...@@ -226,7 +235,7 @@ class Cron
{ {
// needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413 // needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413
$renderer = Phrase::getRenderer(); $renderer = Phrase::getRenderer();
if($renderer instanceof Placeholder) { if ($renderer instanceof Placeholder) {
$this->_areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE); $this->_areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);
} }
...@@ -247,9 +256,7 @@ class Cron ...@@ -247,9 +256,7 @@ class Cron
foreach ($notifications as $notification) { foreach ($notifications as $notification) {
// set Cron processing to true // set Cron processing to true
$notification->setProcessing(true); $this->_updateNotification($notification, true, false);
$notification->setUpdatedAt(new \DateTime());
$notification->save();
} }
// loop over the notifications // loop over the notifications
...@@ -260,21 +267,29 @@ class Cron ...@@ -260,21 +267,29 @@ class Cron
sprintf("Processing notification %s", $notification->getEntityId()) sprintf("Processing notification %s", $notification->getEntityId())
); );
// ignore duplicate notification
if ($this->_isDuplicate($notification)) {
$this->_adyenLogger->addAdyenNotificationCronjob(
"This is a duplicate notification and will be ignored"
);
$this->_updateNotification($notification, false, true);
++$count;
continue;
}
/** /**
* If the event is a RECURRING_CONTRACT wait an extra 5 minutes * If the event is a RECURRING_CONTRACT wait an extra 5 minutes
* before processing so we are sure the RECURRING_CONTRACT * before processing so we are sure the RECURRING_CONTRACT
*/ */
if (trim($notification->getEventCode()) == Notification::RECURRING_CONTRACT && if (trim($notification->getEventCode()) == Notification::RECURRING_CONTRACT &&
strtotime($notification->getCreatedAt()) >= strtotime('-5 minutes', time())) { strtotime($notification->getCreatedAt()) >= strtotime('-5 minutes', time())
) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
"This is a recurring_contract notification wait an extra 5 minutes "This is a recurring_contract notification wait an extra 5 minutes
before processing this to make sure the contract exists" before processing this to make sure the contract exists"
); );
// set processing back to false // set processing back to false
$notification->setProcessing(false); $this->_updateNotification($notification, false, false);
$notification->setUpdatedAt($dateEnd);
$notification->save();
continue; continue;
} }
...@@ -311,7 +326,8 @@ class Cron ...@@ -311,7 +326,8 @@ class Cron
*/ */
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT || if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT ||
$this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW ||
$this->_eventCode == Notification::ORDER_CLOSED) { $this->_eventCode == Notification::ORDER_CLOSED
) {
$this->_adyenLogger->addAdyenNotificationCronjob('Going to cancel the order'); $this->_adyenLogger->addAdyenNotificationCronjob('Going to cancel the order');
...@@ -328,7 +344,8 @@ class Cron ...@@ -328,7 +344,8 @@ class Cron
* refund/cancelled as well so if it is a split payment that failed cancel the order as well * refund/cancelled as well so if it is a split payment that failed cancel the order as well
*/ */
if ($previousAdyenEventCode != "AUTHORISATION : TRUE" || if ($previousAdyenEventCode != "AUTHORISATION : TRUE" ||
$this->_eventCode == Notification::ORDER_CLOSED) { $this->_eventCode == Notification::ORDER_CLOSED
) {
$this->_holdCancelOrder(false); $this->_holdCancelOrder(false);
} else { } else {
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode); $this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
...@@ -349,12 +366,8 @@ class Cron ...@@ -349,12 +366,8 @@ class Cron
} }
$this->_order->save(); $this->_order->save();
// set done to true // set done to true
$notification->setDone(true); $this->_updateNotification($notification, false, true);
$notification->setProcessing(false);
$notification->setUpdatedAt(new \DateTime());
$notification->save();
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
sprintf("Notification %s is processed", $notification->getEntityId()) sprintf("Notification %s is processed", $notification->getEntityId())
); );
...@@ -366,6 +379,35 @@ class Cron ...@@ -366,6 +379,35 @@ class Cron
} }
} }
/**
* @param $notification
* @param $processing
* @param $done
*/
protected function _updateNotification($notification, $processing, $done)
{
if ($done) {
$notification->setDone(true);
}
$notification->setProcessing($processing);
$notification->setUpdatedAt(new \DateTime());
$notification->save();
}
/**
* Check if the notification is already executed if so this is a duplicate and ignore this one
*
* @param $notification
* @return bool
*/
protected function _isDuplicate($notification)
{
return $notification->isDuplicate(
$notification->getPspreference(), $notification->getEventCode(), $notification->getSuccess(),
$notification->getOriginalReference(), true
);
}
/** /**
* Declare private variables for processing notification * Declare private variables for processing notification
* *
...@@ -461,10 +503,10 @@ class Cron ...@@ -461,10 +503,10 @@ class Cron
// check if it is a full or partial refund // check if it is a full or partial refund
$amount = $this->_value; $amount = $this->_value;
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency); $orderAmount = (int)$this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'amount notification:'.$amount . ' amount order:'.$orderAmount 'amount notification:' . $amount . ' amount order:' . $orderAmount
); );
if ($amount == $orderAmount) { if ($amount == $orderAmount) {
...@@ -487,7 +529,8 @@ class Cron ...@@ -487,7 +529,8 @@ class Cron
if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" || if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" ||
$this->_paymentMethod == "openinvoice" || $this->_paymentMethod == "ratepay" $this->_paymentMethod == "openinvoice" || $this->_paymentMethod == "ratepay"
) && ($this->_klarnaReservationNumber != null && ) && ($this->_klarnaReservationNumber != null &&
$this->_klarnaReservationNumber != "")) { $this->_klarnaReservationNumber != "")
) {
$klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber; $klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
} else { } else {
$klarnaReservationNumberText = ""; $klarnaReservationNumberText = "";
...@@ -520,7 +563,8 @@ class Cron ...@@ -520,7 +563,8 @@ class Cron
// if manual review is accepted and a status is selected. Change the status through this comment history item // if manual review is accepted and a status is selected. Change the status through this comment history item
if ($this->_eventCode == Notification::MANUAL_REVIEW_ACCEPT if ($this->_eventCode == Notification::MANUAL_REVIEW_ACCEPT
&& $this->_getFraudManualReviewAcceptStatus() != "") { && $this->_getFraudManualReviewAcceptStatus() != ""
) {
$manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus(); $manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus();
$this->_order->addStatusHistoryComment($comment, $manualReviewAcceptStatus); $this->_order->addStatusHistoryComment($comment, $manualReviewAcceptStatus);
$this->_adyenLogger->addAdyenNotificationCronjob('Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus); $this->_adyenLogger->addAdyenNotificationCronjob('Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus);
...@@ -543,7 +587,8 @@ class Cron ...@@ -543,7 +587,8 @@ class Cron
if ($this->_eventCode == Notification::AUTHORISATION if ($this->_eventCode == Notification::AUTHORISATION
|| $this->_eventCode == Notification::HANDLED_EXTERNALLY || $this->_eventCode == Notification::HANDLED_EXTERNALLY
|| ($this->_eventCode == Notification::CAPTURE && $_paymentCode == "adyen_pos")) { || ($this->_eventCode == Notification::CAPTURE && $_paymentCode == "adyen_pos")
) {
/* /*
* if current notification is authorisation : false and * if current notification is authorisation : false and
...@@ -551,7 +596,8 @@ class Cron ...@@ -551,7 +596,8 @@ class Cron
*/ */
if (strcmp($this->_success, 'false') == 0 || if (strcmp($this->_success, 'false') == 0 ||
strcmp($this->_success, '0') == 0 || strcmp($this->_success, '0') == 0 ||
strcmp($this->_success, '') == 0) { strcmp($this->_success, '') == 0
) {
$previousAdyenEventCode = $this->_order->getData('adyen_notification_event_code'); $previousAdyenEventCode = $this->_order->getData('adyen_notification_event_code');
if ($previousAdyenEventCode != "AUTHORISATION : TRUE") { if ($previousAdyenEventCode != "AUTHORISATION : TRUE") {
...@@ -684,6 +730,7 @@ class Cron ...@@ -684,6 +730,7 @@ class Cron
*/ */
protected function _processNotification() protected function _processNotification()
{ {
$this->_adyenLogger->addAdyenNotificationCronjob('Processing the notification'); $this->_adyenLogger->addAdyenNotificationCronjob('Processing the notification');
$_paymentCode = $this->_paymentMethodCode(); $_paymentCode = $this->_paymentMethodCode();
...@@ -751,6 +798,13 @@ class Cron ...@@ -751,6 +798,13 @@ class Cron
$this->_authorizePayment(); $this->_authorizePayment();
} }
break; break;
case Notification::OFFER_CLOSED:
if (!$this->_order->canCancel()) {
// Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
}
$this->_holdCancelOrder(true);
break;
case Notification::CAPTURE_FAILED: case Notification::CAPTURE_FAILED:
case Notification::CANCELLATION: case Notification::CANCELLATION:
case Notification::CANCELLED: case Notification::CANCELLED:
...@@ -767,12 +821,14 @@ class Cron ...@@ -767,12 +821,14 @@ class Cron
} }
} else { } else {
if ($this->_order->isCanceled() || if ($this->_order->isCanceled() ||
$this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED) { $this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED
) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'Order is already cancelled or holded so do nothing' 'Order is already cancelled or holded so do nothing'
); );
} else if ($this->_order->canCancel() || $this->_order->canHold()) { } else {
if ($this->_order->canCancel() || $this->_order->canHold()) {
$this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order'); $this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order');
$this->_holdCancelOrder(true); $this->_holdCancelOrder(true);
} else { } else {
...@@ -783,6 +839,7 @@ class Cron ...@@ -783,6 +839,7 @@ class Cron
$this->_setRefundAuthorized(); $this->_setRefundAuthorized();
} }
} }
}
break; break;
case Notification::RECURRING_CONTRACT: case Notification::RECURRING_CONTRACT:
...@@ -793,7 +850,8 @@ class Cron ...@@ -793,7 +850,8 @@ class Cron
$customerReference = $this->_order->getCustomerId(); $customerReference = $this->_order->getCustomerId();
$listRecurringContracts = null; $listRecurringContracts = null;
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
__('CustomerReference is: %1 and storeId is %2 and RecurringDetailsReference is %3', $customerReference, $storeId, $recurringDetailReference) __('CustomerReference is: %1 and storeId is %2 and RecurringDetailsReference is %3',
$customerReference, $storeId, $recurringDetailReference)
); );
try { try {
$listRecurringContracts = $this->_adyenPaymentRequest->getRecurringContractsForShopper( $listRecurringContracts = $this->_adyenPaymentRequest->getRecurringContractsForShopper(
...@@ -810,7 +868,8 @@ class Cron ...@@ -810,7 +868,8 @@ class Cron
foreach ($listRecurringContracts as $rc) { foreach ($listRecurringContracts as $rc) {
$recurringReferencesList[] = $rc['recurringDetailReference']; $recurringReferencesList[] = $rc['recurringDetailReference'];
if (isset($rc['recurringDetailReference']) && if (isset($rc['recurringDetailReference']) &&
$rc['recurringDetailReference'] == $recurringDetailReference) { $rc['recurringDetailReference'] == $recurringDetailReference
) {
$contractDetail = $rc; $contractDetail = $rc;
} }
} }
...@@ -860,8 +919,7 @@ class Cron ...@@ -860,8 +919,7 @@ class Cron
$billingAgreement->setStoreId($this->_order->getStoreId()); $billingAgreement->setStoreId($this->_order->getStoreId());
$billingAgreement->importOrderPayment($this->_order->getPayment()); $billingAgreement->importOrderPayment($this->_order->getPayment());
$message = __('Created billing agreement #%1.', $recurringDetailReference); $message = __('Created billing agreement #%1.', $recurringDetailReference);
} } else {
else {
$this->_adyenLogger->addAdyenNotificationCronjob("Using existing Billing Agreement"); $this->_adyenLogger->addAdyenNotificationCronjob("Using existing Billing Agreement");
$billingAgreement->setIsObjectChanged(true); $billingAgreement->setIsObjectChanged(true);
$message = __('Updated billing agreement #%1.', $recurringDetailReference); $message = __('Updated billing agreement #%1.', $recurringDetailReference);
...@@ -881,7 +939,7 @@ class Cron ...@@ -881,7 +939,7 @@ class Cron
throw new \Exception($message); throw new \Exception($message);
} }
} catch(\Exception $exception) { } catch (\Exception $exception) {
$message = $exception->getMessage(); $message = $exception->getMessage();
} }
...@@ -1002,7 +1060,8 @@ class Cron ...@@ -1002,7 +1060,8 @@ class Cron
if (($this->_paymentMethod == "c_cash" && if (($this->_paymentMethod == "c_cash" &&
$this->_getConfigData('create_shipment', 'adyen_cash', $this->_order->getStoreId())) || $this->_getConfigData('create_shipment', 'adyen_cash', $this->_order->getStoreId())) ||
($this->_getConfigData('create_shipment', 'adyen_pos', $this->_order->getStoreId()) && ($this->_getConfigData('create_shipment', 'adyen_pos', $this->_order->getStoreId()) &&
$_paymentCode == "adyen_pos")) { $_paymentCode == "adyen_pos")
) {
$this->_createShipment(); $this->_createShipment();
} }
...@@ -1018,7 +1077,7 @@ class Cron ...@@ -1018,7 +1077,7 @@ class Cron
try { try {
$this->_orderSender->send($this->_order); $this->_orderSender->send($this->_order);
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper'); $this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
} catch(\Exception $exception) { } catch (\Exception $exception) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
"Exception in Send Mail in Magento. This is an issue in the the core of Magento" . "Exception in Send Mail in Magento. This is an issue in the the core of Magento" .
$exception->getMessage() $exception->getMessage()
...@@ -1086,7 +1145,7 @@ class Cron ...@@ -1086,7 +1145,7 @@ class Cron
} }
} }
$createPendingInvoice = (bool) $this->_getConfigData( $createPendingInvoice = (bool)$this->_getConfigData(
'create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId() 'create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId()
); );
...@@ -1151,7 +1210,8 @@ class Cron ...@@ -1151,7 +1210,8 @@ class Cron
* There will be a capture send to indicate if payment is successful * There will be a capture send to indicate if payment is successful
*/ */
if (($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") && if (($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") &&
$sepaFlow == "authcap") { $sepaFlow == "authcap"
) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'Manual Capture is applied for sepa because it is in authcap flow' 'Manual Capture is applied for sepa because it is in authcap flow'
); );
...@@ -1160,10 +1220,11 @@ class Cron ...@@ -1160,10 +1220,11 @@ class Cron
// payment method ideal, cash adyen_boleto or adyen_pos has direct capture // payment method ideal, cash adyen_boleto or adyen_pos has direct capture
if ($_paymentCode == "adyen_pos" || (($_paymentCode == "adyen_sepa" || if ($_paymentCode == "adyen_pos" || (($_paymentCode == "adyen_sepa" ||
$this->_paymentMethod == "sepadirectdebit") && $sepaFlow != "authcap")) { $this->_paymentMethod == "sepadirectdebit") && $sepaFlow != "authcap")
) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method does not allow manual capture.(2) paymentCode:' . 'This payment method does not allow manual capture.(2) paymentCode:' .
$_paymentCode . ' paymentMethod:' . $this->_paymentMethod . ' sepaFLow:'.$sepaFlow $_paymentCode . ' paymentMethod:' . $this->_paymentMethod . ' sepaFLow:' . $sepaFlow
); );
return true; return true;
} }
...@@ -1178,13 +1239,13 @@ class Cron ...@@ -1178,13 +1239,13 @@ class Cron
return true; return true;
} }
// if PayPal capture modues is different from the default use this one // if PayPal capture modues is different from the default use this one
if (strcmp($this->_paymentMethod, 'paypal' ) === 0 && $captureModePayPal != "") { if (strcmp($this->_paymentMethod, 'paypal') === 0 && $captureModePayPal != "") {
if (strcmp($captureModePayPal, 'auto') === 0 ) { if (strcmp($captureModePayPal, 'auto') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is paypal and configured to work as auto capture' 'This payment method is paypal and configured to work as auto capture'
); );
return true; return true;
} elseif (strcmp($captureModePayPal, 'manual') === 0 ) { } elseif (strcmp($captureModePayPal, 'manual') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is paypal and configured to work as manual capture' 'This payment method is paypal and configured to work as manual capture'
); );
...@@ -1227,7 +1288,7 @@ class Cron ...@@ -1227,7 +1288,7 @@ class Cron
$manualCaptureAllowed = null; $manualCaptureAllowed = null;
$paymentMethod = $this->_paymentMethod; $paymentMethod = $this->_paymentMethod;
switch($paymentMethod) { switch ($paymentMethod) {
case 'cup': case 'cup':
case 'cartebancaire': case 'cartebancaire':
case 'visa': case 'visa':
...@@ -1304,7 +1365,7 @@ class Cron ...@@ -1304,7 +1365,7 @@ class Cron
); );
// get total amount of the order // get total amount of the order
$grandTotal = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $orderCurrencyCode); $grandTotal = (int)$this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $orderCurrencyCode);
// check if total amount of the order is authorised // check if total amount of the order is authorised
$res = $this->_adyenOrderPaymentCollectionFactory $res = $this->_adyenOrderPaymentCollectionFactory
...@@ -1358,7 +1419,7 @@ class Cron ...@@ -1358,7 +1419,7 @@ class Cron
$autoCapture = $this->_isAutoCapture(); $autoCapture = $this->_isAutoCapture();
$createPendingInvoice = (bool) $this->_getConfigData( $createPendingInvoice = (bool)$this->_getConfigData(
'create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId() 'create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId()
); );
...@@ -1388,12 +1449,14 @@ class Cron ...@@ -1388,12 +1449,14 @@ class Cron
$this->_setPaymentAuthorized(); $this->_setPaymentAuthorized();
$invoiceAutoMail = (bool) $this->_getConfigData( $invoiceAutoMail = (bool)$this->_scopeConfig->isSetFlag(
'send_invoice_update_mail', 'adyen_abstract', $this->_order->getStoreId() \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::XML_PATH_EMAIL_ENABLED,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$this->_order->getStoreId()
); );
if ($invoiceAutoMail) { if ($invoiceAutoMail) {
$invoice->sendEmail(); $this->_invoiceSender->send($invoice);
} }
} else { } else {
$this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order'); $this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order');
...@@ -1412,12 +1475,12 @@ class Cron ...@@ -1412,12 +1475,12 @@ class Cron
// if full amount is captured create invoice // if full amount is captured create invoice
$currency = $this->_order->getOrderCurrencyCode(); $currency = $this->_order->getOrderCurrencyCode();
$amount = $this->_value; $amount = $this->_value;
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency); $orderAmount = (int)$this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
// create invoice for the capture notification if you are on manual capture // create invoice for the capture notification if you are on manual capture
if ($createInvoice == true && $amount == $orderAmount) { if ($createInvoice == true && $amount == $orderAmount) {
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
'amount notification:'.$amount . ' amount order:'.$orderAmount 'amount notification:' . $amount . ' amount order:' . $orderAmount
); );
$this->_createInvoice(); $this->_createInvoice();
} }
......
...@@ -48,6 +48,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel ...@@ -48,6 +48,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel
const RECURRING_CONTRACT = "RECURRING_CONTRACT"; const RECURRING_CONTRACT = "RECURRING_CONTRACT";
const REPORT_AVAILABLE = "REPORT_AVAILABLE"; const REPORT_AVAILABLE = "REPORT_AVAILABLE";
const ORDER_CLOSED = "ORDER_CLOSED"; const ORDER_CLOSED = "ORDER_CLOSED";
const OFFER_CLOSED = "OFFER_CLOSED";
/** /**
* Notification constructor. * Notification constructor.
...@@ -85,11 +86,12 @@ class Notification extends \Magento\Framework\Model\AbstractModel ...@@ -85,11 +86,12 @@ class Notification extends \Magento\Framework\Model\AbstractModel
* @param $eventCode * @param $eventCode
* @param $success * @param $success
* @param $originalReference * @param $originalReference
* @return bool (true if the notification is a duplicate) * @param null $done
* @return bool
*/ */
public function isDuplicate($pspReference, $eventCode, $success, $originalReference) public function isDuplicate($pspReference, $eventCode, $success, $originalReference, $done = null)
{ {
$result = $this->getResource()->getNotification($pspReference, $eventCode, $success, $originalReference); $result = $this->getResource()->getNotification($pspReference, $eventCode, $success, $originalReference, $done);
return (empty($result)) ? false : true; return (empty($result)) ? false : true;
} }
......
...@@ -41,16 +41,25 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb ...@@ -41,16 +41,25 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param $eventCode * @param $eventCode
* @param $success * @param $success
* @param $originalReference * @param $originalReference
* @param null $done
* @return array * @return array
*/ */
public function getNotification($pspReference, $eventCode, $success, $originalReference) public function getNotification($pspReference, $eventCode, $success, $originalReference, $done = null)
{ {
$select = $this->getConnection()->select() $select = $this->getConnection()->select()
->from(['notification' => $this->getTable('adyen_notification')]) ->from(['notification' => $this->getTable('adyen_notification')])
->where('notification.pspreference=?', $pspReference) ->where('notification.pspreference=?', $pspReference)
->where('notification.event_code=?', $eventCode) ->where('notification.event_code=?', $eventCode)
->where('notification.success=?', $success) ->where('notification.success=?', $success);
->where('notification.original_reference=?', $originalReference);
if ($done !== null) {
$select->where('notification.done=?', $done);
}
if ($originalReference) {
$select->where('notification.original_reference=?', $originalReference);
}
return $this->getConnection()->fetchAll($select); return $this->getConnection()->fetchAll($select);
} }
} }
\ No newline at end of file
...@@ -81,7 +81,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -81,7 +81,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Model\Session $session \Magento\Checkout\Model\Session $session
) { )
{
$this->_paymentHelper = $paymentHelper; $this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_request = $request; $this->_request = $request;
...@@ -141,8 +142,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -141,8 +142,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
'show_telephone' 'show_telephone'
); );
$config['payment'] ['adyenHpp']['ratePayId'] = $this->_adyenHelper->getRatePayId(); $config['payment'] ['adyenHpp']['ratePayId'] = $this->_adyenHelper->getRatePayId();
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId().date('c')); $config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId() . date('c'));
$config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI'];
return $config; return $config;
} }
......
...@@ -61,6 +61,8 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver ...@@ -61,6 +61,8 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver
$paymentInfo = $this->readPaymentModelArgument($observer); $paymentInfo = $this->readPaymentModelArgument($observer);
$paymentInfo->setCcType('boleto');
foreach ($this->additionalInformationList as $additionalInformationKey) { foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) { if (isset($additionalData[$additionalInformationKey])) {
$paymentInfo->setAdditionalInformation( $paymentInfo->setAdditionalInformation(
......
...@@ -37,6 +37,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver ...@@ -37,6 +37,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
const DOB = 'dob'; const DOB = 'dob';
const TELEPHONE = 'telephone'; const TELEPHONE = 'telephone';
const DF_VALUE = 'df_value'; const DF_VALUE = 'df_value';
const SSN = 'ssn';
/** /**
...@@ -48,7 +49,8 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver ...@@ -48,7 +49,8 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
self::GENDER, self::GENDER,
self::DOB, self::DOB,
self::TELEPHONE, self::TELEPHONE,
self::DF_VALUE self::DF_VALUE,
self::SSN
]; ];
/** /**
...@@ -66,6 +68,10 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver ...@@ -66,6 +68,10 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
$paymentInfo = $this->readPaymentModelArgument($observer); $paymentInfo = $this->readPaymentModelArgument($observer);
if (isset($additionalData[self::BRAND_CODE])) {
$paymentInfo->setCcType($additionalData[self::BRAND_CODE]);
}
foreach ($this->additionalInformationList as $additionalInformationKey) { foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) { if (isset($additionalData[$additionalInformationKey])) {
$paymentInfo->setAdditionalInformation( $paymentInfo->setAdditionalInformation(
...@@ -75,4 +81,4 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver ...@@ -75,4 +81,4 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
} }
} }
} }
} }
...@@ -61,6 +61,8 @@ class AdyenSepaDataAssignObserver extends AbstractDataAssignObserver ...@@ -61,6 +61,8 @@ class AdyenSepaDataAssignObserver extends AbstractDataAssignObserver
$paymentInfo = $this->readPaymentModelArgument($observer); $paymentInfo = $this->readPaymentModelArgument($observer);
$paymentInfo->setCcType('sepa');
foreach ($this->additionalInformationList as $additionalInformationKey) { foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) { if (isset($additionalData[$additionalInformationKey])) {
$paymentInfo->setAdditionalInformation( $paymentInfo->setAdditionalInformation(
......
# Adyen_Magento2 # Adyen_Magento2
Adyen Payment plugin for Magento2 Adyen Payment plugin for Magento2. This plugin supports Magento2 version 2.1 and higher. <br/>
For Magento2 version 2.0 support, use plugin version 1.4.6.
## Installation ## ## Installation ##
``` ```
bin/composer require adyen/module-payment bin/composer require adyen/module-payment
......
...@@ -2,13 +2,12 @@ ...@@ -2,13 +2,12 @@
"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": "2.1.2", "version": "2.1.3",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
], ],
"require": { "require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"adyen/php-api-library": "*" "adyen/php-api-library": "*"
}, },
"autoload": { "autoload": {
......
...@@ -192,12 +192,5 @@ ...@@ -192,12 +192,5 @@
<group>adyen</group> <group>adyen</group>
</adyen_boleto> </adyen_boleto>
</payment> </payment>
<dev>
<js>
<minify_exclude>
live.adyen.com/hpp/js/df
</minify_exclude>
</js>
</dev>
</default> </default>
</config> </config>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="2.1.2"> <module name="Adyen_Payment" setup_version="2.1.3">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
view/base/web/images/logos/ABNAMRO.png

3.19 KB | W: | H:

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

1.97 KB | W: | H:

view/base/web/images/logos/ABNAMRO.png
view/base/web/images/logos/ABNAMRO.png
view/base/web/images/logos/ABNAMRO.png
view/base/web/images/logos/ABNAMRO.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/BUNQ.png

2.35 KB | W: | H:

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

2.05 KB | W: | H:

view/base/web/images/logos/BUNQ.png
view/base/web/images/logos/BUNQ.png
view/base/web/images/logos/BUNQ.png
view/base/web/images/logos/BUNQ.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/ING.png

7.51 KB | W: | H:

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

2.09 KB | W: | H:

view/base/web/images/logos/ING.png
view/base/web/images/logos/ING.png
view/base/web/images/logos/ING.png
view/base/web/images/logos/ING.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/KNAB.png

2.84 KB | W: | H:

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

1.54 KB | W: | H:

view/base/web/images/logos/KNAB.png
view/base/web/images/logos/KNAB.png
view/base/web/images/logos/KNAB.png
view/base/web/images/logos/KNAB.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/alipay.png

3.88 KB | W: | H:

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

2.53 KB | W: | H:

view/base/web/images/logos/alipay.png
view/base/web/images/logos/alipay.png
view/base/web/images/logos/alipay.png
view/base/web/images/logos/alipay.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/bank_ru.png

1.11 KB | W: | H:

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

1.39 KB | W: | H:

view/base/web/images/logos/bank_ru.png
view/base/web/images/logos/bank_ru.png
view/base/web/images/logos/bank_ru.png
view/base/web/images/logos/bank_ru.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/bank_ru_small.png

613 Bytes | W: | H:

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

883 Bytes | W: | H:

view/base/web/images/logos/bank_ru_small.png
view/base/web/images/logos/bank_ru_small.png
view/base/web/images/logos/bank_ru_small.png
view/base/web/images/logos/bank_ru_small.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/bank_ru_tiny.png

538 Bytes | W: | H:

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

542 Bytes | W: | H:

view/base/web/images/logos/bank_ru_tiny.png
view/base/web/images/logos/bank_ru_tiny.png
view/base/web/images/logos/bank_ru_tiny.png
view/base/web/images/logos/bank_ru_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/bcmc.png

4.45 KB | W: | H:

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

2.09 KB | W: | H:

view/base/web/images/logos/bcmc.png
view/base/web/images/logos/bcmc.png
view/base/web/images/logos/bcmc.png
view/base/web/images/logos/bcmc.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/bcmc_tiny.png

994 Bytes | W: | H:

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

729 Bytes | W: | H:

view/base/web/images/logos/bcmc_tiny.png
view/base/web/images/logos/bcmc_tiny.png
view/base/web/images/logos/bcmc_tiny.png
view/base/web/images/logos/bcmc_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/card.png

4.17 KB | W: | H:

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

2.72 KB | W: | H:

view/base/web/images/logos/card.png
view/base/web/images/logos/card.png
view/base/web/images/logos/card.png
view/base/web/images/logos/card.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/interac.png

2.04 KB | W: | H:

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

1.74 KB | W: | H:

view/base/web/images/logos/interac.png
view/base/web/images/logos/interac.png
view/base/web/images/logos/interac.png
view/base/web/images/logos/interac.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/interac_tiny.png

684 Bytes | W: | H:

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

769 Bytes | W: | H:

view/base/web/images/logos/interac_tiny.png
view/base/web/images/logos/interac_tiny.png
view/base/web/images/logos/interac_tiny.png
view/base/web/images/logos/interac_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/klarna.png

3.41 KB | W: | H:

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

1.9 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
view/base/web/images/logos/klarna_tiny.png

910 Bytes | W: | H:

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

477 Bytes | W: | H:

view/base/web/images/logos/klarna_tiny.png
view/base/web/images/logos/klarna_tiny.png
view/base/web/images/logos/klarna_tiny.png
view/base/web/images/logos/klarna_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/mc_small_grey.png

688 Bytes | W: | H:

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

822 Bytes | W: | H:

view/base/web/images/logos/mc_small_grey.png
view/base/web/images/logos/mc_small_grey.png
view/base/web/images/logos/mc_small_grey.png
view/base/web/images/logos/mc_small_grey.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/mc_tiny.png

975 Bytes | W: | H:

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

590 Bytes | W: | H:

view/base/web/images/logos/mc_tiny.png
view/base/web/images/logos/mc_tiny.png
view/base/web/images/logos/mc_tiny.png
view/base/web/images/logos/mc_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/moneta.png

2.17 KB | W: | H:

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

1.03 KB | W: | H:

view/base/web/images/logos/moneta.png
view/base/web/images/logos/moneta.png
view/base/web/images/logos/moneta.png
view/base/web/images/logos/moneta.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/online_RU_small.png

1019 Bytes | W: | H:

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

969 Bytes | W: | H:

view/base/web/images/logos/online_RU_small.png
view/base/web/images/logos/online_RU_small.png
view/base/web/images/logos/online_RU_small.png
view/base/web/images/logos/online_RU_small.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/online_RU_tiny.png

196 Bytes | W: | H:

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

601 Bytes | W: | H:

view/base/web/images/logos/online_RU_tiny.png
view/base/web/images/logos/online_RU_tiny.png
view/base/web/images/logos/online_RU_tiny.png
view/base/web/images/logos/online_RU_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/paypal.png

2.02 KB | W: | H:

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

2.87 KB | W: | H:

view/base/web/images/logos/paypal.png
view/base/web/images/logos/paypal.png
view/base/web/images/logos/paypal.png
view/base/web/images/logos/paypal.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/paypal_tiny.png

635 Bytes | W: | H:

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

1.36 KB | W: | H:

view/base/web/images/logos/paypal_tiny.png
view/base/web/images/logos/paypal_tiny.png
view/base/web/images/logos/paypal_tiny.png
view/base/web/images/logos/paypal_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/safetypay_tiny.png

665 Bytes | W: | H:

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

612 Bytes | W: | H:

view/base/web/images/logos/safetypay_tiny.png
view/base/web/images/logos/safetypay_tiny.png
view/base/web/images/logos/safetypay_tiny.png
view/base/web/images/logos/safetypay_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/sm_small.png

1.68 KB | W: | H:

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

2.14 KB | W: | H:

view/base/web/images/logos/sm_small.png
view/base/web/images/logos/sm_small.png
view/base/web/images/logos/sm_small.png
view/base/web/images/logos/sm_small.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/ukash.png

2.88 KB | W: | H:

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

4.58 KB | W: | H:

view/base/web/images/logos/ukash.png
view/base/web/images/logos/ukash.png
view/base/web/images/logos/ukash.png
view/base/web/images/logos/ukash.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/ukash_tiny.png

800 Bytes | W: | H:

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

1.63 KB | W: | H:

view/base/web/images/logos/ukash_tiny.png
view/base/web/images/logos/ukash_tiny.png
view/base/web/images/logos/ukash_tiny.png
view/base/web/images/logos/ukash_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/visa.png

2.14 KB | W: | H:

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

2.9 KB | W: | H:

view/base/web/images/logos/visa.png
view/base/web/images/logos/visa.png
view/base/web/images/logos/visa.png
view/base/web/images/logos/visa.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/visa_tiny.png

874 Bytes | W: | H:

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

1.45 KB | W: | H:

view/base/web/images/logos/visa_tiny.png
view/base/web/images/logos/visa_tiny.png
view/base/web/images/logos/visa_tiny.png
view/base/web/images/logos/visa_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/wallet_RU.png

3.87 KB | W: | H:

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

525 Bytes | W: | H:

view/base/web/images/logos/wallet_RU.png
view/base/web/images/logos/wallet_RU.png
view/base/web/images/logos/wallet_RU.png
view/base/web/images/logos/wallet_RU.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/wallet_RU_tiny.png

981 Bytes | W: | H:

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

305 Bytes | W: | H:

view/base/web/images/logos/wallet_RU_tiny.png
view/base/web/images/logos/wallet_RU_tiny.png
view/base/web/images/logos/wallet_RU_tiny.png
view/base/web/images/logos/wallet_RU_tiny.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/yourgift.png

4.21 KB | W: | H:

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

4.13 KB | W: | H:

view/base/web/images/logos/yourgift.png
view/base/web/images/logos/yourgift.png
view/base/web/images/logos/yourgift.png
view/base/web/images/logos/yourgift.png
  • 2-up
  • Swipe
  • Onion skin
view/base/web/images/logos/yourgift_tiny.png

936 Bytes | W: | H:

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

938 Bytes | W: | H:

view/base/web/images/logos/yourgift_tiny.png
view/base/web/images/logos/yourgift_tiny.png
view/base/web/images/logos/yourgift_tiny.png
view/base/web/images/logos/yourgift_tiny.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
/*global alert*/ /*global alert*/
var config = { var config = {
paths: { paths: {
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min', 'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min'
'adyen/df' : 'https://live.adyen.com/hpp/js/df'
}, },
config: { config: {
mixins: { mixins: {
......
...@@ -35,10 +35,9 @@ define( ...@@ -35,10 +35,9 @@ define(
'Magento_Checkout/js/model/url-builder', 'Magento_Checkout/js/model/url-builder',
'Adyen_Payment/js/model/adyen-payment-service', 'Adyen_Payment/js/model/adyen-payment-service',
'Magento_Customer/js/model/customer', 'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/model/full-screen-loader'
'adyen/df'
], ],
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, deviceFingerprint) { function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader) {
'use strict'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
...@@ -74,7 +73,7 @@ define( ...@@ -74,7 +73,7 @@ define(
// retrieve payment methods // retrieve payment methods
var serviceUrl, var serviceUrl,
payload; payload;
if(customer.isLoggedIn()) { if (customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/carts/mine/retrieve-adyen-payment-methods', {}); serviceUrl = urlBuilder.createUrl('/carts/mine/retrieve-adyen-payment-methods', {});
} else { } else {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/retrieve-adyen-payment-methods', { serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/retrieve-adyen-payment-methods', {
...@@ -91,75 +90,120 @@ define( ...@@ -91,75 +90,120 @@ define(
serviceUrl, JSON.stringify(payload) serviceUrl, JSON.stringify(payload)
).done( ).done(
function (response) { function (response) {
adyenPaymentService.setPaymentMethods(response); function waitForDfSet() {
if(JSON.stringify(response).indexOf("ratepay") > -1) { // Wait for dfSet function to be loaded from df.js script
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId; if (typeof dfSet == "undefined") {
window.di = {t: '', v: ratePayId, l: 'Checkout'}; setTimeout(waitForDfSet, 500);
function waitForDfValue() { return;
var dfValueRatePay = self.getRatePayDeviceIdentToken();
if (dfValueRatePay) {
window.di.t = dfValueRatePay.replace(':', '');
var scriptTag = document.createElement('script');
scriptTag.src = "//d.ratepay.com/" + ratePayId + "/di.js";
scriptTag.type = "text/javascript";
document.body.appendChild(scriptTag);
} else {
setTimeout(waitForDfValue, 200);
}
}
waitForDfValue();
} }
// set device fingerprint value // set device fingerprint value
dfSet('dfValue', 0); dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work // propagate this manually to knockoutjs otherwise it would not work
dfValue($('#dfValue').val()); dfValue($('#dfValue').val());
}
adyenPaymentService.setPaymentMethods(response);
if (JSON.stringify(response).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
var dfValueRatePay = self.getRatePayDeviceIdentToken();
window.di = {
t: dfValueRatePay.replace(':', ''),
v: ratePayId,
l: 'Checkout'
};
// Load Ratepay script
var ratepayScriptTag = document.createElement('script');
ratepayScriptTag.src = "//d.ratepay.com/" + ratePayId + "/di.js";
ratepayScriptTag.type = "text/javascript";
document.body.appendChild(ratepayScriptTag);
}
// Load Adyen df.js script
var dfScriptTag = document.createElement('script');
dfScriptTag.src = "//live.adyen.com/hpp/js/df.js?v=20171130";
dfScriptTag.type = "text/javascript";
document.body.appendChild(dfScriptTag);
waitForDfSet();
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
} }
).fail(function(error) { ).fail(function (error) {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
}); });
}, },
getAdyenHppPaymentMethods: function() { getAdyenHppPaymentMethods: function () {
var self = this; var self = this;
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods(); var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function(value) { var paymentList = _.map(paymentMethods, function (value) {
var result = {}; var result = {};
result.value = value.brandCode; result.value = value.brandCode;
result.name = value; result.name = value;
result.method = self.item.method; result.method = self.item.method;
result.getCode = function() { result.getCode = function () {
return self.item.method; return self.item.method;
}; };
result.validate = function () { result.validate = function () {
return self.validate(); return self.validate();
};
result.isPaymentMethodOpenInvoiceMethod = function () {
return value.isPaymentMethodOpenInvoiceMethod;
};
result.getSsnLength = function () {
if (quote.billingAddress().countryId == "NO") {
//5 digits for Norway
return 5;
} }
else {
if(value.brandCode == "ideal") { //4 digits for other Nordic countries
return 4;
}
};
if (value.brandCode == "ideal") {
result.issuerIds = value.issuers; result.issuerIds = value.issuers;
result.issuerId = ko.observable(null); result.issuerId = ko.observable(null);
} else if(value.isPaymentMethodOpenInvoiceMethod) { } else if (value.isPaymentMethodOpenInvoiceMethod) {
result.telephone = ko.observable(quote.shippingAddress().telephone); result.telephone = ko.observable(quote.shippingAddress().telephone);
result.gender = ko.observable(window.checkoutConfig.payment.adyenHpp.gender); result.gender = ko.observable(window.checkoutConfig.payment.adyenHpp.gender);
result.dob = ko.observable(window.checkoutConfig.payment.adyenHpp.dob); result.dob = ko.observable(window.checkoutConfig.payment.adyenHpp.dob);
result.datepickerValue = ko.observable(); // needed ?? result.datepickerValue = ko.observable(); // needed ??
result.ssn = ko.observable();
result.getRatePayDeviceIdentToken = function () {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
};
result.showGender = function () {
return window.checkoutConfig.payment.adyenHpp.showGender;
};
result.showDob = function () {
return window.checkoutConfig.payment.adyenHpp.showDob;
};
result.showTelephone = function () {
return window.checkoutConfig.payment.adyenHpp.showTelephone;
};
result.showSsn = function () {
if (value.brandCode.indexOf("klarna") >= 0) {
var ba = quote.billingAddress();
if (ba != null) {
var nordicCountriesList = window.checkoutConfig.payment.adyenHpp.nordicCountries;
if (nordicCountriesList.indexOf(ba.countryId) >= 0) {
return true;
} }
result.isPaymentMethodOpenInvoiceMethod = function() {
return value.isPaymentMethodOpenInvoiceMethod;
} }
result.getRatePayDeviceIdentToken = function() { }
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken; return false;
};
} }
return result; return result;
}); });
return paymentList; return paymentList;
}, },
getGenderTypes: function() { getGenderTypes: function () {
// return window.checkoutConfig.payment.adyenHpp.genderTypes; return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function (value, key) {
return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function(value, key) {
return { return {
'key': key, 'key': key,
'value': value 'value': value
...@@ -175,7 +219,7 @@ define( ...@@ -175,7 +219,7 @@ define(
return false; return false;
} }
}, },
continueToAdyenBrandCode: function() { continueToAdyenBrandCode: function () {
// set payment method to adyen_hpp // set payment method to adyen_hpp
var self = this; var self = this;
...@@ -188,13 +232,14 @@ define( ...@@ -188,13 +232,14 @@ define(
additionalData.brand_code = self.value; additionalData.brand_code = self.value;
additionalData.df_value = dfValue(); additionalData.df_value = dfValue();
if(brandCode() == "ideal") { if (brandCode() == "ideal") {
additionalData.issuer_id = this.issuerId(); additionalData.issuer_id = this.issuerId();
} else if(self.isPaymentMethodOpenInvoiceMethod()) { } else if (self.isPaymentMethodOpenInvoiceMethod()) {
additionalData.gender = this.gender(); additionalData.gender = this.gender();
additionalData.dob = this.dob(); additionalData.dob = this.dob();
additionalData.telephone = this.telephone(); additionalData.telephone = this.telephone();
if(brandCode() == "ratepay"){ additionalData.ssn = this.ssn();
if (brandCode() == "ratepay") {
additionalData.df_value = this.getRatePayDeviceIdentToken(); additionalData.df_value = this.getRatePayDeviceIdentToken();
} }
} }
...@@ -207,7 +252,7 @@ define( ...@@ -207,7 +252,7 @@ define(
return false; return false;
}, },
selectPaymentMethodBrandCode: function() { selectPaymentMethodBrandCode: function () {
var self = this; var self = this;
// set payment method to adyen_hpp // set payment method to adyen_hpp
...@@ -232,34 +277,25 @@ define( ...@@ -232,34 +277,25 @@ define(
}, },
isBrandCodeChecked: ko.computed(function () { isBrandCodeChecked: ko.computed(function () {
if(!quote.paymentMethod()) { if (!quote.paymentMethod()) {
return null; return null;
} }
if(quote.paymentMethod().method == paymentMethod()) { if (quote.paymentMethod().method == paymentMethod()) {
return brandCode(); return brandCode();
} }
return null; return null;
}), }),
isPaymentMethodSelectionOnAdyen: function() { isPaymentMethodSelectionOnAdyen: function () {
return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen; return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen;
}, },
isIconEnabled: function() { isIconEnabled: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
showGender: function() {
return window.checkoutConfig.payment.adyenHpp.showGender;
},
showDob: function() {
return window.checkoutConfig.payment.adyenHpp.showDob;
},
showTelephone: function() {
return window.checkoutConfig.payment.adyenHpp.showTelephone;
},
validate: function () { validate: function () {
return true; return true;
}, },
getRatePayDeviceIdentToken: function(){ getRatePayDeviceIdentToken: function () {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken; return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
} }
}); });
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<!-- ko if: isPaymentMethodOpenInvoiceMethod() --> <!-- ko if: isPaymentMethodOpenInvoiceMethod() -->
<!-- ko if: $parent.showGender() --> <!-- ko if: showGender() -->
<div class="field gender_type type required"> <div class="field gender_type type required">
<label data-bind="attr: {for: getCode() + '_gender_type'}" class="label"> <label data-bind="attr: {for: getCode() + '_gender_type'}" class="label">
<span><!-- ko text: $t('Gender')--><!-- /ko --></span> <span><!-- ko text: $t('Gender')--><!-- /ko --></span>
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
</div> </div>
<!--/ko--> <!--/ko-->
<!-- ko if: $parent.showDob() --> <!-- ko if: showDob() -->
<div class="field required"> <div class="field required">
<label data-bind="attr: {for: getCode() + '_dob'}" class="label"> <label data-bind="attr: {for: getCode() + '_dob'}" class="label">
<span><!-- ko text: $t('Date of Birth')--><!-- /ko --></span> <span><!-- ko text: $t('Date of Birth')--><!-- /ko --></span>
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</div> </div>
<!--/ko--> <!--/ko-->
<!-- ko if: $parent.showTelephone() --> <!-- ko if: showTelephone() -->
<div class="field required"> <div class="field required">
<label data-bind="attr: {for: getCode() + '_telephone'}" class="label"> <label data-bind="attr: {for: getCode() + '_telephone'}" class="label">
<span><!-- ko text: $t('Telephone')--><!-- /ko --></span> <span><!-- ko text: $t('Telephone')--><!-- /ko --></span>
...@@ -131,6 +131,29 @@ ...@@ -131,6 +131,29 @@
</div> </div>
</div> </div>
<!--/ko--> <!--/ko-->
<!-- ko if: showSsn() -->
<div class="field required">
<label data-bind="attr: {for: getCode() + '_ssn'}" class="label">
<span><!-- ko text: $t('Personal number (last digits)')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text" class="input-text"
name="payment[ssn]"
data-bind="
attr: {
id: getCode() + '_ssn',
title: $t('Social Security Number'),
'data-container': getCode() + '-ssn',
'data-validate': JSON.stringify({'required-number':true }),
maxlength : getSsnLength()
},
value: ssn"
/>
</div>
</div>
<!--/ko-->
<!--/ko--> <!--/ko-->
</fieldset> </fieldset>
<div class="checkout-agreements-block"> <div class="checkout-agreements-block">
......
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