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
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Model\Calculation $taxCalculation
) {
)
{
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data);
......@@ -127,11 +128,12 @@ class Redirect extends \Magento\Payment\Block\Form
} else {
if ($this->getPaymentMethodSelectionOnAdyen()) {
$url = 'https://test.adyen.com/hpp/select.shtml';
$url = 'https://test.adyen.com/hpp/select.shtml';
} else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)) {
)
) {
$url = "https://test.adyen.com/hpp/skipDetails.shtml";
} else {
$url = "https://test.adyen.com/hpp/details.shtml";
......@@ -144,11 +146,12 @@ class Redirect extends \Magento\Payment\Block\Form
$url = 'https://live.adyen.com/hpp/pay.shtml';
} else {
if ($this->getPaymentMethodSelectionOnAdyen()) {
$url = 'https://live.adyen.com/hpp/select.shtml';
$url = 'https://live.adyen.com/hpp/select.shtml';
} else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)) {
)
) {
$url = "https://live.adyen.com/hpp/skipDetails.shtml";
} else {
$url = "https://live.adyen.com/hpp/details.shtml";
......@@ -158,7 +161,7 @@ class Redirect extends \Magento\Payment\Block\Form
break;
}
}
} catch(Exception $e) {
} catch (Exception $e) {
// do nothing for now
throw($e);
}
......@@ -183,56 +186,57 @@ class Redirect extends \Magento\Payment\Block\Form
try {
if ($this->_order->getPayment()) {
$realOrderId = $this->_order->getRealOrderId();
$realOrderId = $this->_order->getRealOrderId();
$orderCurrencyCode = $this->_order->getOrderCurrencyCode();
$skinCode = trim($this->_adyenHelper->getAdyenHppConfigData('skin_code'));
$amount = $this->_adyenHelper->formatAmount(
$skinCode = trim($this->_adyenHelper->getAdyenHppConfigData('skin_code'));
$amount = $this->_adyenHelper->formatAmount(
$this->_order->getGrandTotal(), $orderCurrencyCode
);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account'));
$shopperEmail = $this->_order->getCustomerEmail();
$customerId = $this->_order->getCustomerId();
$shopperIP = $this->_order->getRemoteIp();
$browserInfo = $_SERVER['HTTP_USER_AGENT'];
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days');
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale'));
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_resolver->getLocale();
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code'));
$countryCode = (!empty($countryCode)) ? $countryCode : false;
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account'));
$shopperEmail = $this->_order->getCustomerEmail();
$customerId = $this->_order->getCustomerId();
$shopperIP = $this->_order->getRemoteIp();
$browserInfo = $_SERVER['HTTP_USER_AGENT'];
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days');
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale'));
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_resolver->getLocale();
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code'));
$countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingaddress as countrycode
if ($countryCode == false) {
if ($this->_order->getBillingAddress() &&
$this->_order->getBillingAddress()->getCountryId() != "") {
$this->_order->getBillingAddress()->getCountryId() != ""
) {
$countryCode = $this->_order->getBillingAddress()->getCountryId();
}
}
$formFields = [];
$formFields['merchantAccount'] = $merchantAccount;
$formFields['merchantAccount'] = $merchantAccount;
$formFields['merchantReference'] = $realOrderId;
$formFields['paymentAmount'] = (int)$amount;
$formFields['currencyCode'] = $orderCurrencyCode;
$formFields['shipBeforeDate'] = date(
$formFields['paymentAmount'] = (int)$amount;
$formFields['currencyCode'] = $orderCurrencyCode;
$formFields['shipBeforeDate'] = date(
"Y-m-d",
mktime(date("H"), date("i"), date("s"), date("m"), date("j") + $deliveryDays, date("Y"))
);
$formFields['skinCode'] = $skinCode;
$formFields['shopperLocale'] = $shopperLocale;
$formFields['countryCode'] = $countryCode;
$formFields['shopperIP'] = $shopperIP;
$formFields['browserInfo'] = $browserInfo;
$formFields['sessionValidity'] = date(
$formFields['skinCode'] = $skinCode;
$formFields['shopperLocale'] = $shopperLocale;
$formFields['countryCode'] = $countryCode;
$formFields['shopperIP'] = $shopperIP;
$formFields['browserInfo'] = $browserInfo;
$formFields['sessionValidity'] = date(
DATE_ATOM,
mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y"))
);
$formFields['shopperEmail'] = $shopperEmail;
$formFields['shopperEmail'] = $shopperEmail;
// recurring
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData(
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData(
'recurring_type')
);
$brandCode = $this->_order->getPayment()->getAdditionalInformation(
$brandCode = $this->_order->getPayment()->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
......@@ -243,30 +247,30 @@ class Redirect extends \Magento\Payment\Block\Form
if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = $customerId;
$formFields['shopperReference'] = $customerId;
} else {
// required for openinvoice payment methods use unique id
$uniqueReference = "guest_" . $realOrderId . "_" . $this->_order->getStoreId();
$formFields['shopperReference'] = $uniqueReference;
$uniqueReference = "guest_" . $realOrderId . "_" . $this->_order->getStoreId();
$formFields['shopperReference'] = $uniqueReference;
}
//blocked methods
$formFields['blockedMethods'] = "";
$formFields['blockedMethods'] = "";
$baseUrl = $this->_storeManager->getStore($this->getStore())
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK);
$formFields['resURL'] = $baseUrl . 'adyen/process/result';
$hmacKey = $this->_adyenHelper->getHmac();
$formFields['resURL'] = $baseUrl . 'adyen/process/result';
$hmacKey = $this->_adyenHelper->getHmac();
if ($brandCode) {
$formFields['brandCode'] = $brandCode;
$formFields['brandCode'] = $brandCode;
}
$issuerId = $this->_order->getPayment()->getAdditionalInformation("issuer_id");
if ($issuerId) {
$formFields['issuerId'] = $issuerId;
$formFields['issuerId'] = $issuerId;
}
$formFields = $this->setBillingAddressData($formFields);
......@@ -274,8 +278,6 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields = $this->setOpenInvoiceData($formFields);
$formFields['shopper.gender'] = $this->getGenderText($this->_order->getCustomerGender());
$dob = $this->_order->getCustomerDob();
if ($dob) {
$formFields['shopper.dateOfBirthDayOfMonth'] = trim($this->_getDate($dob, 'd'));
......@@ -285,15 +287,19 @@ class Redirect extends \Magento\Payment\Block\Form
// For klarna acceptPrivacyPolicy to skip HPP page
if ($brandCode == "klarna") {
$ssn = $this->_order->getPayment()->getAdditionalInformation('ssn');
if (!empty($ssn)) {
$formFields['shopper.socialSecurityNumber'] = $ssn;
}
// // needed for DE and AT
$formFields['klarna.acceptPrivacyPolicy'] = 'true';
$formFields['klarna.acceptPrivacyPolicy'] = 'true';
}
// OpenInvoice don't allow to edit billing and delivery items
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
// don't allow editable shipping/delivery address
$formFields['billingAddressType'] = "1";
$formFields['billingAddressType'] = "1";
$formFields['deliveryAddressType'] = "1";
// make setting to make this optional
......@@ -313,18 +319,14 @@ class Redirect extends \Magento\Payment\Block\Form
$merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true));
$formFields['merchantSig'] = $merchantSig;
$formFields['merchantSig'] = $merchantSig;
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
}
} catch(Exception $e) {
} catch (Exception $e) {
// do nothing for now
}
// echo "GENDER" . $this->_order->getCustomerGender();
//
// print_r($formFields);die();
return $formFields;
}
......@@ -336,9 +338,7 @@ class Redirect extends \Magento\Payment\Block\Form
protected function setBillingAddressData($formFields)
{
$billingAddress = $this->_order->getBillingAddress();
if ($billingAddress) {
$formFields['shopper.firstName'] = trim($billingAddress->getFirstname());
$middleName = trim($billingAddress->getMiddlename());
if ($middleName != "") {
......@@ -347,7 +347,6 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['shopper.lastName'] = trim($billingAddress->getLastname());
$formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone());
$street = $this->_adyenHelper->getStreet($billingAddress);
if (isset($street['name']) && $street['name'] != "") {
......@@ -458,7 +457,7 @@ class Redirect extends \Magento\Payment\Block\Form
$this->_adyenHelper->formatAmount(
$item->getPriceInclTax(),
$currency
) - $this->_adyenHelper->formatAmount(
) - $this->_adyenHelper->formatAmount(
$item->getPrice(),
$currency
) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency);
......@@ -467,7 +466,7 @@ class Redirect extends \Magento\Payment\Block\Form
// Calculate vat percentage
$itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent());
$numberOfItems = (int) $item->getQtyOrdered();
$numberOfItems = (int)$item->getQtyOrdered();
$formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems);
......@@ -515,7 +514,7 @@ class Redirect extends \Magento\Payment\Block\Form
$itemVatAmount, $itemVatPercentage, $numberOfItems);
}
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for ".$formFields['merchantReference'];
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference'];
$formFields['openinvoicedata.numberOfLines'] = $count;
return $formFields;
......@@ -534,9 +533,10 @@ class Redirect extends \Magento\Payment\Block\Form
* @param $numberOfItems
*/
protected function setOpenInvoiceLineData($formFields, $count, $currencyCode, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems
) {
$linename = "line".$count;
$itemVatAmount, $itemVatPercentage, $numberOfItems
)
{
$linename = "line" . $count;
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode;
$formFields['openinvoicedata.' . $linename . '.description'] = $description;
$formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount;
......@@ -545,7 +545,8 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems;
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";
} else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
......
......@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Command;
use Magento\Payment\Gateway\Command;
use Magento\Payment\Gateway\CommandInterface;
class PayByMailCommand implements CommandInterface
{
......@@ -34,11 +35,6 @@ class PayByMailCommand implements CommandInterface
*/
protected $_adyenHelper;
/**
* @var ResolverInterface
*/
protected $_resolver;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
......@@ -53,11 +49,9 @@ class PayByMailCommand implements CommandInterface
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Locale\ResolverInterface $resolver,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->_adyenHelper = $adyenHelper;
$this->_resolver = $resolver;
$this->_adyenLogger = $adyenLogger;
}
/**
......@@ -134,6 +128,7 @@ class PayByMailCommand implements CommandInterface
$realOrderId = $order->getRealOrderId();
$orderCurrencyCode = $order->getOrderCurrencyCode();
$storeId = $order->getStore()->getId();
// check if paybymail has it's own skin
$skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code'));
......@@ -141,18 +136,20 @@ class PayByMailCommand implements CommandInterface
// use HPP skin and HMAC
$skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code');
$hmacKey = $this->_adyenHelper->getHmac();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale', $storeId));
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code', $storeId));
} else {
// use pay_by_mail skin and hmac
$hmacKey = $this->_adyenHelper->getHmacPayByMail();
}
$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();
$customerId = $order->getCustomerId();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale'));
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_resolver->getLocale();
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code'));
// get locale from store
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_adyenHelper->getStoreLocale($storeId);
$countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode
......@@ -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;
$formFields = [];
......@@ -184,9 +181,9 @@ class PayByMailCommand implements CommandInterface
$formFields['shopperEmail'] = $shopperEmail;
// 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 == "") {
$sessionValidity = 3;
......
......@@ -816,4 +816,9 @@ class Data extends AbstractHelper
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
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(
Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
......
......@@ -25,6 +25,7 @@ namespace Adyen\Payment\Model;
use Magento\Framework\Webapi\Exception;
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\AreaList;
use Magento\Framework\Phrase\Renderer\Placeholder;
......@@ -71,6 +72,11 @@ class Cron
*/
protected $_orderSender;
/**
* @var InvoiceSender
*/
protected $_invoiceSender;
/**
* @var \Magento\Framework\DB\TransactionFactory
*/
......@@ -180,6 +186,7 @@ class Cron
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param OrderSender $orderSender
* @param InvoiceSender $invoiceSender
* @param \Magento\Framework\DB\TransactionFactory $transactionFactory
* @param Billing\AgreementFactory $billingAgreementFactory
* @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
......@@ -195,6 +202,7 @@ class Cron
\Magento\Sales\Model\OrderFactory $orderFactory,
\Adyen\Payment\Helper\Data $adyenHelper,
OrderSender $orderSender,
InvoiceSender $invoiceSender,
\Magento\Framework\DB\TransactionFactory $transactionFactory,
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
......@@ -209,6 +217,7 @@ class Cron
$this->_orderFactory = $orderFactory;
$this->_adyenHelper = $adyenHelper;
$this->_orderSender = $orderSender;
$this->_invoiceSender = $invoiceSender;
$this->_transactionFactory = $transactionFactory;
$this->_billingAgreementFactory = $billingAgreementFactory;
$this->_billingAgreementCollectionFactory = $billingAgreementCollectionFactory;
......@@ -226,7 +235,7 @@ class Cron
{
// needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413
$renderer = Phrase::getRenderer();
if($renderer instanceof Placeholder) {
if ($renderer instanceof Placeholder) {
$this->_areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);
}
......@@ -247,9 +256,7 @@ class Cron
foreach ($notifications as $notification) {
// set Cron processing to true
$notification->setProcessing(true);
$notification->setUpdatedAt(new \DateTime());
$notification->save();
$this->_updateNotification($notification, true, false);
}
// loop over the notifications
......@@ -260,21 +267,29 @@ class Cron
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
* before processing so we are sure the 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 is a recurring_contract notification wait an extra 5 minutes
before processing this to make sure the contract exists"
);
// set processing back to false
$notification->setProcessing(false);
$notification->setUpdatedAt($dateEnd);
$notification->save();
$this->_updateNotification($notification, false, false);
continue;
}
......@@ -311,7 +326,8 @@ class Cron
*/
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT ||
$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');
......@@ -328,7 +344,8 @@ class Cron
* refund/cancelled as well so if it is a split payment that failed cancel the order as well
*/
if ($previousAdyenEventCode != "AUTHORISATION : TRUE" ||
$this->_eventCode == Notification::ORDER_CLOSED) {
$this->_eventCode == Notification::ORDER_CLOSED
) {
$this->_holdCancelOrder(false);
} else {
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
......@@ -349,12 +366,8 @@ class Cron
}
$this->_order->save();
// set done to true
$notification->setDone(true);
$notification->setProcessing(false);
$notification->setUpdatedAt(new \DateTime());
$notification->save();
$this->_updateNotification($notification, false, true);
$this->_adyenLogger->addAdyenNotificationCronjob(
sprintf("Notification %s is processed", $notification->getEntityId())
);
......@@ -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
*
......@@ -461,10 +503,10 @@ class Cron
// check if it is a full or partial refund
$amount = $this->_value;
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
$orderAmount = (int)$this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
$this->_adyenLogger->addAdyenNotificationCronjob(
'amount notification:'.$amount . ' amount order:'.$orderAmount
'amount notification:' . $amount . ' amount order:' . $orderAmount
);
if ($amount == $orderAmount) {
......@@ -487,7 +529,8 @@ class Cron
if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" ||
$this->_paymentMethod == "openinvoice" || $this->_paymentMethod == "ratepay"
) && ($this->_klarnaReservationNumber != null &&
$this->_klarnaReservationNumber != "")) {
$this->_klarnaReservationNumber != "")
) {
$klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
} else {
$klarnaReservationNumberText = "";
......@@ -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 ($this->_eventCode == Notification::MANUAL_REVIEW_ACCEPT
&& $this->_getFraudManualReviewAcceptStatus() != "") {
&& $this->_getFraudManualReviewAcceptStatus() != ""
) {
$manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus();
$this->_order->addStatusHistoryComment($comment, $manualReviewAcceptStatus);
$this->_adyenLogger->addAdyenNotificationCronjob('Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus);
......@@ -543,7 +587,8 @@ class Cron
if ($this->_eventCode == Notification::AUTHORISATION
|| $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
......@@ -551,7 +596,8 @@ class Cron
*/
if (strcmp($this->_success, 'false') == 0 ||
strcmp($this->_success, '0') == 0 ||
strcmp($this->_success, '') == 0) {
strcmp($this->_success, '') == 0
) {
$previousAdyenEventCode = $this->_order->getData('adyen_notification_event_code');
if ($previousAdyenEventCode != "AUTHORISATION : TRUE") {
......@@ -684,6 +730,7 @@ class Cron
*/
protected function _processNotification()
{
$this->_adyenLogger->addAdyenNotificationCronjob('Processing the notification');
$_paymentCode = $this->_paymentMethodCode();
......@@ -751,6 +798,13 @@ class Cron
$this->_authorizePayment();
}
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::CANCELLATION:
case Notification::CANCELLED:
......@@ -767,20 +821,23 @@ class Cron
}
} else {
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(
'Order is already cancelled or holded so do nothing'
);
} else if ($this->_order->canCancel() || $this->_order->canHold()) {
$this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order');
$this->_holdCancelOrder(true);
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('try to refund the order');
// refund
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
if ($this->_order->canCancel() || $this->_order->canHold()) {
$this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order');
$this->_holdCancelOrder(true);
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('try to refund the order');
// refund
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
}
}
}
break;
......@@ -793,7 +850,8 @@ class Cron
$customerReference = $this->_order->getCustomerId();
$listRecurringContracts = null;
$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 {
$listRecurringContracts = $this->_adyenPaymentRequest->getRecurringContractsForShopper(
......@@ -810,7 +868,8 @@ class Cron
foreach ($listRecurringContracts as $rc) {
$recurringReferencesList[] = $rc['recurringDetailReference'];
if (isset($rc['recurringDetailReference']) &&
$rc['recurringDetailReference'] == $recurringDetailReference) {
$rc['recurringDetailReference'] == $recurringDetailReference
) {
$contractDetail = $rc;
}
}
......@@ -860,8 +919,7 @@ class Cron
$billingAgreement->setStoreId($this->_order->getStoreId());
$billingAgreement->importOrderPayment($this->_order->getPayment());
$message = __('Created billing agreement #%1.', $recurringDetailReference);
}
else {
} else {
$this->_adyenLogger->addAdyenNotificationCronjob("Using existing Billing Agreement");
$billingAgreement->setIsObjectChanged(true);
$message = __('Updated billing agreement #%1.', $recurringDetailReference);
......@@ -881,7 +939,7 @@ class Cron
throw new \Exception($message);
}
} catch(\Exception $exception) {
} catch (\Exception $exception) {
$message = $exception->getMessage();
}
......@@ -917,7 +975,7 @@ class Cron
if ($orderPayment->getId() > 0) {
$currency = $this->_order->getOrderCurrencyCode();
$amountRefunded = $amountRefunded = $orderPayment->getTotalRefunded() +
$amountRefunded = $amountRefunded = $orderPayment->getTotalRefunded() +
$this->_adyenHelper->originalAmount($this->_value, $currency);
$orderPayment->setUpdatedAt(new \DateTime());
$orderPayment->setTotalRefunded($amountRefunded);
......@@ -1002,7 +1060,8 @@ class Cron
if (($this->_paymentMethod == "c_cash" &&
$this->_getConfigData('create_shipment', 'adyen_cash', $this->_order->getStoreId())) ||
($this->_getConfigData('create_shipment', 'adyen_pos', $this->_order->getStoreId()) &&
$_paymentCode == "adyen_pos")) {
$_paymentCode == "adyen_pos")
) {
$this->_createShipment();
}
......@@ -1018,7 +1077,7 @@ class Cron
try {
$this->_orderSender->send($this->_order);
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
} catch(\Exception $exception) {
} catch (\Exception $exception) {
$this->_adyenLogger->addAdyenNotificationCronjob(
"Exception in Send Mail in Magento. This is an issue in the the core of Magento" .
$exception->getMessage()
......@@ -1086,7 +1145,7 @@ class Cron
}
}
$createPendingInvoice = (bool) $this->_getConfigData(
$createPendingInvoice = (bool)$this->_getConfigData(
'create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId()
);
......@@ -1151,7 +1210,8 @@ class Cron
* There will be a capture send to indicate if payment is successful
*/
if (($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") &&
$sepaFlow == "authcap") {
$sepaFlow == "authcap"
) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'Manual Capture is applied for sepa because it is in authcap flow'
);
......@@ -1160,10 +1220,11 @@ class Cron
// payment method ideal, cash adyen_boleto or adyen_pos has direct capture
if ($_paymentCode == "adyen_pos" || (($_paymentCode == "adyen_sepa" ||
$this->_paymentMethod == "sepadirectdebit") && $sepaFlow != "authcap")) {
$this->_paymentMethod == "sepadirectdebit") && $sepaFlow != "authcap")
) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method does not allow manual capture.(2) paymentCode:' .
$_paymentCode . ' paymentMethod:' . $this->_paymentMethod . ' sepaFLow:'.$sepaFlow
$_paymentCode . ' paymentMethod:' . $this->_paymentMethod . ' sepaFLow:' . $sepaFlow
);
return true;
}
......@@ -1178,13 +1239,13 @@ class Cron
return true;
}
// if PayPal capture modues is different from the default use this one
if (strcmp($this->_paymentMethod, 'paypal' ) === 0 && $captureModePayPal != "") {
if (strcmp($captureModePayPal, 'auto') === 0 ) {
if (strcmp($this->_paymentMethod, 'paypal') === 0 && $captureModePayPal != "") {
if (strcmp($captureModePayPal, 'auto') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is paypal and configured to work as auto capture'
);
return true;
} elseif (strcmp($captureModePayPal, 'manual') === 0 ) {
} elseif (strcmp($captureModePayPal, 'manual') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'This payment method is paypal and configured to work as manual capture'
);
......@@ -1227,7 +1288,7 @@ class Cron
$manualCaptureAllowed = null;
$paymentMethod = $this->_paymentMethod;
switch($paymentMethod) {
switch ($paymentMethod) {
case 'cup':
case 'cartebancaire':
case 'visa':
......@@ -1304,7 +1365,7 @@ class Cron
);
// 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
$res = $this->_adyenOrderPaymentCollectionFactory
......@@ -1358,7 +1419,7 @@ class Cron
$autoCapture = $this->_isAutoCapture();
$createPendingInvoice = (bool) $this->_getConfigData(
$createPendingInvoice = (bool)$this->_getConfigData(
'create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId()
);
......@@ -1388,12 +1449,14 @@ class Cron
$this->_setPaymentAuthorized();
$invoiceAutoMail = (bool) $this->_getConfigData(
'send_invoice_update_mail', 'adyen_abstract', $this->_order->getStoreId()
$invoiceAutoMail = (bool)$this->_scopeConfig->isSetFlag(
\Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::XML_PATH_EMAIL_ENABLED,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$this->_order->getStoreId()
);
if ($invoiceAutoMail) {
$invoice->sendEmail();
$this->_invoiceSender->send($invoice);
}
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order');
......@@ -1412,16 +1475,16 @@ class Cron
// if full amount is captured create invoice
$currency = $this->_order->getOrderCurrencyCode();
$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
if ($createInvoice == true && $amount == $orderAmount) {
$this->_adyenLogger->addAdyenNotificationCronjob(
'amount notification:'.$amount . ' amount order:'.$orderAmount
'amount notification:' . $amount . ' amount order:' . $orderAmount
);
$this->_createInvoice();
}
$status = $this->_getConfigData(
'payment_authorized', 'adyen_abstract', $this->_order->getStoreId()
);
......@@ -1455,7 +1518,7 @@ class Cron
$paidAmount = floatval(trim($paidAmount));
if ($paidAmount > $orginalAmount) {
$overpaidStatus = $this->_getConfigData(
$overpaidStatus = $this->_getConfigData(
'order_overpaid_status', 'adyen_boleto', $this->_order->getStoreId()
);
// check if there is selected a status if not fall back to the default
......@@ -1535,4 +1598,4 @@ class Cron
$path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
\ No newline at end of file
}
......@@ -37,17 +37,18 @@ class Notification extends \Magento\Framework\Model\AbstractModel
const ERROR = 'ERROR';
const REFUND = 'REFUND';
const REFUND_FAILED = 'REFUND_FAILED';
const CANCEL_OR_REFUND = 'CANCEL_OR_REFUND';
const CANCEL_OR_REFUND = 'CANCEL_OR_REFUND';
const CAPTURE = 'CAPTURE';
const CAPTURE_FAILED = 'CAPTURE_FAILED';
const CANCELLATION = 'CANCELLATION';
const POSAPPROVED = 'POS_APPROVED';
const HANDLED_EXTERNALLY = 'HANDLED_EXTERNALLY';
const HANDLED_EXTERNALLY = 'HANDLED_EXTERNALLY';
const MANUAL_REVIEW_ACCEPT = 'MANUAL_REVIEW_ACCEPT';
const MANUAL_REVIEW_REJECT = 'MANUAL_REVIEW_REJECT ';
const RECURRING_CONTRACT = "RECURRING_CONTRACT";
const REPORT_AVAILABLE = "REPORT_AVAILABLE";
const ORDER_CLOSED = "ORDER_CLOSED";
const OFFER_CLOSED = "OFFER_CLOSED";
/**
* Notification constructor.
......@@ -85,11 +86,12 @@ class Notification extends \Magento\Framework\Model\AbstractModel
* @param $eventCode
* @param $success
* @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;
}
......@@ -147,7 +149,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel
{
return $this->setData(self::ORIGINAL_REFERENCE, $originalReference);
}
/**
* Gets the Merchantreference for the notification.
*
......@@ -314,7 +316,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel
{
return $this->setData(self::LIVE, $live);
}
/**
* Gets the AdditionalData for the notification.
*
......
......@@ -36,21 +36,30 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
/**
* Get Notification for duplicate check
*
*
* @param $pspReference
* @param $eventCode
* @param $success
* @param $originalReference
* @param null $done
* @return array
*/
public function getNotification($pspReference, $eventCode, $success, $originalReference)
public function getNotification($pspReference, $eventCode, $success, $originalReference, $done = null)
{
$select = $this->getConnection()->select()
->from(['notification' => $this->getTable('adyen_notification')])
->where('notification.pspreference=?', $pspReference)
->where('notification.event_code=?', $eventCode)
->where('notification.success=?', $success)
->where('notification.original_reference=?', $originalReference);
->where('notification.success=?', $success);
if ($done !== null) {
$select->where('notification.done=?', $done);
}
if ($originalReference) {
$select->where('notification.original_reference=?', $originalReference);
}
return $this->getConnection()->fetchAll($select);
}
}
\ No newline at end of file
......@@ -81,7 +81,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Model\Session $session
) {
)
{
$this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper;
$this->_request = $request;
......@@ -123,7 +124,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$gender = "";
$dob = "";
}
// add to config
$config['payment'] ['adyenHpp']['gender'] = $gender;
$config['payment'] ['adyenHpp']['dob'] = $dob;
......@@ -137,12 +138,12 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen;
$config['payment'] ['adyenHpp']['showGender'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_gender');
$config['payment'] ['adyenHpp']['showDob'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_dob');
$config['payment'] ['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag(
$config['payment'] ['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag(
'show_telephone'
);
$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;
}
......
......@@ -60,6 +60,8 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver
}
$paymentInfo = $this->readPaymentModelArgument($observer);
$paymentInfo->setCcType('boleto');
foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) {
......
......@@ -37,6 +37,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
const DOB = 'dob';
const TELEPHONE = 'telephone';
const DF_VALUE = 'df_value';
const SSN = 'ssn';
/**
......@@ -48,7 +49,8 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
self::GENDER,
self::DOB,
self::TELEPHONE,
self::DF_VALUE
self::DF_VALUE,
self::SSN
];
/**
......@@ -65,6 +67,10 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
}
$paymentInfo = $this->readPaymentModelArgument($observer);
if (isset($additionalData[self::BRAND_CODE])) {
$paymentInfo->setCcType($additionalData[self::BRAND_CODE]);
}
foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) {
......@@ -72,7 +78,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
$additionalInformationKey,
$additionalData[$additionalInformationKey]
);
}
}
}
}
}
......@@ -60,6 +60,8 @@ class AdyenSepaDataAssignObserver extends AbstractDataAssignObserver
}
$paymentInfo = $this->readPaymentModelArgument($observer);
$paymentInfo->setCcType('sepa');
foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) {
......
# 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 ##
```
bin/composer require adyen/module-payment
......
......@@ -2,13 +2,12 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "2.1.2",
"version": "2.1.3",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"adyen/php-api-library": "*"
},
"autoload": {
......
......@@ -192,12 +192,5 @@
<group>adyen</group>
</adyen_boleto>
</payment>
<dev>
<js>
<minify_exclude>
live.adyen.com/hpp/js/df
</minify_exclude>
</js>
</dev>
</default>
</config>
......@@ -24,7 +24,7 @@
-->
<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>
<module name="Magento_Sales"/>
<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 @@
/*global alert*/
var config = {
paths: {
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min',
'adyen/df' : 'https://live.adyen.com/hpp/js/df'
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min'
},
config: {
mixins: {
......
......@@ -35,10 +35,9 @@ define(
'Magento_Checkout/js/model/url-builder',
'Adyen_Payment/js/model/adyen-payment-service',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader',
'adyen/df'
'Magento_Checkout/js/model/full-screen-loader'
],
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';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
......@@ -74,7 +73,7 @@ define(
// retrieve payment methods
var serviceUrl,
payload;
if(customer.isLoggedIn()) {
if (customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/carts/mine/retrieve-adyen-payment-methods', {});
} else {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/retrieve-adyen-payment-methods', {
......@@ -91,75 +90,120 @@ define(
serviceUrl, JSON.stringify(payload)
).done(
function (response) {
function waitForDfSet() {
// Wait for dfSet function to be loaded from df.js script
if (typeof dfSet == "undefined") {
setTimeout(waitForDfSet, 500);
return;
}
// set device fingerprint value
dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work
dfValue($('#dfValue').val());
}
adyenPaymentService.setPaymentMethods(response);
if(JSON.stringify(response).indexOf("ratepay") > -1) {
if (JSON.stringify(response).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
window.di = {t: '', v: ratePayId, l: 'Checkout'};
function waitForDfValue() {
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();
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);
}
// set device fingerprint value
dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work
dfValue($('#dfValue').val());
// 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();
}
).fail(function(error) {
).fail(function (error) {
console.log(JSON.stringify(error));
fullScreenLoader.stopLoader();
});
},
getAdyenHppPaymentMethods: function() {
getAdyenHppPaymentMethods: function () {
var self = this;
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function(value) {
var paymentList = _.map(paymentMethods, function (value) {
var result = {};
result.value = value.brandCode;
result.name = value;
result.method = self.item.method;
result.getCode = function() {
result.getCode = function () {
return self.item.method;
};
result.validate = function () {
return self.validate();
}
if(value.brandCode == "ideal") {
};
result.isPaymentMethodOpenInvoiceMethod = function () {
return value.isPaymentMethodOpenInvoiceMethod;
};
result.getSsnLength = function () {
if (quote.billingAddress().countryId == "NO") {
//5 digits for Norway
return 5;
}
else {
//4 digits for other Nordic countries
return 4;
}
};
if (value.brandCode == "ideal") {
result.issuerIds = value.issuers;
result.issuerId = ko.observable(null);
} else if(value.isPaymentMethodOpenInvoiceMethod) {
} else if (value.isPaymentMethodOpenInvoiceMethod) {
result.telephone = ko.observable(quote.shippingAddress().telephone);
result.gender = ko.observable(window.checkoutConfig.payment.adyenHpp.gender);
result.dob = ko.observable(window.checkoutConfig.payment.adyenHpp.dob);
result.datepickerValue = ko.observable(); // needed ??
}
result.isPaymentMethodOpenInvoiceMethod = function() {
return value.isPaymentMethodOpenInvoiceMethod;
}
result.getRatePayDeviceIdentToken = function() {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
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;
}
}
}
return false;
};
}
return result;
});
return paymentList;
},
getGenderTypes: function() {
// return window.checkoutConfig.payment.adyenHpp.genderTypes;
return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function(value, key) {
getGenderTypes: function () {
return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function (value, key) {
return {
'key': key,
'value': value
......@@ -175,7 +219,7 @@ define(
return false;
}
},
continueToAdyenBrandCode: function() {
continueToAdyenBrandCode: function () {
// set payment method to adyen_hpp
var self = this;
......@@ -188,13 +232,14 @@ define(
additionalData.brand_code = self.value;
additionalData.df_value = dfValue();
if(brandCode() == "ideal") {
if (brandCode() == "ideal") {
additionalData.issuer_id = this.issuerId();
} else if(self.isPaymentMethodOpenInvoiceMethod()) {
} else if (self.isPaymentMethodOpenInvoiceMethod()) {
additionalData.gender = this.gender();
additionalData.dob = this.dob();
additionalData.telephone = this.telephone();
if(brandCode() == "ratepay"){
additionalData.ssn = this.ssn();
if (brandCode() == "ratepay") {
additionalData.df_value = this.getRatePayDeviceIdentToken();
}
}
......@@ -207,11 +252,11 @@ define(
return false;
},
selectPaymentMethodBrandCode: function() {
selectPaymentMethodBrandCode: function () {
var self = this;
// set payment method to adyen_hpp
var data = {
var data = {
"method": self.method,
"po_number": null,
"additional_data": {
......@@ -232,34 +277,25 @@ define(
},
isBrandCodeChecked: ko.computed(function () {
if(!quote.paymentMethod()) {
if (!quote.paymentMethod()) {
return null;
}
if(quote.paymentMethod().method == paymentMethod()) {
if (quote.paymentMethod().method == paymentMethod()) {
return brandCode();
}
return null;
}),
isPaymentMethodSelectionOnAdyen: function() {
isPaymentMethodSelectionOnAdyen: function () {
return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen;
},
isIconEnabled: function() {
isIconEnabled: function () {
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 () {
return true;
},
getRatePayDeviceIdentToken: function(){
getRatePayDeviceIdentToken: function () {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
}
});
......
......@@ -70,7 +70,7 @@
<!-- ko if: isPaymentMethodOpenInvoiceMethod() -->
<!-- ko if: $parent.showGender() -->
<!-- ko if: showGender() -->
<div class="field gender_type type required">
<label data-bind="attr: {for: getCode() + '_gender_type'}" class="label">
<span><!-- ko text: $t('Gender')--><!-- /ko --></span>
......@@ -90,7 +90,7 @@
</div>
<!--/ko-->
<!-- ko if: $parent.showDob() -->
<!-- ko if: showDob() -->
<div class="field required">
<label data-bind="attr: {for: getCode() + '_dob'}" class="label">
<span><!-- ko text: $t('Date of Birth')--><!-- /ko --></span>
......@@ -111,7 +111,7 @@
</div>
<!--/ko-->
<!-- ko if: $parent.showTelephone() -->
<!-- ko if: showTelephone() -->
<div class="field required">
<label data-bind="attr: {for: getCode() + '_telephone'}" class="label">
<span><!-- ko text: $t('Telephone')--><!-- /ko --></span>
......@@ -131,6 +131,29 @@
</div>
</div>
<!--/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-->
</fieldset>
<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