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 a1f07421 authored by Giorgos Adam's avatar Giorgos Adam Committed by GitHub

Merge pull request #161 from Adyen/develop

Release 2.1.0
parents 1201e022 3ff4c38b
...@@ -26,4 +26,8 @@ namespace Adyen\Payment\Block\Info; ...@@ -26,4 +26,8 @@ namespace Adyen\Payment\Block\Info;
class Oneclick extends Cc class Oneclick extends Cc
{ {
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_oneclick.phtml';
} }
...@@ -58,6 +58,13 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -58,6 +58,13 @@ class Redirect extends \Magento\Payment\Block\Form
*/ */
protected $_adyenLogger; protected $_adyenLogger;
/**
* @var \Magento\Tax\Model\Config
*/
protected $_taxConfig;
protected $_taxCalculation;
/** /**
* Redirect constructor. * Redirect constructor.
* *
...@@ -74,7 +81,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -74,7 +81,9 @@ class Redirect extends \Magento\Payment\Block\Form
\Magento\Checkout\Model\Session $checkoutSession, \Magento\Checkout\Model\Session $checkoutSession,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Locale\ResolverInterface $resolver, \Magento\Framework\Locale\ResolverInterface $resolver,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Model\Calculation $taxCalculation
) { ) {
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession; $this->_checkoutSession = $checkoutSession;
...@@ -88,6 +97,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -88,6 +97,8 @@ class Redirect extends \Magento\Payment\Block\Form
$incrementId = $this->_getCheckout()->getLastRealOrderId(); $incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId); $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
} }
$this->_taxConfig = $taxConfig;
$this->_taxCalculation = $taxCalculation;
} }
...@@ -221,7 +232,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -221,7 +232,9 @@ class Redirect extends \Magento\Payment\Block\Form
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData( $recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData(
'recurring_type') 'recurring_type')
); );
$brandCode = $this->_order->getPayment()->getAdditionalInformation("brand_code"); $brandCode = $this->_order->getPayment()->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
// Paypal does not allow ONECLICK,RECURRING only RECURRING // Paypal does not allow ONECLICK,RECURRING only RECURRING
if ($brandCode == "paypal" && $recurringType == 'ONECLICK,RECURRING') { if ($brandCode == "paypal" && $recurringType == 'ONECLICK,RECURRING') {
...@@ -231,6 +244,10 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -231,6 +244,10 @@ class Redirect extends \Magento\Payment\Block\Form
if ($customerId > 0) { if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType; $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;
} }
//blocked methods //blocked methods
...@@ -266,19 +283,25 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -266,19 +283,25 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['shopper.dateOfBirthYear'] = trim($this->_getDate($dob, 'Y')); $formFields['shopper.dateOfBirthYear'] = trim($this->_getDate($dob, 'Y'));
} }
if ($this->_order->getPayment()->getAdditionalInformation( // For klarna acceptPrivacyPolicy to skip HPP page
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna" if ($brandCode == "klarna") {
) {
// // needed for DE and AT // // 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 // don't allow editable shipping/delivery address
$formFields['billingAddressType'] = "1"; $formFields['billingAddressType'] = "1";
$formFields['deliveryAddressType'] = "1"; $formFields['deliveryAddressType'] = "1";
// make setting to make this optional // make setting to make this optional
$adyFields['shopperType'] = "1"; $formFields['shopperType'] = "1";
}
if ($this->_order->getPayment()->getAdditionalInformation("df_value") != "") {
$formFields['dfValue'] = $this->_order->getPayment()->getAdditionalInformation("df_value");
} }
// Sort the array by key using SORT_STRING order // Sort the array by key using SORT_STRING order
...@@ -298,6 +321,10 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -298,6 +321,10 @@ class Redirect extends \Magento\Payment\Block\Form
} 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;
} }
...@@ -422,15 +449,11 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -422,15 +449,11 @@ class Redirect extends \Magento\Payment\Block\Form
foreach ($this->_order->getAllVisibleItems() as $item) { foreach ($this->_order->getAllVisibleItems() as $item) {
++$count; ++$count;
$linename = "line".$count;
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currency;
$formFields['openinvoicedata.' . $linename . '.description'] =
str_replace("\n", '', trim($item->getName()));
$formFields['openinvoicedata.' . $linename . '.itemAmount'] =
$this->_adyenHelper->formatAmount($item->getPrice(), $currency);
$formFields['openinvoicedata.' . $linename . '.itemVatAmount'] = $description = str_replace("\n", '', trim($item->getName()));
$itemAmount = $this->_adyenHelper->formatAmount($item->getPrice(), $currency);
$itemVatAmount =
($item->getTaxAmount() > 0 && $item->getPriceInclTax() > 0) ? ($item->getTaxAmount() > 0 && $item->getPriceInclTax() > 0) ?
$this->_adyenHelper->formatAmount( $this->_adyenHelper->formatAmount(
$item->getPriceInclTax(), $item->getPriceInclTax(),
...@@ -440,23 +463,56 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -440,23 +463,56 @@ class Redirect extends \Magento\Payment\Block\Form
$currency $currency
) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency); ) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency);
// Calculate vat percentage // Calculate vat percentage
$percentageMinorUnits = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent()); $itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent());
$formFields['openinvoicedata.' . $linename . '.itemVatPercentage'] = $percentageMinorUnits;
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = (int) $item->getQtyOrdered();
if ($this->_order->getPayment()->getAdditionalInformation( $numberOfItems = (int) $item->getQtyOrdered();
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna"
) { $formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High"; $itemVatAmount, $itemVatPercentage, $numberOfItems);
} else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
} }
if ($item->getSku() != "") {
$formFields['openinvoicedata.' . $linename . '.itemId'] = $item->getSku(); // Discount cost
if ($this->_order->getDiscountAmount() > 0 || $this->_order->getDiscountAmount() < 0) {
++$count;
$description = __('Total Discount');
$itemAmount = $this->_adyenHelper->formatAmount($this->_order->getDiscountAmount(), $currency);
$itemVatAmount = "0";
$itemVatPercentage = "0";
$numberOfItems = 1;
$formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems);
} }
// Shipping cost
if ($this->_order->getShippingAmount() > 0 || $this->_order->getShippingTaxAmount() > 0) {
++$count;
$description = $this->_order->getShippingDescription();
$itemAmount = $this->_adyenHelper->formatAmount($this->_order->getShippingAmount(), $currency);
$itemVatAmount = $this->_adyenHelper->formatAmount($this->_order->getShippingTaxAmount(), $currency);
// Create RateRequest to calculate the Tax class rate for the shipping method
$rateRequest = $this->_taxCalculation->getRateRequest(
$this->_order->getShippingAddress(),
$this->_order->getBillingAddress(),
null,
$this->_order->getStoreId(), $this->_order->getCustomerId()
);
$taxClassId = $this->_taxConfig->getShippingTaxClass($this->_order->getStoreId());
$rateRequest->setProductClassId($taxClassId);
$rate = $this->_taxCalculation->getRate($rateRequest);
$itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($rate);
$numberOfItems = 1;
$formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems);
} }
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for ".$formFields['merchantReference']; $formFields['openinvoicedata.refundDescription'] = "Refund / Correction for ".$formFields['merchantReference'];
...@@ -465,6 +521,38 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -465,6 +521,38 @@ class Redirect extends \Magento\Payment\Block\Form
return $formFields; return $formFields;
} }
/**
* Set the openinvoice line
*
* @param $count
* @param $currencyCode
* @param $description
* @param $itemAmount
* @param $itemVatAmount
* @param $itemVatPercentage
* @param $numberOfItems
*/
protected function setOpenInvoiceLineData($formFields, $count, $currencyCode, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems
) {
$linename = "line".$count;
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode;
$formFields['openinvoicedata.' . $linename . '.description'] = $description;
$formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount;
$formFields['openinvoicedata.' . $linename . '.itemVatAmount'] = $itemVatAmount;
$formFields['openinvoicedata.' . $linename . '.itemVatPercentage'] = $itemVatPercentage;
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems;
if ($this->_adyenHelper->isVatCategoryHigh($this->_order->getPayment()->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE))) {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
} else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
}
return $formFields;
}
/** /**
* @param $genderId * @param $genderId
* @return string * @return string
......
...@@ -97,7 +97,7 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -97,7 +97,7 @@ class Result extends \Magento\Framework\App\Action\Action
if ($result) { if ($result) {
$session = $this->_session; $session = $this->_session;
$session->getQuote()->setIsActive(false)->save(); $session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success', ['utm_nooverride' => '1']); $this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
} else { } else {
$this->_cancel($response); $this->_cancel($response);
$this->_redirect('checkout/cart'); $this->_redirect('checkout/cart');
......
...@@ -95,7 +95,7 @@ class ResultPos extends \Magento\Framework\App\Action\Action ...@@ -95,7 +95,7 @@ class ResultPos extends \Magento\Framework\App\Action\Action
if ($result) { if ($result) {
$session = $this->_session; $session = $this->_session;
$session->getQuote()->setIsActive(false)->save(); $session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success', ['utm_nooverride' => '1']); $this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
} else { } else {
$this->_cancel($response); $this->_cancel($response);
$this->_redirect('checkout/cart'); $this->_redirect('checkout/cart');
......
...@@ -133,7 +133,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -133,7 +133,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$order->getPayment()->setAdditionalInformation('3dActive', ''); $order->getPayment()->setAdditionalInformation('3dActive', '');
$this->_orderRepository->save($order); $this->_orderRepository->save($order);
$this->_redirect('checkout/onepage/success', ['utm_nooverride' => '1']); $this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
} else { } else {
$order->addStatusHistoryComment(__('3D-secure validation was unsuccessful.'))->save(); $order->addStatusHistoryComment(__('3D-secure validation was unsuccessful.'))->save();
...@@ -162,7 +162,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -162,7 +162,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$this->_view->renderLayout(); $this->_view->renderLayout();
} }
} else { } else {
$this->_redirect('checkout/onepage/success/', ['utm_nooverride' => '1']); $this->_redirect('checkout/onepage/success', ['_query' => ['utm_nooverride' => '1']]);
} }
} }
......
...@@ -88,7 +88,7 @@ class TransactionCancel implements ClientInterface ...@@ -88,7 +88,7 @@ class TransactionCancel implements ClientInterface
$service = new \Adyen\Service\Modification($this->_client); $service = new \Adyen\Service\Modification($this->_client);
try { try {
$response = $service->cancelOrRefund($request); $response = $service->cancel($request);
} catch(\Adyen\AdyenException $e) { } catch(\Adyen\AdyenException $e) {
$response = null; $response = null;
} }
......
...@@ -86,11 +86,26 @@ class SepaValidator extends AbstractValidator ...@@ -86,11 +86,26 @@ class SepaValidator extends AbstractValidator
$newString .= $movedCharArray[$key]; $newString .= $movedCharArray[$key];
} }
if (bcmod($newString, '97') == 1) { if (function_exists("bcmod")) {
return true; return bcmod($newString, '97') == 1;
} else {
return false;
} }
/**
* if server does not support bcmoc then do this manually:
* http://au2.php.net/manual/en/function.bcmod.php#38474
*/
$x = $newString;
$y = "97";
$take = 5;
$mod = "";
do {
$a = (int)$mod . substr($x, 0, $take);
$x = substr($x, $take);
$mod = $a % $y;
} while (strlen($x));
return (int)$mod == 1;
} else { } else {
return false; return false;
} }
......
...@@ -770,6 +770,22 @@ class Data extends AbstractHelper ...@@ -770,6 +770,22 @@ class Data extends AbstractHelper
} }
} }
/**
* For Klarna And AfterPay use VatCategory High others use none
*
* @param $paymentMethod
* @return bool
*/
public function isVatCategoryHigh($paymentMethod)
{
if ($paymentMethod == "klarna" ||
strlen($paymentMethod) >= 9 && substr($paymentMethod, 0, 9) == 'afterpay_'
) {
return true;
}
return false;
}
/** /**
* @return bool * @return bool
*/ */
......
...@@ -80,6 +80,16 @@ class PaymentMethods extends AbstractHelper ...@@ -80,6 +80,16 @@ class PaymentMethods extends AbstractHelper
*/ */
protected $_assetSource; protected $_assetSource;
/**
* @var \Magento\Framework\View\DesignInterface
*/
protected $_design;
/**
* @var \Magento\Framework\View\Design\Theme\ThemeProviderInterface
*/
protected $_themeProvider;
/** /**
* PaymentMethods constructor. * PaymentMethods constructor.
* *
...@@ -93,6 +103,8 @@ class PaymentMethods extends AbstractHelper ...@@ -93,6 +103,8 @@ class PaymentMethods extends AbstractHelper
* @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\View\Asset\Source $assetSource * @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Framework\View\DesignInterface $design
* @param \Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider
*/ */
public function __construct( public function __construct(
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
...@@ -104,7 +116,9 @@ class PaymentMethods extends AbstractHelper ...@@ -104,7 +116,9 @@ class PaymentMethods extends AbstractHelper
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\RequestInterface $request,
\Magento\Framework\View\Asset\Source $assetSource \Magento\Framework\View\Asset\Source $assetSource,
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider
) { ) {
$this->_quoteRepository = $quoteRepository; $this->_quoteRepository = $quoteRepository;
$this->_quoteIdMaskFactory = $quoteIdMaskFactory; $this->_quoteIdMaskFactory = $quoteIdMaskFactory;
...@@ -116,7 +130,8 @@ class PaymentMethods extends AbstractHelper ...@@ -116,7 +130,8 @@ class PaymentMethods extends AbstractHelper
$this->_assetRepo = $assetRepo; $this->_assetRepo = $assetRepo;
$this->_request = $request; $this->_request = $request;
$this->_assetSource = $assetSource; $this->_assetSource = $assetSource;
$this->_design = $design;
$this->_themeProvider = $themeProvider;
} }
/** /**
...@@ -208,11 +223,24 @@ class PaymentMethods extends AbstractHelper ...@@ -208,11 +223,24 @@ class PaymentMethods extends AbstractHelper
// add icon location in result // add icon location in result
if ($this->_adyenHelper->showLogos()) { if ($this->_adyenHelper->showLogos()) {
// Fix for MAGETWO-70402 https://github.com/magento/magento2/pull/7686
// Explicitly setting theme
$themeCode = "Magento/blank";
$themeId = $this->_design->getConfigurationDesignTheme(\Magento\Framework\App\Area::AREA_FRONTEND);
if(!empty($themeId)) {
$theme = $this->_themeProvider->getThemeById($themeId);
if($theme && !empty($theme->getCode())) {
$themeCode = $theme->getCode();
}
}
$params = []; $params = [];
// use frontend area $params = array_merge([
$params = array_merge(['area' => 'frontend', '_secure' => $this->_request->isSecure()], $params); 'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'_secure' => $this->_request->isSecure(),
'theme' => $themeCode
], $params);
$asset = $this->_assetRepo->createAsset('Adyen_Payment::images/logos/' . $asset = $this->_assetRepo->createAsset('Adyen_Payment::images/logos/' .
$paymentMethodCode . '.png', $params); $paymentMethodCode . '.png', $params);
......
...@@ -56,7 +56,7 @@ class CcType extends \Magento\Payment\Model\Source\Cctype ...@@ -56,7 +56,7 @@ class CcType extends \Magento\Payment\Model\Source\Cctype
*/ */
public function getAllowedTypes() public function getAllowedTypes()
{ {
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'OT', 'MI']; return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN'];
} }
/** /**
......
...@@ -25,6 +25,10 @@ namespace Adyen\Payment\Model; ...@@ -25,6 +25,10 @@ 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\Framework\App\Area;
use Magento\Framework\App\AreaList;
use Magento\Framework\Phrase\Renderer\Placeholder;
use Magento\Framework\Phrase;
class Cron class Cron
{ {
...@@ -162,6 +166,11 @@ class Cron ...@@ -162,6 +166,11 @@ class Cron
*/ */
protected $_adyenOrderPaymentCollectionFactory; protected $_adyenOrderPaymentCollectionFactory;
/**
* @var AreaList
*/
protected $_areaList;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -177,6 +186,7 @@ class Cron ...@@ -177,6 +186,7 @@ class Cron
* @param Api\PaymentRequest $paymentRequest * @param Api\PaymentRequest $paymentRequest
* @param Order\PaymentFactory $adyenOrderPaymentFactory * @param Order\PaymentFactory $adyenOrderPaymentFactory
* @param Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory * @param Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param AreaList $areaList
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
...@@ -190,7 +200,8 @@ class Cron ...@@ -190,7 +200,8 @@ class Cron
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory, \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest, \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory, \Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
AreaList $areaList
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
...@@ -204,6 +215,7 @@ class Cron ...@@ -204,6 +215,7 @@ class Cron
$this->_adyenPaymentRequest = $paymentRequest; $this->_adyenPaymentRequest = $paymentRequest;
$this->_adyenOrderPaymentFactory = $adyenOrderPaymentFactory; $this->_adyenOrderPaymentFactory = $adyenOrderPaymentFactory;
$this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory; $this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory;
$this->_areaList = $areaList;
} }
/** /**
...@@ -212,6 +224,12 @@ class Cron ...@@ -212,6 +224,12 @@ class Cron
*/ */
public function processNotification() public function processNotification()
{ {
// needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413
$renderer = Phrase::getRenderer();
if($renderer instanceof Placeholder) {
$this->_areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);
}
$this->_order = null; $this->_order = null;
// execute notifications from 2 minute or earlier because order could not yet been created by magento // execute notifications from 2 minute or earlier because order could not yet been created by magento
...@@ -224,8 +242,16 @@ class Cron ...@@ -224,8 +242,16 @@ class Cron
// create collection // create collection
$notifications = $this->_notificationFactory->create(); $notifications = $this->_notificationFactory->create();
$notifications->addFieldToFilter('done', 0); $notifications->addFieldToFilter('done', 0);
$notifications->addFieldToFilter('processing', 0);
$notifications->addFieldToFilter('created_at', $dateRange); $notifications->addFieldToFilter('created_at', $dateRange);
foreach ($notifications as $notification) {
// set Cron processing to true
$notification->setProcessing(true);
$notification->setUpdatedAt(new \DateTime());
$notification->save();
}
// loop over the notifications // loop over the notifications
$count = 0; $count = 0;
foreach ($notifications as $notification) { foreach ($notifications as $notification) {
...@@ -244,6 +270,11 @@ class Cron ...@@ -244,6 +270,11 @@ class Cron
"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
$notification->setProcessing(false);
$notification->setUpdatedAt($dateEnd);
$notification->save();
continue; continue;
} }
...@@ -320,9 +351,9 @@ class Cron ...@@ -320,9 +351,9 @@ class Cron
$this->_order->save(); $this->_order->save();
// set done to true // set done to true
$dateEnd = new \DateTime();
$notification->setDone(true); $notification->setDone(true);
$notification->setUpdatedAt($dateEnd); $notification->setProcessing(false);
$notification->setUpdatedAt(new \DateTime());
$notification->save(); $notification->save();
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
sprintf("Notification %s is processed", $notification->getEntityId()) sprintf("Notification %s is processed", $notification->getEntityId())
......
...@@ -36,6 +36,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver ...@@ -36,6 +36,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
const GENDER = 'gender'; const GENDER = 'gender';
const DOB = 'dob'; const DOB = 'dob';
const TELEPHONE = 'telephone'; const TELEPHONE = 'telephone';
const DF_VALUE = 'df_value';
/** /**
...@@ -46,7 +47,8 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver ...@@ -46,7 +47,8 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
self::ISSUER_ID, self::ISSUER_ID,
self::GENDER, self::GENDER,
self::DOB, self::DOB,
self::TELEPHONE self::TELEPHONE,
self::DF_VALUE
]; ];
/** /**
......
...@@ -59,6 +59,10 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -59,6 +59,10 @@ class UpgradeSchema implements UpgradeSchemaInterface
$this->updateSchemaVersion204($setup); $this->updateSchemaVersion204($setup);
} }
if (version_compare($context->getVersion(), '2.0.7', '<')) {
$this->updateSchemaVersion207($setup);
}
$setup->endSetup(); $setup->endSetup();
} }
...@@ -262,4 +266,32 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -262,4 +266,32 @@ class UpgradeSchema implements UpgradeSchemaInterface
] ]
); );
} }
/**
* Upgrade to 2.0.7
*
* @param SchemaSetupInterface $setup
* @return void
*/
public function updateSchemaVersion207(SchemaSetupInterface $setup)
{
$connection = $setup->getConnection();
$tableName = $setup->getTable('adyen_notification');
$adyenNotificationProcessingColumn = [
'type' => Table::TYPE_BOOLEAN,
'length' => 1,
'nullable' => true,
'default' => 0,
'comment' => 'Adyen Notification Cron Processing',
'after' => \Adyen\Payment\Model\Notification::DONE
];
$connection->addColumn(
$tableName,
'processing',
$adyenNotificationProcessingColumn
);
}
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "2.0.6", "version": "2.1.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -45,13 +45,13 @@ ...@@ -45,13 +45,13 @@
</field> </field>
<field id="hmac_test" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="hmac_test" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>HMAC Key for Test</label> <label>HMAC Key for Test</label>
<tooltip>Copy and paste the HMAC key of the skin you want to use from Test Customer Area => Skins. => click on [skin code] => Edit => HMAC for Test platform. Currently, only the older SHA-1 HMAC calculation method is supported in this plugin.</tooltip> <tooltip>Copy and paste the HMAC key of the skin you want to use from Test Customer Area => Skins. => click on [skin code] => Edit => HMAC for Test platform.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_hpp/hmac_test</config_path> <config_path>payment/adyen_hpp/hmac_test</config_path>
</field> </field>
<field id="hmac_live" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="hmac_live" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>HMAC Key for Live</label> <label>HMAC Key for Live</label>
<tooltip>Copy and paste the HMAC key of the skin you want to use from Test Customer Area => Skins. => click on [skin code] => Edit => HMAC for Live platform. Currently, only the older SHA-1 HMAC calculation method is supported in this plugin.</tooltip> <tooltip>Copy and paste the HMAC key of the skin you want to use from Test Customer Area => Skins. => click on [skin code] => Edit => HMAC for Live platform.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_hpp/hmac_live</config_path> <config_path>payment/adyen_hpp/hmac_live</config_path>
</field> </field>
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
--> -->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd"> <include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_oneclick" translate="label" type="text" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1"> <group id="adyen_oneclick" translate="label" type="text" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[OneClick - Requires Adyen Credit Card]]></label> <label><![CDATA[Stored Payment Methods - Requires Adyen Credit Card]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css> <fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment><![CDATA[During checkout shoppers can choose to have their payment details remembered and stored for trusted websites in Adyen’s highly secure platform. Adyen takes care of this process for its customers. Shoppers can then select in the Magento checkout the saved card and checkout with ‘OneClick’.]]></comment> <comment><![CDATA[During checkout shoppers can choose to have their payment details remembered and stored for trusted websites in Adyen’s highly secure platform. Adyen takes care of this process for its customers. Shoppers can then select the stored payment method in the checkout.]]></comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label> <label>Enabled</label>
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<adyen_oneclick> <adyen_oneclick>
<active>1</active> <active>1</active>
<model>AdyenPaymentOneclickFacade</model> <model>AdyenPaymentOneclickFacade</model>
<title>Adyen OneClick</title> <title>Adyen Stored Payment Methods</title>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>1</sort_order> <sort_order>1</sort_order>
<cctypes>AE,VI,MC,DI</cctypes> <!-- important to show the payment method isAvailabe()--> <cctypes>AE,VI,MC,DI</cctypes> <!-- important to show the payment method isAvailabe()-->
......
...@@ -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.0.6"> <module name="Adyen_Payment" setup_version="2.1.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -40,7 +40,7 @@ $currentCountry = $block->getInfoData('country'); ...@@ -40,7 +40,7 @@ $currentCountry = $block->getInfoData('country');
<?php foreach($block->getOneClickCards() as $card): ?> <?php foreach($block->getOneClickCards() as $card): ?>
<?php if($card['agreement_label'] != ""):?> <?php if($card['agreement_label'] != ""):?>
<dt class="admin__field-option"> <dt class="admin__field-option">
<input id="p_method_adyen_oneclick_<?php echo $card['reference_id']?>" value="<?php echo $card['reference_id']; ?>" type="radio" name="payment[recurring_detail_reference]" title="Adyen OneClick" onclick="document.getElementById('adyen_oneclick_variant').value = '<?php echo $card['agreement_data']['variant']; ?>';" class="admin__control-radio"> <input id="p_method_adyen_oneclick_<?php echo $card['reference_id']?>" value="<?php echo $card['reference_id']; ?>" type="radio" name="payment[recurring_detail_reference]" title="Adyen Stored Payment Methods" onclick="document.getElementById('adyen_oneclick_variant').value = '<?php echo $card['agreement_data']['variant']; ?>';" class="admin__control-radio">
<label class="admin__field-label" for="p_method_adyen_oneclick_<?php echo $card['reference_id']?>"><?php echo $card['agreement_label']; ?></label> <label class="admin__field-label" for="p_method_adyen_oneclick_<?php echo $card['reference_id']?>"><?php echo $card['agreement_label']; ?></label>
</dt> </dt>
<?php endif; ?> <?php endif; ?>
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
/*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: {
......
...@@ -36,7 +36,9 @@ $_info = $this->getInfo(); ...@@ -36,7 +36,9 @@ $_info = $this->getInfo();
<dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt> <dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt>
<?php else: ?> <?php else: ?>
<?php if ($_brandCode = $_info->getAdditionalInformation('brand_code')):?> <?php if ($_methodTitle = $_info->getAdditionalInformation('method_title')):?>
<dt class="title"><?php echo $_methodTitle; ?></dt>
<?php elseif ($_brandCode = $_info->getAdditionalInformation('brand_code')):?>
<dt class="title"><?php echo $_brandCode; ?></dt> <dt class="title"><?php echo $_brandCode; ?></dt>
<?php endif;?> <?php endif;?>
......
...@@ -35,12 +35,14 @@ define( ...@@ -35,12 +35,14 @@ 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) { function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, deviceFingerprint) {
'use strict'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
var dfValue = ko.observable(null);
return Component.extend({ return Component.extend({
self: this, self: this,
...@@ -55,7 +57,8 @@ define( ...@@ -55,7 +57,8 @@ define(
'issuerId', 'issuerId',
'gender', 'gender',
'dob', 'dob',
'telephone' 'telephone',
'dfValue'
]); ]);
return this; return this;
}, },
...@@ -89,6 +92,12 @@ define( ...@@ -89,6 +92,12 @@ define(
).done( ).done(
function (response) { function (response) {
adyenPaymentService.setPaymentMethods(response); adyenPaymentService.setPaymentMethods(response);
// set device fingerprint value
dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work
dfValue($('#dfValue').val());
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
} }
).fail(function(error) { ).fail(function(error) {
...@@ -114,7 +123,6 @@ define( ...@@ -114,7 +123,6 @@ define(
return self.validate(); return self.validate();
} }
if(value.brandCode == "ideal") { if(value.brandCode == "ideal") {
result.issuerIds = value.issuers; result.issuerIds = value.issuers;
result.issuerId = ko.observable(null); result.issuerId = ko.observable(null);
...@@ -155,17 +163,16 @@ define( ...@@ -155,17 +163,16 @@ define(
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
var data = {}; var data = {};
data.method = self.method; data.method = self.method;
data.po_number = null;
var additionalData = {}; var additionalData = {};
additionalData.brand_code = self.value; additionalData.brand_code = self.value;
additionalData.df_value = dfValue();
if(brandCode() == "ideal") { if(brandCode() == "ideal") {
additionalData.issuer_id = this.issuerId(); additionalData.issuer_id = this.issuerId();
} else if(brandCode() == "klarna") { } 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();
...@@ -187,7 +194,7 @@ define( ...@@ -187,7 +194,7 @@ define(
"method": self.method, "method": self.method,
"po_number": null, "po_number": null,
"additional_data": { "additional_data": {
brand_code: self.value, brand_code: self.value
} }
}; };
......
...@@ -80,6 +80,16 @@ define( ...@@ -80,6 +80,16 @@ define(
event.preventDefault(); event.preventDefault();
} }
var data = {
"method": self.method,
"additional_data": {
variant: self.agreement_data.variant,
recurring_detail_reference: self.value
}
}
// only use CSE and installments for cards
if (self.agreement_data.card) {
var cse_key = this.getCSEKey(); var cse_key = this.getCSEKey();
var options = { enableValidations: false}; var options = { enableValidations: false};
...@@ -96,16 +106,9 @@ define( ...@@ -96,16 +106,9 @@ define(
var encryptedData = cseInstance.encrypt(cardData); var encryptedData = cseInstance.encrypt(cardData);
// set payment method to adyen_hpp // set payment method to adyen_hpp
var data = { data.additional_data.encrypted_data = encryptedData;
"method": self.method, data.additional_data.number_of_installments = self.installment;
"po_number": null,
"additional_data": {
encrypted_data: encryptedData,
recurring_detail_reference: self.value,
variant: self.agreement_data.variant,
number_of_installments: self.installment
} }
};
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
//this.isPlaceOrderActionAllowed(false); //this.isPlaceOrderActionAllowed(false);
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
<input type="text" class="input-text" <input type="text" class="input-text"
name="payment[dob]" name="payment[dob]"
data-bind=" data-bind="
datepicker: { storage: datepickerValue, options: { showOn: 'both' } }, datepicker: { storage: datepickerValue, options: { showOn: 'both', changeYear: true, yearRange: '-99:-1', defaultDate: '-20y' } },
attr: { attr: {
title: $t('Date of Birth'), title: $t('Date of Birth'),
'data-container': getCode() + '-dob', 'data-container': getCode() + '-dob',
...@@ -153,6 +153,11 @@ ...@@ -153,6 +153,11 @@
<!--/ko--> <!--/ko-->
<!--/ko--> <!--/ko-->
<input type="hidden" name="payment[dfValue]" data-bind="attr: { id: 'dfValue', value: dfValue }" />
<!-- ko if: (isPaymentMethodSelectionOnAdyen()) --> <!-- ko if: (isPaymentMethodSelectionOnAdyen()) -->
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}"> <div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
......
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