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

Merge pull request #281 from Adyen/develop

Merge for new release 2.3.0
parents 787f9f5f 4495500d
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
**Tested scenarios** **Tested scenarios**
<!-- Description of tested scenarios --> <!-- Description of tested scenarios -->
<!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c ." --> <!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/adyen/module-payment/Test/" -->
**Fixed issue**: <!-- #-prefixed issue number --> **Fixed issue**: <!-- #-prefixed issue number -->
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\AdminMessage;
class VersionMessage implements \Magento\Framework\Notification\MessageInterface
{
protected $_authSession;
protected $_adyenHelper;
protected $_inboxFactory;
public function __construct(
\Magento\Backend\Model\Auth\Session $authSession,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\AdminNotification\Model\InboxFactory $inboxFactory
) {
$this->_authSession = $authSession;
$this->_adyenHelper = $adyenHelper;
$this->_inboxFactory = $inboxFactory;
}
/**
* Message identity
*/
const MESSAGE_IDENTITY = 'Adyen Version Control message';
/**
* Retrieve unique system message identity
*
* @return string
*/
public function getIdentity()
{
return self::MESSAGE_IDENTITY;
}
/**
* Check whether the system message should be shown
*
* @return bool
*/
public function isDisplayed()
{
// Only execute the query the first time you access the Admin page
if ($this->_authSession->isFirstPageAfterLogin()) {
try {
$githubContent = $this->getDecodedContentFromGithub();
$this->setSessionData("AdyenGithubVersion", $githubContent);
$title = "Adyen extension version " . $githubContent['tag_name'] . " available!";
$versionData[] = array(
'severity' => self::SEVERITY_NOTICE,
'date_added' => $githubContent['published_at'],
'title' => $title,
'description' => $githubContent['body'],
'url' => $githubContent['html_url'],
);
/*
* The parse function checks if the $versionData message exists in the inbox,
* otherwise it will create it and add it to the inbox.
*/
$this->_inboxFactory->create()->parse(array_reverse($versionData));
/*
* This will compare the currently installed version with the latest available one.
* A message will appear after the login if the two are not matching.
*/
if ($this->_adyenHelper->getModuleVersion() != $githubContent['tag_name']) {
return true;
}
} catch (\Exception $e) {
return false;
}
}
return false;
}
/**
* Retrieve system message text
*
* @return \Magento\Framework\Phrase
*/
public function getText()
{
$githubContent = $this->getSessionData("AdyenGithubVersion");
$message = __("A new Adyen extension version is now available: ");
$message .= __("<a href= \"" . $githubContent['html_url'] . "\" target='_blank'> " . $githubContent['tag_name'] . "!</a>");
$message .= __(" You are running the " . $this->_adyenHelper->getModuleVersion() . " version. We advise to update your extension.");
return __($message);
}
/**
* Retrieve system message severity
*
* @return int
*/
public function getSeverity()
{
return self::SEVERITY_MAJOR;
}
public function getDecodedContentFromGithub()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/adyen/adyen-magento2/releases/latest');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'magento');
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content, true);
return $json;
}
/**
* Set the current value for the backend session
*/
public function setSessionData($key, $value)
{
return $this->_authSession->setData($key, $value);
}
/**
* Retrieve the session value
*/
public function getSessionData($key, $remove = false)
{
return $this->_authSession->getData($key, $remove);
}
}
...@@ -35,9 +35,10 @@ interface AdyenPaymentMethodManagementInterface ...@@ -35,9 +35,10 @@ interface AdyenPaymentMethodManagementInterface
/** /**
* Get payment information * Get payment information
* *
* @param string $cartId * @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface * @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/ */
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress); public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null);
} }
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Api\Data;
interface InvoiceInterface
{
/**
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/
/*
* Entity ID.
*/
const ENTITY_ID = 'entity_id';
/*
* Pspreference of the capture.
*/
const PSPREFERENCE = 'pspreference';
/*
* Original Pspreference of the payment.
*/
const ORIGINAL_REFERENCE = 'original_reference';
/*
* Acquirer reference.
*/
const ACQUIRER_REFERENCE = 'acquirer_reference';
/*
* Invoice ID.
*/
const INVOICE_ID = 'invoice_id';
/**
* Gets the ID for the invoice.
*
* @return int|null Entity ID.
*/
public function getEntityId();
/**
* Sets entity ID.
*
* @param int $entityId
* @return $this
*/
public function setEntityId($entityId);
/**
* Gets the Pspreference for the invoice(capture).
*
* @return int|null Pspreference.
*/
public function getPspreference();
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference);
/**
* @return mixed
*/
public function getOriginalReference();
/**
* @param $originalReference
* @return mixed
*/
public function setOriginalReference($originalReference);
/**
* Gets the AcquirerReference for the invoice.
*
* @return int|null Acquirerreference.
*/
public function getAcquirerReference();
/**
* Sets AcquirerReference.
*
* @param string $acquirerReference
* @return $this
*/
public function setAcquirerReference($acquirerReference);
/**
* Gets the InvoiceID for the invoice.
*
* @return int|null Invoice ID.
*/
public function getInvoiceId();
/**
* Sets InvoiceID.
*
* @param int $invoiceId
* @return $this
*/
public function setInvoiceId($invoiceId);
}
\ No newline at end of file
...@@ -35,9 +35,10 @@ interface GuestAdyenPaymentMethodManagementInterface ...@@ -35,9 +35,10 @@ interface GuestAdyenPaymentMethodManagementInterface
/** /**
* Get payment information * Get payment information
* *
* @param string $cartId * @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface * @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/ */
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress); public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null);
} }
...@@ -34,7 +34,7 @@ class AbstractInfo extends \Magento\Payment\Block\Info ...@@ -34,7 +34,7 @@ class AbstractInfo extends \Magento\Payment\Block\Info
protected $_adyenHelper; protected $_adyenHelper;
/** /**
* @var \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory * @var \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory
*/ */
protected $_adyenOrderPaymentCollectionFactory; protected $_adyenOrderPaymentCollectionFactory;
...@@ -42,13 +42,13 @@ class AbstractInfo extends \Magento\Payment\Block\Info ...@@ -42,13 +42,13 @@ class AbstractInfo extends \Magento\Payment\Block\Info
* AbstractInfo constructor. * AbstractInfo constructor.
* *
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory * @param \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param Template\Context $context * @param Template\Context $context
* @param array $data * @param array $data
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory, \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
Template\Context $context, Template\Context $context,
array $data = [] array $data = []
) )
......
...@@ -29,5 +29,5 @@ class Oneclick extends Cc ...@@ -29,5 +29,5 @@ class Oneclick extends Cc
/** /**
* @var string * @var string
*/ */
protected $_template = 'Adyen_Payment::info/adyen_oneclick.phtml'; protected $_template = 'Adyen_Payment::info/adyen_cc.phtml';
} }
...@@ -15,48 +15,82 @@ ...@@ -15,48 +15,82 @@
* *
* Adyen Payment module (https://www.adyen.com/) * Adyen Payment module (https://www.adyen.com/)
* *
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/) * Copyright (c) 2018 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details. * See LICENSE.txt for license details.
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Controller\Process;
use Symfony\Component\Config\Definition\Exception\Exception; namespace Adyen\Payment\Block\Info;
/**
* Class Json use Magento\Framework\View\Element\Template;
* @package Adyen\Payment\Controller\Process
*/ class PaymentLink extends AbstractInfo
class Cron extends \Magento\Framework\App\Action\Action
{ {
/** /**
* @var \Magento\Framework\ObjectManagerInterface * @var \Magento\Framework\Registry
*/
protected $_objectManager;
/**
* @var \Magento\Framework\Controller\Result\RawFactory
*/ */
protected $_resultFactory; private $registry;
/** /**
* Cron constructor. * @var \Adyen\Payment\Gateway\Command\PayByMailCommand
*
* @param \Magento\Framework\App\Action\Context $context
*/ */
private $payByMail;
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
Template\Context $context,
array $data = [],
\Magento\Framework\Registry $registry,
\Adyen\Payment\Gateway\Command\PayByMailCommand $payByMailCommand
) { ) {
parent::__construct($context); $this->registry = $registry;
$this->_objectManager = $context->getObjectManager(); $this->payByMail = $payByMailCommand;
$this->_resultFactory = $context->getResultFactory();
parent::__construct($adyenHelper, $adyenOrderPaymentCollectionFactory, $context, $data);
} }
/** /**
* Process Notification from Cron * @return \Magento\Sales\Model\Order
*/
public function getOrder()
{
return $this->registry->registry('current_order');
}
/**
* @return \Magento\Sales\Model\Order\Payment
*/
public function getPayment()
{
$order = $this->getOrder();
return $order->getPayment();
}
/**
* @return string
*/
public function getPaymentLinkUrl()
{
return $this->payByMail->generatePaymentUrl($this->getPayment(), $this->getOrder()->getTotalDue());
}
/**
* Check if order was placed using Adyen payment method
* and if total due is greater than zero while one or more payments have been made
*
* @return string
*/ */
public function execute() public function _toHtml()
{ {
$cron = $this->_objectManager->create('Adyen\Payment\Model\Cron'); return strpos($this->getPayment()->getMethod(), 'adyen_') === 0
$cron->processNotification(); && $this->_scopeConfig->getValue('payment/adyen_hpp/active')
die(); && $this->_scopeConfig->getValue('payment/adyen_pay_by_mail/active')
&& $this->getOrder()->getTotalInvoiced() > 0
&& $this->getOrder()->getTotalDue() > 0
? parent::_toHtml()
: '';
} }
} }
\ No newline at end of file
...@@ -445,31 +445,22 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -445,31 +445,22 @@ class Redirect extends \Magento\Payment\Block\Form
foreach ($this->_order->getAllVisibleItems() as $item) { foreach ($this->_order->getAllVisibleItems() as $item) {
++$count; ++$count;
$description = str_replace("\n", '', trim($item->getName()));
$itemAmount = $this->_adyenHelper->formatAmount($item->getPrice(), $currency);
$itemVatAmount =
($item->getTaxAmount() > 0 && $item->getPriceInclTax() > 0) ?
$this->_adyenHelper->formatAmount(
$item->getPriceInclTax(),
$currency
) - $this->_adyenHelper->formatAmount(
$item->getPrice(),
$currency
) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency);
// 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, $formFields = $this->_adyenHelper->createOpenInvoiceLineItem(
$itemVatAmount, $itemVatPercentage, $numberOfItems); $formFields,
$count,
$item->getName(),
$item->getPrice(),
$currency,
$item->getTaxAmount(),
$item->getPriceInclTax(),
$item->getTaxPercent(),
$numberOfItems,
$this->_order->getPayment()
);
} }
// Discount cost // Discount cost
if ($this->_order->getDiscountAmount() > 0 || $this->_order->getDiscountAmount() < 0) { if ($this->_order->getDiscountAmount() > 0 || $this->_order->getDiscountAmount() < 0) {
++$count; ++$count;
...@@ -480,35 +471,23 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -480,35 +471,23 @@ class Redirect extends \Magento\Payment\Block\Form
$itemVatPercentage = "0"; $itemVatPercentage = "0";
$numberOfItems = 1; $numberOfItems = 1;
$formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount, $formFields = $this->_adyenHelper->getOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems); $itemVatAmount, $itemVatPercentage, $numberOfItems, $this->_order->getPayment());
} }
// Shipping cost // Shipping cost
if ($this->_order->getShippingAmount() > 0 || $this->_order->getShippingTaxAmount() > 0) { if ($this->_order->getShippingAmount() > 0 || $this->_order->getShippingTaxAmount() > 0) {
++$count; ++$count;
$description = $this->_order->getShippingDescription(); $formFields = $this->_adyenHelper->createOpenInvoiceLineShipping(
$itemAmount = $this->_adyenHelper->formatAmount($this->_order->getShippingAmount(), $currency); $formFields,
$itemVatAmount = $this->_adyenHelper->formatAmount($this->_order->getShippingTaxAmount(), $currency); $count,
$this->_order,
// Create RateRequest to calculate the Tax class rate for the shipping method $this->_order->getShippingAmount(),
$rateRequest = $this->_taxCalculation->getRateRequest( $this->_order->getShippingTaxAmount(),
$this->_order->getShippingAddress(), $currency,
$this->_order->getBillingAddress(), $this->_order->getPayment()
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'];
...@@ -517,40 +496,6 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -517,40 +496,6 @@ 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
......
...@@ -62,7 +62,8 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -62,7 +62,8 @@ class Json extends \Magento\Framework\App\Action\Action
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger
) { )
{
parent::__construct($context); parent::__construct($context);
$this->_objectManager = $context->getObjectManager(); $this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory(); $this->_resultFactory = $context->getResultFactory();
...@@ -100,6 +101,8 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -100,6 +101,8 @@ class Json extends \Magento\Framework\App\Action\Action
if ($notificationMode != "" && $this->_validateNotificationMode($notificationMode)) { if ($notificationMode != "" && $this->_validateNotificationMode($notificationMode)) {
foreach ($notificationItems['notificationItems'] as $notificationItem) { foreach ($notificationItems['notificationItems'] as $notificationItem) {
$status = $this->_processNotification( $status = $this->_processNotification(
$notificationItem['NotificationRequestItem'], $notificationMode $notificationItem['NotificationRequestItem'], $notificationMode
); );
...@@ -108,9 +111,10 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -108,9 +111,10 @@ class Json extends \Magento\Framework\App\Action\Action
$this->_return401(); $this->_return401();
return; return;
} }
}
$acceptedMessage = "[accepted]"; $acceptedMessage = "[accepted]";
}
$cronCheckTest = $notificationItems['notificationItems'][0]['NotificationRequestItem']['pspReference']; $cronCheckTest = $notificationItems['notificationItems'][0]['NotificationRequestItem']['pspReference'];
// Run the query for checking unprocessed notifications, do this only for test notifications coming from the Adyen Customer Area // Run the query for checking unprocessed notifications, do this only for test notifications coming from the Adyen Customer Area
...@@ -247,8 +251,7 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -247,8 +251,7 @@ class Json extends \Magento\Framework\App\Action\Action
if (empty($submitedMerchantAccount) && empty($internalMerchantAccount)) { if (empty($submitedMerchantAccount) && empty($internalMerchantAccount)) {
if ($this->_isTestNotification($response['pspReference'])) { if ($this->_isTestNotification($response['pspReference'])) {
echo 'merchantAccountCode is empty in magento settings'; $this->_returnResult('merchantAccountCode is empty in magento settings');
exit();
} }
return false; return false;
} }
...@@ -256,8 +259,9 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -256,8 +259,9 @@ class Json extends \Magento\Framework\App\Action\Action
// validate username and password // validate username and password
if ((!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW']))) { if ((!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW']))) {
if ($this->_isTestNotification($response['pspReference'])) { if ($this->_isTestNotification($response['pspReference'])) {
echo 'Authentication failed: PHP_AUTH_USER and PHP_AUTH_PW are empty. See Adyen Magento manual CGI mode'; $this->_returnResult(
exit(); 'Authentication failed: PHP_AUTH_USER and PHP_AUTH_PW are empty. See Adyen Magento manual CGI mode'
);
} }
return false; return false;
} }
...@@ -275,11 +279,11 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -275,11 +279,11 @@ class Json extends \Magento\Framework\App\Action\Action
// If notification is test check if fields are correct if not return error // If notification is test check if fields are correct if not return error
if ($this->_isTestNotification($response['pspReference'])) { if ($this->_isTestNotification($response['pspReference'])) {
if ($accountCmp != 0) { if ($accountCmp != 0) {
echo 'MerchantAccount in notification is not the same as in Magento settings'; $this->_returnResult('MerchantAccount in notification is not the same as in Magento settings');
exit();
} elseif ($usernameCmp != 0 || $passwordCmp != 0) { } elseif ($usernameCmp != 0 || $passwordCmp != 0) {
echo 'username (PHP_AUTH_USER) and\or password (PHP_AUTH_PW) are not the same as Magento settings'; $this->_returnResult(
exit(); 'username (PHP_AUTH_USER) and\or password (PHP_AUTH_PW) are not the same as Magento settings'
);
} }
} }
return false; return false;
...@@ -356,4 +360,18 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -356,4 +360,18 @@ class Json extends \Magento\Framework\App\Action\Action
return false; return false;
} }
} }
/**
* Returns the message to the browser
*
* @param $message
*/
protected function _returnResult($message)
{
$this->getResponse()
->clearHeader('Content-Type')
->setHeader('Content-Type', 'text/html')
->setBody($message);
return;
}
} }
\ No newline at end of file
...@@ -91,6 +91,8 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -91,6 +91,8 @@ class Result extends \Magento\Framework\App\Action\Action
$response = $this->getRequest()->getParams(); $response = $this->getRequest()->getParams();
$this->_adyenLogger->addAdyenResult(print_r($response, true)); $this->_adyenLogger->addAdyenResult(print_r($response, true));
$failReturnPath = $this->_adyenHelper->getAdyenAbstractConfigData('return_path');
if ($response) { if ($response) {
$result = $this->validateResponse($response); $result = $this->validateResponse($response);
...@@ -100,11 +102,11 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -100,11 +102,11 @@ class Result extends \Magento\Framework\App\Action\Action
$this->_redirect('checkout/onepage/success', ['_query' => ['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($failReturnPath);
} }
} else { } else {
// redirect to checkout page // redirect to checkout page
$this->_redirect('checkout/cart'); $this->_redirect($failReturnPath);
} }
} }
......
...@@ -98,7 +98,7 @@ class ResultPos extends \Magento\Framework\App\Action\Action ...@@ -98,7 +98,7 @@ class ResultPos extends \Magento\Framework\App\Action\Action
$this->_redirect('checkout/onepage/success', ['_query' => ['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($this->_adyenHelper->getAdyenAbstractConfigData('return_path'));
} }
} }
......
...@@ -150,7 +150,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action ...@@ -150,7 +150,7 @@ class Validate3d extends \Magento\Framework\App\Action\Action
// restore the quote // restore the quote
$session->restoreQuote(); $session->restoreQuote();
$this->_redirect('checkout/cart'); $this->_redirect($this->_adyenHelper->getAdyenAbstractConfigData('return_path'));
} }
} }
} else { } else {
......
...@@ -54,6 +54,7 @@ class PayByMailCommand implements CommandInterface ...@@ -54,6 +54,7 @@ class PayByMailCommand implements CommandInterface
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
} }
/** /**
* @param array $commandSubject * @param array $commandSubject
* @return $this * @return $this
...@@ -68,7 +69,7 @@ class PayByMailCommand implements CommandInterface ...@@ -68,7 +69,7 @@ class PayByMailCommand implements CommandInterface
$payment->setIsTransactionPending(true); $payment->setIsTransactionPending(true);
// generateUrl // generateUrl
$payment->setAdditionalInformation('payment_url', $this->_generatePaymentUrl($payment)); $payment->setAdditionalInformation('payment_url', $this->generatePaymentUrl($payment));
// update status and state // update status and state
$stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW); $stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
...@@ -79,13 +80,14 @@ class PayByMailCommand implements CommandInterface ...@@ -79,13 +80,14 @@ class PayByMailCommand implements CommandInterface
} }
/** /**
* @param $payment * @param \Magento\Sales\Model\Order\Payment $payment
* @param float|bool $paymentAmount
* @return string * @return string
*/ */
protected function _generatePaymentUrl($payment) public function generatePaymentUrl($payment, $paymentAmount = false)
{ {
$url = $this->getFormUrl(); $url = $this->getFormUrl();
$fields = $this->getFormFields($payment); $fields = $this->getFormFields($payment, $paymentAmount);
$count = 1; $count = 1;
$size = count($fields); $size = count($fields);
...@@ -119,10 +121,11 @@ class PayByMailCommand implements CommandInterface ...@@ -119,10 +121,11 @@ class PayByMailCommand implements CommandInterface
/** /**
* @param $payment * @param \Magento\Sales\Model\Order\Payment $payment
* @param float|bool $paymentAmount
* @return array * @return array
*/ */
protected function getFormFields($payment) protected function getFormFields($payment, $paymentAmount = false)
{ {
$order = $payment->getOrder(); $order = $payment->getOrder();
...@@ -143,7 +146,7 @@ class PayByMailCommand implements CommandInterface ...@@ -143,7 +146,7 @@ class PayByMailCommand implements CommandInterface
$hmacKey = $this->_adyenHelper->getHmacPayByMail(); $hmacKey = $this->_adyenHelper->getHmacPayByMail();
} }
$amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode); $amount = $this->_adyenHelper->formatAmount($paymentAmount ?: $order->getGrandTotal(), $orderCurrencyCode);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId)); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId));
$shopperEmail = $order->getCustomerEmail(); $shopperEmail = $order->getCustomerEmail();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
......
...@@ -38,11 +38,12 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface ...@@ -38,11 +38,12 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface
* *
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper) public function __construct(
{ \Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
} }
/** /**
* @param array $buildSubject * @param array $buildSubject
* @return mixed * @return mixed
...@@ -59,7 +60,15 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface ...@@ -59,7 +60,15 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface
$request = []; $request = [];
$request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number"); $request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number");
$request['selectedBrand'] = $payment->getAdditionalInformation("boleto_type");
$boletoTypes = $this->adyenHelper->getAdyenBoletoConfigData('boletotypes');
$boletoTypes = explode(',', $boletoTypes);
if (count($boletoTypes) == 1) {
$request['selectedBrand'] = $boletoTypes[0];
} else {
$request['selectedBrand'] = $payment->getAdditionalInformation("boleto_type");
}
$shopperName = [ $shopperName = [
'firstName' => $payment->getAdditionalInformation("firstname"), 'firstName' => $payment->getAdditionalInformation("firstname"),
...@@ -68,7 +77,7 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface ...@@ -68,7 +77,7 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface
$request['shopperName'] = $shopperName; $request['shopperName'] = $shopperName;
$deliveryDays = (int) $this->adyenHelper->getAdyenBoletoConfigData("delivery_days", $storeId); $deliveryDays = (int)$this->adyenHelper->getAdyenBoletoConfigData("delivery_days", $storeId);
$deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5; $deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5;
$deliveryDate = date( $deliveryDate = date(
"Y-m-d\TH:i:s ", "Y-m-d\TH:i:s ",
...@@ -81,7 +90,7 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface ...@@ -81,7 +90,7 @@ class BoletoAuthorizationDataBuilder implements BuilderInterface
); );
$request['deliveryDate'] = $deliveryDate; $request['deliveryDate'] = $deliveryDate;
return $request; return $request;
} }
} }
\ No newline at end of file
...@@ -48,7 +48,7 @@ class CaptureDataBuilder implements BuilderInterface ...@@ -48,7 +48,7 @@ class CaptureDataBuilder implements BuilderInterface
/** /**
* Create capture request * Create capture request
* *
* @param array $buildSubject * @param array $buildSubject
* @return array * @return array
*/ */
...@@ -57,21 +57,84 @@ class CaptureDataBuilder implements BuilderInterface ...@@ -57,21 +57,84 @@ class CaptureDataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject); $amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject);
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$pspReference = $payment->getCcTransId(); $pspReference = $payment->getCcTransId();
$currency = $payment->getOrder()->getOrderCurrencyCode(); $currency = $payment->getOrder()->getOrderCurrencyCode();
//format the amount to minor units
$amount = $this->adyenHelper->formatAmount($amount, $currency); $amount = $this->adyenHelper->formatAmount($amount, $currency);
$modificationAmount = ['currency' => $currency, 'value' => $amount]; $modificationAmount = ['currency' => $currency, 'value' => $amount];
$request = [
return [
"modificationAmount" => $modificationAmount, "modificationAmount" => $modificationAmount,
"reference" => $payment->getOrder()->getIncrementId(), "reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $pspReference "originalReference" => $pspReference
]; ];
$brandCode = $payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
$openInvoiceFields = $this->getOpenInvoiceData($payment);
$request["additionalData"] = $openInvoiceFields;
}
return $request;
}
/**
* @param $payment
* @return mixed
* @internal param $formFields
*/
protected function getOpenInvoiceData($payment)
{
$formFields = [];
$count = 0;
$currency = $payment->getOrder()->getOrderCurrencyCode();
$invoices = $payment->getOrder()->getInvoiceCollection();
// The latest invoice will contain only the selected items(and quantities) for the (partial) capture
$latestInvoice = $invoices->getLastItem();
foreach ($latestInvoice->getItemsCollection() as $invoiceItem) {
++$count;
$numberOfItems = (int)$invoiceItem->getQty();
$formFields = $this->adyenHelper->createOpenInvoiceLineItem(
$formFields,
$count,
$invoiceItem->getName(),
$invoiceItem->getPrice(),
$currency,
$invoiceItem->getTaxAmount(),
$invoiceItem->getPriceInclTax(),
$invoiceItem->getTaxPercent(),
$numberOfItems,
$payment
);
}
// Shipping cost
if ($latestInvoice->getShippingAmount() > 0) {
++$count;
$formFields = $this->adyenHelper->createOpenInvoiceLineShipping(
$formFields,
$count,
$payment->getOrder(),
$latestInvoice->getShippingAmount(),
$latestInvoice->getShippingTaxAmount(),
$currency,
$payment
);
}
$formFields['openinvoicedata.numberOfLines'] = $count;
return $formFields;
} }
} }
\ No newline at end of file
...@@ -37,22 +37,28 @@ class RefundDataBuilder implements BuilderInterface ...@@ -37,22 +37,28 @@ class RefundDataBuilder implements BuilderInterface
private $adyenHelper; private $adyenHelper;
/** /**
* @var \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory * @var \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory
*/ */
private $orderPaymentCollectionFactory; private $orderPaymentCollectionFactory;
/**
* @var \Adyen\Payment\Model\ResourceModel\Invoice\CollectionFactory
*/
protected $adyenInvoiceCollectionFactory;
/** /**
* RefundDataBuilder constructor. * RefundDataBuilder constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $orderPaymentCollectionFactory * @param \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $orderPaymentCollectionFactory
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $orderPaymentCollectionFactory \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $orderPaymentCollectionFactory,
) \Adyen\Payment\Model\ResourceModel\Invoice\CollectionFactory $adyenInvoiceCollectionFactory
{ ) {
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->orderPaymentCollectionFactory = $orderPaymentCollectionFactory; $this->orderPaymentCollectionFactory = $orderPaymentCollectionFactory;
$this->adyenInvoiceCollectionFactory = $adyenInvoiceCollectionFactory;
} }
/** /**
...@@ -63,7 +69,7 @@ class RefundDataBuilder implements BuilderInterface ...@@ -63,7 +69,7 @@ class RefundDataBuilder implements BuilderInterface
{ {
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject); $amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject);
$order = $paymentDataObject->getOrder(); $order = $paymentDataObject->getOrder();
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
...@@ -96,7 +102,7 @@ class RefundDataBuilder implements BuilderInterface ...@@ -96,7 +102,7 @@ class RefundDataBuilder implements BuilderInterface
$orderPaymentCollection->addPaymentFilterDescending($payment->getId()); $orderPaymentCollection->addPaymentFilterDescending($payment->getId());
} elseif ($refundStrategy == "3") { } elseif ($refundStrategy == "3") {
// refund based on ratio // refund based on ratio
$ratio = $amount / $grandTotal; $ratio = $amount / $grandTotal;
$orderPaymentCollection->addPaymentFilterAscending($payment->getId()); $orderPaymentCollection->addPaymentFilterAscending($payment->getId());
} }
...@@ -109,7 +115,7 @@ class RefundDataBuilder implements BuilderInterface ...@@ -109,7 +115,7 @@ class RefundDataBuilder implements BuilderInterface
// refund based on ratio calculate refund amount // refund based on ratio calculate refund amount
$modificationAmount = $ratio * ( $modificationAmount = $ratio * (
$splitPayment->getAmount() - $splitPayment->getTotalRefunded() $splitPayment->getAmount() - $splitPayment->getTotalRefunded()
); );
} else { } else {
// total authorised amount of the split payment // total authorised amount of the split payment
$splitPaymentAmount = $splitPayment->getAmount() - $splitPayment->getTotalRefunded(); $splitPaymentAmount = $splitPayment->getAmount() - $splitPayment->getTotalRefunded();
...@@ -119,7 +125,7 @@ class RefundDataBuilder implements BuilderInterface ...@@ -119,7 +125,7 @@ class RefundDataBuilder implements BuilderInterface
continue; continue;
} }
// if refunded amount is greather then split payment amount do a full refund // if refunded amount is greater than split payment amount do a full refund
if ($amount >= $splitPaymentAmount) { if ($amount >= $splitPaymentAmount) {
$modificationAmount = $splitPaymentAmount; $modificationAmount = $splitPaymentAmount;
} else { } else {
...@@ -155,8 +161,81 @@ class RefundDataBuilder implements BuilderInterface ...@@ -155,8 +161,81 @@ class RefundDataBuilder implements BuilderInterface
"merchantAccount" => $merchantAccount "merchantAccount" => $merchantAccount
] ]
]; ];
$brandCode = $payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
);
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
$openInvoiceFields = $this->getOpenInvoiceData($payment);
//There is only one payment, so we add the fields to the first(and only) result
$result[0]["additionalData"] = $openInvoiceFields;
}
} }
return $result; return $result;
} }
protected function getOpenInvoiceData($payment)
{
$formFields = [];
$count = 0;
$currency = $payment->getOrder()->getOrderCurrencyCode();
/**
* Magento\Sales\Model\Order\Creditmemo
*/
$creditMemo = $payment->getCreditMemo();
foreach ($creditMemo->getAllItems() as $refundItem) {
++$count;
$numberOfItems = $refundItem->getQty();
$formFields = $this->adyenHelper->createOpenInvoiceLineItem(
$formFields,
$count,
$refundItem->getName(),
$refundItem->getPrice(),
$currency,
$refundItem->getTaxAmount(),
$refundItem->getPriceInclTax(),
$refundItem->getTaxPercent(),
$numberOfItems,
$payment
);
}
// Shipping cost
if ($creditMemo->getShippingAmount() > 0) {
++$count;
$formFields = $this->adyenHelper->createOpenInvoiceLineShipping(
$formFields,
$count,
$payment->getOrder(),
$creditMemo->getShippingAmount(),
$creditMemo->getShippingTaxAmount(),
$currency,
$payment
);
}
$formFields['openinvoicedata.numberOfLines'] = $count;
//Retrieve acquirerReference from the adyen_invoice
$invoiceId = $creditMemo->getInvoice()->getId();
$invoices = $this->adyenInvoiceCollectionFactory->create()
->addFieldToFilter('invoice_id', $invoiceId);
$invoice = $invoices->getFirstItem();
if($invoice) {
$formFields['acquirerReference'] = $invoice->getAcquirerReference();
}
return $formFields;
}
} }
\ No newline at end of file
...@@ -55,7 +55,7 @@ class Data extends AbstractHelper ...@@ -55,7 +55,7 @@ class Data extends AbstractHelper
protected $_moduleList; protected $_moduleList;
/** /**
* @var \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory * @var \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory
*/ */
protected $_billingAgreementCollectionFactory; protected $_billingAgreementCollectionFactory;
...@@ -69,6 +69,21 @@ class Data extends AbstractHelper ...@@ -69,6 +69,21 @@ class Data extends AbstractHelper
*/ */
protected $_assetSource; protected $_assetSource;
/**
* @var \Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory
*/
protected $_notificationFactory;
/**
* @var \Magento\Tax\Model\Config
*/
protected $_taxConfig;
/**
* @var \Magento\Tax\Model\Calculation
*/
protected $_taxCalculation;
/** /**
* Data constructor. * Data constructor.
* *
...@@ -77,7 +92,7 @@ class Data extends AbstractHelper ...@@ -77,7 +92,7 @@ class Data extends AbstractHelper
* @param \Magento\Framework\Config\DataInterface $dataStorage * @param \Magento\Framework\Config\DataInterface $dataStorage
* @param \Magento\Directory\Model\Config\Source\Country $country * @param \Magento\Directory\Model\Config\Source\Country $country
* @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory * @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource * @param \Magento\Framework\View\Asset\Source $assetSource
*/ */
...@@ -87,12 +102,13 @@ class Data extends AbstractHelper ...@@ -87,12 +102,13 @@ class Data extends AbstractHelper
\Magento\Framework\Config\DataInterface $dataStorage, \Magento\Framework\Config\DataInterface $dataStorage,
\Magento\Directory\Model\Config\Source\Country $country, \Magento\Directory\Model\Config\Source\Country $country,
\Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Module\ModuleListInterface $moduleList,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory, \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
\Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\Asset\Source $assetSource, \Magento\Framework\View\Asset\Source $assetSource,
\Adyen\Payment\Model\Resource\Notification\CollectionFactory $notificationFactory \Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory $notificationFactory,
) \Magento\Tax\Model\Config $taxConfig,
{ \Magento\Tax\Model\Calculation $taxCalculation
) {
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
$this->_dataStorage = $dataStorage; $this->_dataStorage = $dataStorage;
...@@ -102,6 +118,8 @@ class Data extends AbstractHelper ...@@ -102,6 +118,8 @@ class Data extends AbstractHelper
$this->_assetRepo = $assetRepo; $this->_assetRepo = $assetRepo;
$this->_assetSource = $assetSource; $this->_assetSource = $assetSource;
$this->_notificationFactory = $notificationFactory; $this->_notificationFactory = $notificationFactory;
$this->_taxConfig = $taxConfig;
$this->_taxCalculation = $taxCalculation;
} }
/** /**
...@@ -464,7 +482,7 @@ class Data extends AbstractHelper ...@@ -464,7 +482,7 @@ class Data extends AbstractHelper
{ {
return $this->getConfigData($field, 'adyen_apple_pay', $storeId); return $this->getConfigData($field, 'adyen_apple_pay', $storeId);
} }
/** /**
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -847,15 +865,15 @@ class Data extends AbstractHelper ...@@ -847,15 +865,15 @@ class Data extends AbstractHelper
*/ */
public function isPaymentMethodOpenInvoiceMethod($paymentMethod) public function isPaymentMethodOpenInvoiceMethod($paymentMethod)
{ {
if (strlen($paymentMethod) >= 9 && substr($paymentMethod, 0, 9) == 'afterpay_') { if (strpos($paymentMethod, 'afterpay') !== false) {
return true;
} elseif (strpos($paymentMethod, 'klarna') !== false) {
return true;
} elseif (strpos($paymentMethod, 'ratepay') !== false) {
return true; return true;
} else {
if ($paymentMethod == 'klarna' || $paymentMethod == 'ratepay') {
return true;
} else {
return false;
}
} }
return false;
} }
public function getRatePayId() public function getRatePayId()
...@@ -968,4 +986,149 @@ class Data extends AbstractHelper ...@@ -968,4 +986,149 @@ class Data extends AbstractHelper
return "https://" . $environment . ".adyen.com/hpp/cse/js/" . $this->getLibraryToken($storeId) . ".shtml"; return "https://" . $environment . ".adyen.com/hpp/cse/js/" . $this->getLibraryToken($storeId) . ".shtml";
} }
/**
* @param $formFields
* @param $count
* @param $name
* @param $price
* @param $currency
* @param $taxAmount
* @param $priceInclTax
* @param $taxPercent
* @param $numberOfItems
* @param $payment
* @return mixed
*/
public function createOpenInvoiceLineItem(
$formFields,
$count,
$name,
$price,
$currency,
$taxAmount,
$priceInclTax,
$taxPercent,
$numberOfItems,
$payment
) {
$description = str_replace("\n", '', trim($name));
$itemAmount = $this->formatAmount($price, $currency);
$itemVatAmount = $this->getItemVatAmount($taxAmount,
$priceInclTax, $price, $currency);
// Calculate vat percentage
$itemVatPercentage = $this->getMinorUnitTaxPercent($taxPercent);
return $this->getOpenInvoiceLineData($formFields, $count, $currency, $description,
$itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems, $payment);
}
/**
* @param $formFields
* @param $count
* @param $order
* @param $shippingAmount
* @param $shippingTaxAmount
* @param $currency
* @param $payment
* @return mixed
*/
public function createOpenInvoiceLineShipping(
$formFields,
$count,
$order,
$shippingAmount,
$shippingTaxAmount,
$currency,
$payment
) {
$description = $order->getShippingDescription();
$itemAmount = $this->formatAmount($shippingAmount, $currency);
$itemVatAmount = $this->formatAmount($shippingTaxAmount, $currency);
// Create RateRequest to calculate the Tax class rate for the shipping method
$rateRequest = $this->_taxCalculation->getRateRequest(
$order->getShippingAddress(),
$order->getBillingAddress(),
null,
$order->getStoreId(),
$order->getCustomerId()
);
$taxClassId = $this->_taxConfig->getShippingTaxClass($order->getStoreId());
$rateRequest->setProductClassId($taxClassId);
$rate = $this->_taxCalculation->getRate($rateRequest);
$itemVatPercentage = $this->getMinorUnitTaxPercent($rate);
$numberOfItems = 1;
return $this->getOpenInvoiceLineData($formFields, $count, $currency, $description,
$itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems, $payment);
}
/**
* @param $taxAmount
* @param $priceInclTax
* @param $price
* @param $currency
* @return string
*/
public function getItemVatAmount(
$taxAmount,
$priceInclTax,
$price,
$currency
) {
if ($taxAmount > 0 && $priceInclTax > 0) {
return $this->formatAmount($priceInclTax, $currency) - $this->formatAmount($price, $currency);
}
return $this->formatAmount($taxAmount, $currency);
}
/**
* Set the openinvoice line
*
* @param $formFields
* @param $count
* @param $currencyCode
* @param $description
* @param $itemAmount
* @param $itemVatAmount
* @param $itemVatPercentage
* @param $numberOfItems
* @param $payment
* @return
*/
public function getOpenInvoiceLineData(
$formFields,
$count,
$currencyCode,
$description,
$itemAmount,
$itemVatAmount,
$itemVatPercentage,
$numberOfItems,
$payment
) {
$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->isVatCategoryHigh($payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE))
) {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
} else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
}
return $formFields;
}
} }
\ No newline at end of file
...@@ -154,10 +154,16 @@ class PaymentMethods extends AbstractHelper ...@@ -154,10 +154,16 @@ class PaymentMethods extends AbstractHelper
{ {
$paymentMethods = []; $paymentMethods = [];
$ccEnabled = $this->_config->getValue('payment/'.\Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CODE.'/active'); $ccEnabled = $this->_config->getValue(
'payment/' . \Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CODE . '/active',
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
$ccTypes = array_keys($this->_adyenHelper->getCcTypesAltData()); $ccTypes = array_keys($this->_adyenHelper->getCcTypesAltData());
$sepaEnabled = $this->_config->getValue( $sepaEnabled = $this->_config->getValue(
'payment/'.\Adyen\Payment\Model\Ui\AdyenSepaConfigProvider::CODE.'/active' 'payment/' . \Adyen\Payment\Model\Ui\AdyenSepaConfigProvider::CODE . '/active',
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
); );
foreach ($this->_fetchHppMethods($store, $country) as $methodCode => $methodData) { foreach ($this->_fetchHppMethods($store, $country) as $methodCode => $methodData) {
...@@ -192,20 +198,20 @@ class PaymentMethods extends AbstractHelper ...@@ -192,20 +198,20 @@ class PaymentMethods extends AbstractHelper
} }
$adyFields = [ $adyFields = [
"paymentAmount" => (int) $this->_adyenHelper->formatAmount( "paymentAmount" => (int)$this->_adyenHelper->formatAmount(
$this->_getCurrentPaymentAmount(), $this->_getCurrentPaymentAmount(),
$this->_getCurrentCurrencyCode($store) $this->_getCurrentCurrencyCode($store)
), ),
"currencyCode" => $this->_getCurrentCurrencyCode($store), "currencyCode" => $this->_getCurrentCurrencyCode($store),
"merchantReference" => "Get Payment methods", "merchantReference" => "Get Payment methods",
"skinCode" => $skinCode, "skinCode" => $skinCode,
"merchantAccount" => $merchantAccount, "merchantAccount" => $merchantAccount,
"sessionValidity" => date( "sessionValidity" => date(
DATE_ATOM, DATE_ATOM,
mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y")) mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y"))
), ),
"countryCode" => $this->_getCurrentCountryCode($store, $country), "countryCode" => $this->_getCurrentCountryCode($store, $country),
"shopperLocale" => $this->_getCurrentLocaleCode($store) "shopperLocale" => $this->_getCurrentLocaleCode($store)
]; ];
$responseData = $this->_getDirectoryLookupResponse($adyFields, $store); $responseData = $this->_getDirectoryLookupResponse($adyFields, $store);
...@@ -228,9 +234,9 @@ class PaymentMethods extends AbstractHelper ...@@ -228,9 +234,9 @@ class PaymentMethods extends AbstractHelper
$themeCode = "Magento/blank"; $themeCode = "Magento/blank";
$themeId = $this->_design->getConfigurationDesignTheme(\Magento\Framework\App\Area::AREA_FRONTEND); $themeId = $this->_design->getConfigurationDesignTheme(\Magento\Framework\App\Area::AREA_FRONTEND);
if(!empty($themeId)) { if (!empty($themeId)) {
$theme = $this->_themeProvider->getThemeById($themeId); $theme = $this->_themeProvider->getThemeById($themeId);
if($theme && !empty($theme->getCode())) { if ($theme && !empty($theme->getCode())) {
$themeCode = $theme->getCode(); $themeCode = $theme->getCode();
} }
} }
...@@ -405,7 +411,7 @@ class PaymentMethods extends AbstractHelper ...@@ -405,7 +411,7 @@ class PaymentMethods extends AbstractHelper
$service = new \Adyen\Service\DirectoryLookup($client); $service = new \Adyen\Service\DirectoryLookup($client);
try { try {
$responseData = $service->directoryLookup($requestParams); $responseData = $service->directoryLookup($requestParams);
} catch (\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
$this->_adyenLogger->error( $this->_adyenLogger->error(
"The Directory Lookup response is empty check your Adyen configuration in Magento." "The Directory Lookup response is empty check your Adyen configuration in Magento."
......
This diff is collapsed.
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
use Adyen\Payment\Api\Data\InvoiceInterface;
class Invoice extends \Magento\Framework\Model\AbstractModel
implements InvoiceInterface
{
/**
* Notification constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\ResourceModel\Invoice');
}
/**
* Gets the Pspreference for the invoice(capture).
*
* @return int|null Pspreference.
*/
public function getPspreference()
{
return $this->getData(self::PSPREFERENCE);
}
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference)
{
return $this->setData(self::PSPREFERENCE, $pspreference);
}
/**
* Gets the Pspreference of the original Payment
* @return mixed
*/
public function getOriginalReference()
{
return $this->getData(self::ORIGINAL_REFERENCE);
}
/**
* Sets the OriginalReference
*
* @param $originalReference
* @return $this
*/
public function setOriginalReference($originalReference)
{
return $this->setData(self::ORIGINAL_REFERENCE, $originalReference);
}
/**
* Gets the AcquirerReference for the invoice.
*
* @return int|null Acquirerreference.
*/
public function getAcquirerReference()
{
return $this->getData(self::ACQUIRER_REFERENCE);
}
/**
* Sets AcquirerReference.
*
* @param string $acquirerReference
* @return $this
*/
public function setAcquirerReference($acquirerReference)
{
return $this->setData(self::ACQUIRER_REFERENCE, $acquirerReference);
}
/**
* Gets the InvoiceID for the invoice.
*
* @return int|null Invoice ID.
*/
public function getInvoiceId()
{
return $this->getData(self::INVOICE_ID);
}
/**
* Sets InvoiceID.
*
* @param int $invoiceId
* @return $this
*/
public function setInvoiceId($invoiceId)
{
return $this->setData(self::INVOICE_ID, $invoiceId);
}
}
\ No newline at end of file
...@@ -96,7 +96,7 @@ class Adapter extends Method\Adapter ...@@ -96,7 +96,7 @@ class Adapter extends Method\Adapter
$agreement->getCustomerReference(), $agreement->getCustomerReference(),
$agreement->getStoreId() $agreement->getStoreId()
); );
} catch(Exception $e) { } catch(\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract')); throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract'));
} }
} }
......
...@@ -76,7 +76,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel ...@@ -76,7 +76,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel
*/ */
protected function _construct() protected function _construct()
{ {
$this->_init('Adyen\Payment\Model\Resource\Notification'); $this->_init('Adyen\Payment\Model\ResourceModel\Notification');
} }
/** /**
......
...@@ -55,7 +55,7 @@ class Payment extends \Magento\Framework\Model\AbstractModel ...@@ -55,7 +55,7 @@ class Payment extends \Magento\Framework\Model\AbstractModel
*/ */
protected function _construct() protected function _construct()
{ {
$this->_init('Adyen\Payment\Model\Resource\Order\Payment'); $this->_init('Adyen\Payment\Model\ResourceModel\Order\Payment');
} }
/** /**
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Model\Resource\Billing; namespace Adyen\Payment\Model\ResourceModel\Billing;
/** /**
* Billing agreement resource model * Billing agreement resource model
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Model\Resource\Billing\Agreement; namespace Adyen\Payment\Model\ResourceModel\Billing\Agreement;
/** /**
* Billing agreements resource collection * Billing agreements resource collection
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\ResourceModel;
class Invoice extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Resource initialization
*
* @return void
*/
protected function _construct()
{
$this->_init('adyen_invoice', 'entity_id');
}
}
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\ResourceModel\Invoice;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
/**
* Construct
*/
public function _construct()
{
$this->_init('Adyen\Payment\Model\Invoice', 'Adyen\Payment\Model\ResourceModel\Invoice');
}
}
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Model\Resource; namespace Adyen\Payment\Model\ResourceModel;
class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{ {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Model\Resource\Notification; namespace Adyen\Payment\Model\ResourceModel\Notification;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{ {
...@@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab ...@@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/ */
public function _construct() public function _construct()
{ {
$this->_init('Adyen\Payment\Model\Notification', 'Adyen\Payment\Model\Resource\Notification'); $this->_init('Adyen\Payment\Model\Notification', 'Adyen\Payment\Model\ResourceModel\Notification');
} }
/** /**
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Model\Resource\Order; namespace Adyen\Payment\Model\ResourceModel\Order;
class Payment extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb class Payment extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{ {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
namespace Adyen\Payment\Model\Resource\Order\Payment; namespace Adyen\Payment\Model\ResourceModel\Order\Payment;
/** /**
* Billing agreements resource collection * Billing agreements resource collection
...@@ -36,7 +36,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab ...@@ -36,7 +36,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/ */
protected function _construct() protected function _construct()
{ {
$this->_init('Adyen\Payment\Model\Order\Payment', 'Adyen\Payment\Model\Resource\Order\Payment'); $this->_init('Adyen\Payment\Model\Order\Payment', 'Adyen\Payment\Model\ResourceModel\Order\Payment');
} }
/** /**
......
...@@ -34,7 +34,7 @@ class AdyenBoletoConfigProvider implements ConfigProviderInterface ...@@ -34,7 +34,7 @@ class AdyenBoletoConfigProvider implements ConfigProviderInterface
* @var PaymentHelper * @var PaymentHelper
*/ */
protected $_paymentHelper; protected $_paymentHelper;
/** /**
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
...@@ -86,12 +86,32 @@ class AdyenBoletoConfigProvider implements ConfigProviderInterface ...@@ -86,12 +86,32 @@ class AdyenBoletoConfigProvider implements ConfigProviderInterface
'checkout/onepage/success/', ['_secure' => $this->_getRequest()->isSecure()]) 'checkout/onepage/success/', ['_secure' => $this->_getRequest()->isSecure()])
], ],
'adyenBoleto' => [ 'adyenBoleto' => [
'boletoTypes' => $this->_adyenHelper->getBoletoTypes() 'boletoTypes' => $this->getBoletoAvailableTypes()
] ]
] ]
]; ];
} }
/**
* @return array
*/
protected function getBoletoAvailableTypes()
{
$types = [];
$boletoTypes = $this->_adyenHelper->getBoletoTypes();
$availableTypes = $this->_adyenHelper->getAdyenBoletoConfigData('boletotypes');
if ($availableTypes) {
$availableTypes = explode(',', $availableTypes);
foreach ($boletoTypes as $boletoType) {
if (in_array($boletoType['value'], $availableTypes)) {
$types[] = $boletoType;
}
}
}
return $types;
}
/** /**
* Retrieve request object * Retrieve request object
* *
......
...@@ -3,7 +3,7 @@ Adyen Payment plugin for Magento2. This plugin supports Magento2 version 2.1 and ...@@ -3,7 +3,7 @@ Adyen Payment plugin for Magento2. This plugin supports Magento2 version 2.1 and
For Magento2 version 2.0 support, use plugin version 1.4.6. For Magento2 version 2.0 support, use plugin version 1.4.6.
## Installation ## ## Installation ##
``` ```
bin/composer require adyen/module-payment composer require adyen/module-payment
bin/magento module:enable Adyen_Payment bin/magento module:enable Adyen_Payment
bin/magento setup:upgrade bin/magento setup:upgrade
``` ```
......
...@@ -35,6 +35,7 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -35,6 +35,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
{ {
const ADYEN_ORDER_PAYMENT = 'adyen_order_payment'; const ADYEN_ORDER_PAYMENT = 'adyen_order_payment';
const ADYEN_INVOICE = 'adyen_invoice';
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -63,6 +64,10 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -63,6 +64,10 @@ class UpgradeSchema implements UpgradeSchemaInterface
$this->updateSchemaVersion207($setup); $this->updateSchemaVersion207($setup);
} }
if (version_compare($context->getVersion(), '2.2.1', '<')) {
$this->updateSchemaVersion221($setup);
}
$setup->endSetup(); $setup->endSetup();
} }
...@@ -100,7 +105,7 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -100,7 +105,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
$connection->addColumn($setup->getTable('sales_order_payment'), 'adyen_psp_reference', $pspReferenceColumn); $connection->addColumn($setup->getTable('sales_order_payment'), 'adyen_psp_reference', $pspReferenceColumn);
} }
/** /**
* Upgrade to 1.0.0.2 * Upgrade to 1.0.0.2
* *
...@@ -220,7 +225,7 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -220,7 +225,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
) )
->setComment('Adyen Order Payment'); ->setComment('Adyen Order Payment');
$setup->getConnection()->createTable($table); $setup->getConnection()->createTable($table);
// add originalReference to notification table // add originalReference to notification table
...@@ -231,7 +236,7 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -231,7 +236,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
'length' => 255, 'length' => 255,
'nullable' => true, 'nullable' => true,
'comment' => 'Original Reference', 'comment' => 'Original Reference',
'after' => \Adyen\Payment\Model\Notification::PSPREFRENCE 'after' => \Adyen\Payment\Model\Notification::PSPREFRENCE
]; ];
$connection->addColumn( $connection->addColumn(
...@@ -268,9 +273,9 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -268,9 +273,9 @@ class UpgradeSchema implements UpgradeSchemaInterface
} }
/** /**
* Upgrade to 2.0.7 * Upgrade to 2.0.7
* *
* @param SchemaSetupInterface $setup * @param SchemaSetupInterface $setup
* @return void * @return void
*/ */
...@@ -285,7 +290,7 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -285,7 +290,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
'nullable' => true, 'nullable' => true,
'default' => 0, 'default' => 0,
'comment' => 'Adyen Notification Cron Processing', 'comment' => 'Adyen Notification Cron Processing',
'after' => \Adyen\Payment\Model\Notification::DONE 'after' => \Adyen\Payment\Model\Notification::DONE
]; ];
$connection->addColumn( $connection->addColumn(
...@@ -294,4 +299,59 @@ class UpgradeSchema implements UpgradeSchemaInterface ...@@ -294,4 +299,59 @@ class UpgradeSchema implements UpgradeSchemaInterface
$adyenNotificationProcessingColumn $adyenNotificationProcessingColumn
); );
} }
public function updateSchemaVersion221(SchemaSetupInterface $setup)
{
$table = $setup->getConnection()
->newTable($setup->getTable(self::ADYEN_INVOICE))
->addColumn(
'entity_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Adyen Invoice Entity ID'
)
->addColumn(
'pspreference',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['unsigned' => true, 'nullable' => false],
'Adyen pspreference of the capture'
)
->addColumn(
'original_reference',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['unsigned' => true, 'nullable' => true],
'Adyen OriginalReference of the payment'
)
->addColumn('acquirer_reference',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['unsigned' => true, 'nullable' => true],
'Adyen AcquirerReference of the capture')
->addColumn(
'invoice_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
11,
['unsigned' => true, 'nullable' => false],
'Invoice Id'
)
->addForeignKey(
$setup->getFkName(
self::ADYEN_INVOICE,
'invoice_id',
'sales_invoice',
'entity_id'
),
'invoice_id',
$setup->getTable('sales_invoice'),
'entity_id',
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Adyen Invoice');
$setup->getConnection()->createTable($table);
}
} }
\ No newline at end of file
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
namespace Adyen\Payment\Tests\Helper; namespace Adyen\Payment\Tests\Helper;
use Adyen\Payment\Helper\Data; class DataTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;
class DataTest extends TestCase
{ {
/**
* @var \Adyen\Payment\Helper\Data
*/
private $dataHelper; private $dataHelper;
private function getSimpleMock($originalClassName) private function getSimpleMock($originalClassName)
...@@ -39,24 +39,35 @@ class DataTest extends TestCase ...@@ -39,24 +39,35 @@ class DataTest extends TestCase
public function setUp() public function setUp()
{ {
$context = $this->getSimpleMock('\Magento\Framework\App\Helper\Context'); $context = $this->getSimpleMock(\Magento\Framework\App\Helper\Context::class);
$encryptor = $this->getSimpleMock('\Magento\Framework\Encryption\EncryptorInterface'); $encryptor = $this->getSimpleMock(\Magento\Framework\Encryption\EncryptorInterface::class);
$dataStorage = $this->getSimpleMock('\Magento\Framework\Config\DataInterface'); $dataStorage = $this->getSimpleMock(\Magento\Framework\Config\DataInterface::class);
$country = $this->getSimpleMock('\Magento\Directory\Model\Config\Source\Country'); $country = $this->getSimpleMock(\Magento\Directory\Model\Config\Source\Country::class);
$moduleList = $this->getSimpleMock('\Magento\Framework\Module\ModuleListInterface'); $moduleList = $this->getSimpleMock(\Magento\Framework\Module\ModuleListInterface::class);
$billingAgreementCollectionFactory = $this->getSimpleMock('\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory'); $billingAgreementCollectionFactory = $this->getSimpleMock(\Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory::class);
$assetRepo = $this->getSimpleMock('\Magento\Framework\View\Asset\Repository'); $assetRepo = $this->getSimpleMock(\Magento\Framework\View\Asset\Repository::class);
$assetSource = $this->getSimpleMock('\Magento\Framework\View\Asset\Source'); $assetSource = $this->getSimpleMock(\Magento\Framework\View\Asset\Source::class);
$notificationFactory = $this->getSimpleMock('\Adyen\Payment\Model\Resource\Notification\CollectionFactory'); $notificationFactory = $this->getSimpleMock(\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory::class);
$this->dataHelper = new Data($context, $encryptor, $dataStorage, $country, $moduleList, $this->dataHelper = new \Adyen\Payment\Helper\Data($context, $encryptor, $dataStorage, $country, $moduleList,
$billingAgreementCollectionFactory, $assetRepo, $assetSource, $notificationFactory); $billingAgreementCollectionFactory, $assetRepo, $assetSource, $notificationFactory);
} }
public function testFormatAmount() public function testFormatAmount()
{ {
$this->assertEquals("1234", $this->dataHelper->formatAmount("12.34", "EUR")); $this->assertEquals('1234', $this->dataHelper->formatAmount('12.34', 'EUR'));
$this->assertEquals("1200", $this->dataHelper->formatAmount("12.00", "USD")); $this->assertEquals('1200', $this->dataHelper->formatAmount('12.00', 'USD'));
$this->assertEquals("12", $this->dataHelper->formatAmount("12.00", "JPY")); $this->assertEquals('12', $this->dataHelper->formatAmount('12.00', 'JPY'));
}
public function testisPaymentMethodOpenInvoiceMethod()
{
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('klarna'));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('klarna_account'));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('afterpay'));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('afterpay_default'));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('ratepay'));
$this->assertEquals(false, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('ideal'));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod('test_klarna'));
} }
} }
...@@ -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.2.0", "version": "2.3.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
"adyen/php-api-library": "*", "adyen/php-api-library": "*",
"magento/framework": ">=100.1.0" "magento/framework": ">=100.1.0"
}, },
"require-dev": {
"phpunit/phpunit": "~5"
},
"autoload": { "autoload": {
"files": [ "files": [
"registration.php" "registration.php"
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<type name="Magento\Framework\Notification\MessageList"> <type name="Magento\Framework\Notification\MessageList">
<arguments> <arguments>
<argument name="messages" xsi:type="array"> <argument name="messages" xsi:type="array">
<item name="cronMessage" xsi:type="string">Adyen\Payment\AdminMessage\CronMessage</item> <item name="AdyenCronMessage" xsi:type="string">Adyen\Payment\AdminMessage\CronMessage</item>
<item name="AdyenVersionMessage" xsi:type="string">Adyen\Payment\AdminMessage\VersionMessage</item>
</argument> </argument>
</arguments> </arguments>
</type> </type>
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
</field> </field>
<field id="cctypes" translate="label" type="multiselect" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="cctypes" translate="label" type="multiselect" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Boleto Types</label> <label>Boleto Types</label>
<depends><field id="active">1</field></depends>
<validate>validate-no-empty</validate>
<source_model>Adyen\Payment\Model\Config\Source\BoletoType</source_model> <source_model>Adyen\Payment\Model\Config\Source\BoletoType</source_model>
<config_path>payment/adyen_boleto/boletotypes</config_path> <config_path>payment/adyen_boleto/boletotypes</config_path>
</field> </field>
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
<source_model>Adyen\Payment\Model\Config\Source\RenderMode</source_model> <source_model>Adyen\Payment\Model\Config\Source\RenderMode</source_model>
<config_path>payment/adyen_abstract/title_renderer</config_path> <config_path>payment/adyen_abstract/title_renderer</config_path>
</field> </field>
<field id="return_path" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Checkout Return Path</label>
<config_path>payment/adyen_abstract/return_path</config_path>
<tooltip><![CDATA[The path the customer will be redirected to when payment was <b>not</b> successful. Default is <i>checkout/cart</i>.]]></tooltip>
</field>
</group> </group>
</include> </include>
\ No newline at end of file
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<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>
<group id="adyen_hpp_openinvoice_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="100"> <group id="adyen_hpp_openinvoice_settings" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="100">
<label>Klarna\RatePay\Afterpay Settings</label> <label>Klarna\RatePay\Afterpay Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model> <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="show_gender" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="show_gender" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<config_path>payment/adyen_hpp/ratepay_id</config_path> <config_path>payment/adyen_hpp/ratepay_id</config_path>
</field> </field>
</group> </group>
<group id="adyen_hpp_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200"> <group id="adyen_hpp_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="200">
<label>Advanced Settings</label> <label>Advanced Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model> <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="title" translate="label" type="text" sortOrder="65" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="title" translate="label" type="text" sortOrder="65" showInDefault="1" showInWebsite="1" showInStore="1">
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<config_path>payment/adyen_hpp/country_code</config_path> <config_path>payment/adyen_hpp/country_code</config_path>
</field> </field>
</group> </group>
<group id="adyen_hpp_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210"> <group id="adyen_hpp_country_specific" translate="label" showInDefault="1" showInWebsite="1" showInStore="0" sortOrder="210">
<label>Country Specific Settings</label> <label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model> <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model> <source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model>
<config_path>payment/adyen_pos/recurring_type</config_path> <config_path>payment/adyen_pos/recurring_type</config_path>
</field> </field>
<group id="adyen_pos_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200"> <group id="adyen_pos_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="200">
<label>Advanced Settings</label> <label>Advanced Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model> <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="add_receipt_order_lines" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="add_receipt_order_lines" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<title_renderer>title_image</title_renderer> <title_renderer>title_image</title_renderer>
<sepa_flow>sale</sepa_flow> <sepa_flow>sale</sepa_flow>
<split_payments_refund_strategy>1</split_payments_refund_strategy> <split_payments_refund_strategy>1</split_payments_refund_strategy>
<return_path>checkout/cart</return_path>
<group>adyen</group> <group>adyen</group>
</adyen_abstract> </adyen_abstract>
<adyen_cc> <adyen_cc>
......
...@@ -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.2.0"> <module name="Adyen_Payment" setup_version="2.3.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"Select your Bank","Select your Bank" "Select your Bank","Select your Bank"
"You will be redirected to the Adyen website.","You will be redirected to the Adyen website." "You will be redirected to the Adyen website.","You will be redirected to the Adyen website."
"Update","Update" "Update","Update"
"Place order","Place order" "Place Order","Place Order"
"Continue to Adyen","Continue to Adyen" "Continue to Adyen","Continue to Adyen"
"Unknown","Unknown" "Unknown","Unknown"
"Mismatch between Live/Test modes of Magento store and the Adyen platform","Mismatch between Live/Test modes of Magento store and the Adyen platform" "Mismatch between Live/Test modes of Magento store and the Adyen platform","Mismatch between Live/Test modes of Magento store and the Adyen platform"
......
"Name on Card","Naam op kaart"
"Credit Card Information","Creditcard gegevens"
"Credit Card Type","Creditcard type"
"Credit Card Number","Creditcard Number"
"Credit Card Owner","Creditcardnummer"
"Expiration Date","Verloopdatum"
"Card Verification Number","Creditcard Verificatie Nummer"
"--Please Select--","--Selecteer--"
"What is this?","Wat is dit?"
"Remember these details","Onthoud deze details"
"Select Your Bank","Selecteer uw bank"
"You will be redirected to the Adyen website.","U wordt doorverwezen naar de Adyen-website."
"Update","Bijwerken"
"Place Order","Plaats bestelling"
"Continue to Adyen","Doorgaan naar Adyen"
"Unknown","Onbekend"
"Mismatch between Live/Test modes of Magento store and the Adyen platform","Niet-overeenstemming tussen Live / Test-modi van Magento-winkel en het Adyen-platform"
"You have cancelled the order. Please try again","U hebt de bestelling geannuleerd Probeer het opnieuw"
"Your payment failed, Please try again later","Uw betaling is mislukt. Probeer het later opnieuw"
"Response is empty, please check your webserver that the result url accepts parameters","Reactie is leeg, controleer uw webserver dat de resultaat-URL parameters accepteert"
"ResultUrl authentification failure","ResultUrl authenticatie fout "
"Order does not exists with increment_id: %1","Bestelling bestaat niet met increment_id: %1"
"Empty merchantReference","Lege verkoperReferentie"
"3D-secure validation was successful","3D-beveiligde validatie was succesvol"
"3D-secure validation was unsuccessful.","3D-beveiligde validatie was niet succesvol."
"Customer was redirected to bank for 3D-secure validation.","Klant is doorgestuurd naar bank voor 3D-beveiligde validatie."
"Used existing billing agreement #%s.","Gebruikte bestaande factureringsovereenkomst #%s."
"Created billing agreement #%1.","Factureringsovereenkomst gemaakt #%1."
"Failed to create billing agreement for this order.","Kan geen factuurovereenkomst voor deze bestelling maken."
"Failed to create billing agreement for this order (listRecurringCall did not contain contract)","Kan geen factuurovereenkomst voor deze bestelling maken (listRecurringCall bevat geen contract)"
"Adyen Refund Successfully completed","Adyen Refund succesvol afgerond"
"Payment is pre authorised waiting for capture","De betaling wordt vooraf geautoriseerd om te wachten op opname"
"Capture Mode set to Manual","Capture Mode ingesteld op Manual"
"Adyen Payment is in Manual Review check the Adyen platform","Adyen Payment is in Manual Review, controleer het Adyen-platform"
"Adyen Payment Successfully completed","Adyen-betaling succesvol afgerond"
"Shipment created by Adyen","Verzending gemaakt door Adyen"
"3D secure failed","3D-beveiligd is mislukt"
"The capture action failed","De opnameactie is mislukt"
"The refund action failed","De actie voor teruggave is mislukt"
"Failed to disable this contract","Kan dit contract niet uitschakelen"
"Card encryption failed","Kaartversleuteling mislukt"
"The authorize action is not available.","De autorisatie-actie is niet beschikbaar."
"Empty result.","Leeg resultaat."
"3D secure is not valid","3D Secure is niet geldig"
"The transaction is not permitted.","De transactie is niet toegestaan."
"Declined due to the Card Security Code(CVC) being incorrect. Please check your CVC code!","Afgewezen vanwege de Card Security Code(CVC) onjuist zijn. Controleer alstublieft uw CVC code!"
"The card is restricted.","De kaart is beperkt."
"The payment is REFUSED because the saved card is removed. Please try an other payment method.","De betaling wordt GEWEIGERD omdat de opgeslagen kaart is verwijderd. Probeer een andere betaalmethode."
"The expiry month is not set. Please check your expiry month!","De vervalmaand is niet ingesteld. Controleer alstublieft uw verloopmaand!"
"The payment is REFUSED","De betaling is GEWEIGERD"
"Failed to disable this contract","Kan dit contract niet uitschakelen"
"You will be redirected to the Adyen App", "U wordt doorgestuurd naar de Adyen-app"
"Continue to Adyen App", "Doorgaan naar Adyen-app"
"Do not use Installments", "Gebruik geen wederkerende betalingen"
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Adyen payment module tests">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2018 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="payment_additional_info">
<block class="Adyen\Payment\Block\Info\PaymentLink" name="adyen_paymentlink" template="Adyen_Payment::info/adyen_paymentlink.phtml" />
</referenceContainer>
</body>
</page>
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2018 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
/** @var \Adyen\Payment\Block\Info\PaymentLink $block */
?>
<br />
<div class="admin__page-section-item-title">
<span class="title"><?php echo __('Adyen Payment Link');?></span>
</div>
<p id="paymentlink"></p>
<a href="<?=$block->getPaymentLinkUrl();?>" onclick="copyToClipboard(event, '<?=$block->getPaymentLinkUrl();?>')" style="cursor:pointer;">
<?php echo __('Copy payment link to clipboard'); ?>
</a>
<script type="text/javascript">
function copyToClipboard(e, text) {
e.preventDefault();
var $temp = jQuery("<input>");
jQuery("body").append($temp);
$temp.val(text).select();
document.execCommand("copy");
$temp.remove();
}
</script>
...@@ -61,6 +61,9 @@ ...@@ -61,6 +61,9 @@
<item name="adyen_boleto" xsi:type="array"> <item name="adyen_boleto" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item> </item>
<item name="adyen_pos" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
<item name="adyen_apple_pay" xsi:type="array"> <item name="adyen_apple_pay" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item> </item>
......
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
background-position: 0 -272px; background-position: 0 -272px;
} }
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_boleto {
background-position: 0 -2092px;
}
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_apple_pay { .checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_apple_pay {
background:url(../images/logos/apple_pay.png) no-repeat; background:url(../images/logos/apple_pay.png) no-repeat;
height:43px; height:43px;
......
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
define(
[
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'mage/url',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader'
],
function (quote, urlBuilder, storage, url, errorProcessor, customer, fullScreenLoader) {
'use strict';
return function (paymentData, redirectOnSuccess) {
var serviceUrl,
payload;
//redirectOnSuccess = redirectOnSuccess !== false;
redirectOnSuccess = redirectOnSuccess === false ? false : true;
/** Checkout for guest and registered customer. */
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
quoteId: quote.getQuoteId()
});
payload = {
cartId: quote.getQuoteId(),
email: quote.guestEmail,
paymentMethod: paymentData,
billingAddress: quote.billingAddress()
};
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/payment-information', {});
payload = {
cartId: quote.getQuoteId(),
paymentMethod: paymentData,
billingAddress: quote.billingAddress()
};
}
fullScreenLoader.startLoader();
return storage.post(
serviceUrl, JSON.stringify(payload)
).done(
function (response) {
if (redirectOnSuccess) {
window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
} else{
fullScreenLoader.stopLoader();
}
}
).fail(
function (response) {
errorProcessor.process(response);
fullScreenLoader.stopLoader();
}
);
};
}
);
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
define(
[
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_CheckoutAgreements/js/model/agreements-assigner'
],
function ($, quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader, agreementsAssigner) {
'use strict';
return function () {
var serviceUrl,
payload,
paymentData = quote.paymentMethod();
// use core code to assign the agreement
agreementsAssigner(paymentData);
/** Checkout for guest and registered customer. */
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
quoteId: quote.getQuoteId()
});
payload = {
cartId: quote.getQuoteId(),
email: quote.guestEmail,
paymentMethod: paymentData,
billingAddress: quote.billingAddress()
};
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/payment-information', {});
payload = {
cartId: quote.getQuoteId(),
paymentMethod: paymentData,
billingAddress: quote.billingAddress()
};
}
fullScreenLoader.startLoader();
return storage.post(
serviceUrl, JSON.stringify(payload)
).done(
function () {
$.mage.redirect(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl);
}
).fail(
function (response) {
errorProcessor.process(response);
fullScreenLoader.stopLoader();
}
);
};
}
);
...@@ -19,19 +19,14 @@ ...@@ -19,19 +19,14 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'underscore', 'underscore',
'jquery', 'jquery',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form'
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
], ],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) { function (_, $, quote, Component) {
'use strict'; 'use strict';
var billingAddress = quote.billingAddress(); var billingAddress = quote.billingAddress();
return Component.extend({ return Component.extend({
...@@ -51,16 +46,16 @@ define( ...@@ -51,16 +46,16 @@ define(
]); ]);
return this; return this;
}, },
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
}, },
setValidateHandler: function(handler) { setValidateHandler: function (handler) {
this.validateHandler = handler; this.validateHandler = handler;
}, },
getCode: function() { getCode: function () {
return 'adyen_boleto'; return 'adyen_boleto';
}, },
getData: function() { getData: function () {
return { return {
'method': this.item.method, 'method': this.item.method,
'additional_data': { 'additional_data': {
...@@ -71,56 +66,34 @@ define( ...@@ -71,56 +66,34 @@ define(
} }
}; };
}, },
isActive: function() { isActive: function () {
return true; return true;
}, },
/** getControllerName: function () {
* @override
*/
placeOrder: function(data, event) {
var self = this,
placeOrder;
if (event) {
event.preventDefault();
}
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(response) {
self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
},
getControllerName: function() {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
}, },
getPlaceOrderUrl: function() { getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()]; return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
}, },
context: function() { context: function () {
return this; return this;
}, },
validate: function () { validate: function () {
var form = 'form[data-role=adyen-boleto-form]'; var form = 'form[data-role=adyen-boleto-form]';
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) { if (!validate) {
return false; return false;
} }
return true; return true;
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
getBoletoTypes: function() { getBoletoTypes: function () {
return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function(value, key) { return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function (value, key) {
return { return {
'key': value.value, 'key': value.value,
'value': value.label 'value': value.label
......
...@@ -19,23 +19,19 @@ ...@@ -19,23 +19,19 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'underscore',
'jquery', 'jquery',
'ko',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Customer/js/model/customer', 'Magento_Customer/js/model/customer',
'Magento_Payment/js/model/credit-card-validation/credit-card-data', 'Magento_Payment/js/model/credit-card-validation/credit-card-data',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'ko',
'Adyen_Payment/js/model/installments', 'Adyen_Payment/js/model/installments',
'mage/url'
], ],
function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, creditCardData, quote, ko, installments) { function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url) {
'use strict'; 'use strict';
var cvcLength = ko.observable(4); var cvcLength = ko.observable(4);
...@@ -156,43 +152,63 @@ define( ...@@ -156,43 +152,63 @@ define(
isActive: function () { isActive: function () {
return true; return true;
}, },
/**
* Returns state of place order button
* @returns {boolean}
*/
isButtonActive: function() {
return this.isActive() && this.getCode() == this.isChecked() && this.isPlaceOrderActionAllowed();
},
/** /**
* @override * @override
*/ */
placeOrder: function (data, event) { placeOrder: function (data, event) {
var self = this, var self = this;
placeOrder;
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
} }
var options = {}; var options = {};
var cseInstance = adyen.createEncryption(options); var cseInstance = adyen.createEncryption(options);
var generationtime = self.getGenerationTime(); var generationtime = this.getGenerationTime();
var cardData = { var cardData = {
number: self.creditCardNumber(), number: this.creditCardNumber(),
cvc: self.creditCardVerificationNumber(), cvc: this.creditCardVerificationNumber(),
holderName: self.creditCardOwner(), holderName: this.creditCardOwner(),
expiryMonth: self.creditCardExpMonth(), expiryMonth: this.creditCardExpMonth(),
expiryYear: self.creditCardExpYear(), expiryYear: this.creditCardExpYear(),
generationtime: generationtime generationtime: generationtime
}; };
var data = cseInstance.encrypt(cardData); var data = cseInstance.encrypt(cardData);
self.encryptedData(data); this.encryptedData(data);
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false); this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function (response) { this.getPlaceOrderDeferredObject()
self.isPlaceOrderActionAllowed(true); .fail(
}); function () {
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.afterPlaceOrder();
if (self.redirectAfterPlaceOrder) {
// use custom redirect Link for supporting 3D secure
window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
}
}
);
return true; return true;
} }
return false; return false;
}, },
getControllerName: function () { getControllerName: function () {
......
...@@ -19,14 +19,11 @@ ...@@ -19,14 +19,11 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'ko', 'ko',
'jquery', 'jquery',
'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/view/payment/default',
'Adyen_Payment/js/action/set-payment-method',
'Magento_Checkout/js/action/select-payment-method', 'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/checkout-data', 'Magento_Checkout/js/checkout-data',
...@@ -35,14 +32,17 @@ define( ...@@ -35,14 +32,17 @@ 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',
'Magento_Checkout/js/action/place-order',
'uiLayout',
'Magento_Ui/js/model/messages'
], ],
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader) { function (ko, $, Component, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, placeOrderAction, layout, Messages) {
'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); var dfValue = ko.observable(null);
var messageComponents;
return Component.extend({ return Component.extend({
self: this, self: this,
defaults: { defaults: {
...@@ -128,6 +128,27 @@ define( ...@@ -128,6 +128,27 @@ define(
document.body.appendChild(dfScriptTag); document.body.appendChild(dfScriptTag);
waitForDfSet(); waitForDfSet();
// create component needs to be in initialize method
var messageComponents = {};
_.map(response, function (value) {
var messageContainer = new Messages();
var name = 'messages-' + value.brandCode;
var messagesComponent = {
parent: self.name,
name: 'messages-' + value.brandCode,
displayArea: 'messages-' + value.brandCode,
component: 'Magento_Ui/js/view/messages',
config: {
messageContainer: messageContainer
}
};
layout([messagesComponent]);
messageComponents[name] = messageContainer;
});
self.messageComponents = messageComponents;
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
} }
).fail(function (error) { ).fail(function (error) {
...@@ -150,6 +171,15 @@ define( ...@@ -150,6 +171,15 @@ define(
result.validate = function () { result.validate = function () {
return self.validate(value.brandCode); return self.validate(value.brandCode);
}; };
result.placeRedirectOrder = function placeRedirectOrder(data) {
return self.placeRedirectOrder(data);
};
result.isPlaceOrderActionAllowed = function(bool) {
return self.isPlaceOrderActionAllowed(bool);
};
result.afterPlaceOrder = function() {
return self.afterPlaceOrder();
};
result.isPaymentMethodOpenInvoiceMethod = function () { result.isPaymentMethodOpenInvoiceMethod = function () {
return value.isPaymentMethodOpenInvoiceMethod; return value.isPaymentMethodOpenInvoiceMethod;
}; };
...@@ -212,10 +242,12 @@ define( ...@@ -212,10 +242,12 @@ define(
}, },
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
var self = this;
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
//update payment method information if additional data was changed var data = {};
this.selectPaymentMethod(); data.method = self.method;
setPaymentMethodAction(); this.placeRedirectOrder(data);
return false; return false;
} }
}, },
...@@ -246,9 +278,7 @@ define( ...@@ -246,9 +278,7 @@ define(
} }
data.additional_data = additionalData; data.additional_data = additionalData;
this.placeRedirectOrder(data);
selectPaymentMethodAction(data);
setPaymentMethodAction();
} }
return false; return false;
...@@ -276,6 +306,32 @@ define( ...@@ -276,6 +306,32 @@ define(
return true; return true;
}, },
placeRedirectOrder: function(data) {
// Place Order but use our own redirect url after
var self = this;
var messageContainer = this.messageContainer;
if(brandCode()) {
messageContainer = self.messageComponents['messages-' + brandCode()];
}
this.isPlaceOrderActionAllowed(false);
fullScreenLoader.startLoader();
$.when(
placeOrderAction(data, messageContainer)
).fail(
function () {
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.afterPlaceOrder();
$.mage.redirect(
window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl
);
}
)
},
isBrandCodeChecked: ko.computed(function () { isBrandCodeChecked: ko.computed(function () {
if (!quote.paymentMethod()) { if (!quote.paymentMethod()) {
......
...@@ -19,42 +19,53 @@ ...@@ -19,42 +19,53 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'ko', 'jquery',
'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/view/payment/default',
'Adyen_Payment/js/action/set-payment-method', 'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/payment/additional-validators' 'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/place-order',
'Magento_Checkout/js/model/quote'
], ],
function (ko, Component, setPaymentMethodAction, additionalValidators) { function ($, Component, additionalValidators, fullScreenLoader, placeOrderAction, quote) {
'use strict'; 'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
return Component.extend({ return Component.extend({
self: this,
defaults: { defaults: {
template: 'Adyen_Payment/payment/pos-form', template: 'Adyen_Payment/payment/pos-form'
brandCode: ''
}, },
initObservable: function () { initObservable: function () {
this._super() this._super()
.observe([ .observe([]);
]);
return this; return this;
}, },
/** Redirect to adyen */ /** Redirect to adyen */
continueToAdyen: function () { continueToAdyen: function () {
var self = this;
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
//update payment method information if additional data was changed //update payment method information if additional data was changed
this.selectPaymentMethod(); this.isPlaceOrderActionAllowed(false);
setPaymentMethodAction(); fullScreenLoader.startLoader();
return false;
$.when(
placeOrderAction(this.getData(), this.messageContainer)
).fail(
function () {
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.afterPlaceOrder();
$.mage.redirect(
window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl
);
}
);
} }
return false;
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
validate: function () { validate: function () {
......
...@@ -19,19 +19,14 @@ ...@@ -19,19 +19,14 @@
* *
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
/*browser:true*/
/*global define*/
define( define(
[ [
'underscore', 'underscore',
'jquery', 'jquery',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form'
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
], ],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) { function (_, $, quote, Component) {
'use strict'; 'use strict';
var billingAddress = quote.billingAddress(); var billingAddress = quote.billingAddress();
return Component.extend({ return Component.extend({
...@@ -56,16 +51,16 @@ define( ...@@ -56,16 +51,16 @@ define(
isShowLegend: function () { isShowLegend: function () {
return true; return true;
}, },
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
}, },
setValidateHandler: function(handler) { setValidateHandler: function (handler) {
this.validateHandler = handler; this.validateHandler = handler;
}, },
getCode: function() { getCode: function () {
return 'adyen_sepa'; return 'adyen_sepa';
}, },
getData: function() { getData: function () {
return { return {
'method': this.item.method, 'method': this.item.method,
'additional_data': { 'additional_data': {
...@@ -76,56 +71,34 @@ define( ...@@ -76,56 +71,34 @@ define(
} }
}; };
}, },
isActive: function() { isActive: function () {
return true; return true;
}, },
/** getControllerName: function () {
* @override
*/
placeOrder: function(data, event) {
var self = this,
placeOrder;
if (event) {
event.preventDefault();
}
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(response) {
self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
},
getControllerName: function() {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
}, },
getPlaceOrderUrl: function() { getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()]; return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
}, },
context: function() { context: function () {
return this; return this;
}, },
validate: function () { validate: function () {
var form = 'form[data-role=adyen-sepa-form]'; var form = 'form[data-role=adyen-sepa-form]';
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) { if (!validate) {
return false; return false;
} }
return true; return true;
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
getCountries: function() { getCountries: function () {
return _.map(window.checkoutConfig.payment.adyenSepa.countries, function(value, key) { return _.map(window.checkoutConfig.payment.adyenSepa.countries, function (value, key) {
return { return {
'key': key, 'key': key,
'value': value 'value': value
......
...@@ -55,6 +55,10 @@ ...@@ -55,6 +55,10 @@
'orderSaveUrl':getPlaceOrderUrl(), 'orderSaveUrl':getPlaceOrderUrl(),
}, 'validation':[]}"> }, 'validation':[]}">
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<fieldset data-bind="attr: {class: 'fieldset payment items adyen_boleto ' + getCode(), id: 'payment_form_' + getCode()}"> <fieldset data-bind="attr: {class: 'fieldset payment items adyen_boleto ' + getCode(), id: 'payment_form_' + getCode()}">
<!-- ko if: (isShowLegend())--> <!-- ko if: (isShowLegend())-->
...@@ -80,6 +84,8 @@ ...@@ -80,6 +84,8 @@
</div> </div>
</div> </div>
<!-- ko if: getBoletoTypes().length > 1-->
<div class="field boleto_type type required"> <div class="field boleto_type type required">
<label data-bind="attr: {for: getCode() + '_boleto_type'}" class="label"> <label data-bind="attr: {for: getCode() + '_boleto_type'}" class="label">
<span><!-- ko text: $t('Boleto Card Type')--><!-- /ko --></span> <span><!-- ko text: $t('Boleto Card Type')--><!-- /ko --></span>
...@@ -99,7 +105,7 @@ ...@@ -99,7 +105,7 @@
</div> </div>
</div> </div>
<!--/ko-->
<div class="field firstname type required"> <div class="field firstname type required">
<label data-bind="attr: {for: getCode() + 'firstname'}" class="label"> <label data-bind="attr: {for: getCode() + 'firstname'}" class="label">
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
</div> </div>
<div class="payment-method-content"> <div class="payment-method-content">
<div class="payment-method-billing-address"> <div class="payment-method-billing-address">
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) --> <!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
...@@ -53,6 +54,11 @@ ...@@ -53,6 +54,11 @@
}, 'validation':[]}"> }, 'validation':[]}">
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<fieldset <fieldset
data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + getCode()}"> data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + getCode()}">
<!-- ko if: (isShowLegend())--> <!-- ko if: (isShowLegend())-->
...@@ -268,16 +274,15 @@ ...@@ -268,16 +274,15 @@
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
</div> </div>
<div class="actions-toolbar"> <div class="actions-toolbar">
<div class="primary"> <div class="primary">
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind=" data-bind="click: placeOrder,
click: placeOrder,
attr: {title: $t('Place Order')}, attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()), enable: isButtonActive()"
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled> disabled>
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
......
...@@ -97,13 +97,17 @@ ...@@ -97,13 +97,17 @@
<div class="control"> <div class="control">
<input type="text" class="input-text" <input type="text" class="input-text"
name="payment[dob]" name="payment[dob]"
data-bind=" datepicker: { storage: datepickerValue, options: { showOn: 'both', changeYear: true, yearRange: '-99:-1', defaultDate: '-20y' } }, data-bind="
attr: { attr: {
id: getCode() + '_dob_' + value, id: getCode() + '_dob_' + value,
title: $t('Date of Birth'), title: $t('Date of Birth'),
'data-container': getCode() + '-dob' 'data-container': getCode() + '-dob_' + value,
}, },
value: dob" datepicker: {
storage: datepickerValue,
options: { showOn: 'both', changeYear: true, yearRange: '-99:-1', defaultDate: '-20y' }
},
value: dob"
data-validate="{required:true}" data-validate="{required:true}"
/> />
</div> </div>
...@@ -170,7 +174,7 @@ ...@@ -170,7 +174,7 @@
type="submit" type="submit"
data-bind="click: $parent.continueToAdyenBrandCode, enable: (value == $parent.isBrandCodeChecked())" data-bind="click: $parent.continueToAdyenBrandCode, enable: (value == $parent.isBrandCodeChecked())"
disabled> disabled>
<span data-bind="text: $t('Place order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
</div> </div>
</div> </div>
......
...@@ -23,9 +23,11 @@ ...@@ -23,9 +23,11 @@
--> -->
<!-- ko foreach: getAdyenBillingAgreements() -->
<!-- ko foreach: getAdyenBillingAgreements() -->
<div class="payment-method" data-bind="css: {'_active': (value == $parent.isBillingAgreementChecked())}"> <div class="payment-method" data-bind="css: {'_active': (value == $parent.isBillingAgreementChecked())}">
<div class="payment-method-title field choice"> <div class="payment-method-title field choice">
<input type="radio" <input type="radio"
name="payment[method]" name="payment[method]"
...@@ -50,12 +52,18 @@ ...@@ -50,12 +52,18 @@
</div> </div>
<div class="payment-method-content"> <div class="payment-method-content">
<!-- ko foreach: $parent.getRegion(getMessageName()) -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<div class="payment-method-billing-address"> <div class="payment-method-billing-address">
<!-- ko foreach: $parents[1].getRegion($parent.getBillingAddressFormName()) --> <!-- ko foreach: $parents[1].getRegion($parent.getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
</div> </div>
<form class="form" action="#" method="post" data-bind=" <form class="form" action="#" method="post" data-bind="
attr: {'id': 'adyen_oneclick_' + value, 'data-role': 'adyen_oneclick_' + value }, attr: {'id': 'adyen_oneclick_' + value, 'data-role': 'adyen_oneclick_' + value },
mageInit: { mageInit: {
...@@ -221,9 +229,6 @@ ...@@ -221,9 +229,6 @@
<!-- /ko --> <!-- /ko -->
</fieldset> </fieldset>
<div class="checkout-agreements-block"> <div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') --> <!-- ko foreach: $parents[1].getRegion('before-place-order') -->
...@@ -235,7 +240,7 @@ ...@@ -235,7 +240,7 @@
<button class="action primary checkout" <button class="action primary checkout"
type="submit" type="submit"
data-bind=" data-bind="
click: $parent.placeOrder, click: placeOrder,
attr: {title: $t('Place Order')}, attr: {title: $t('Place Order')},
enable: (value == $parent.isBillingAgreementChecked()) enable: (value == $parent.isBillingAgreementChecked())
" "
......
...@@ -45,6 +45,11 @@ ...@@ -45,6 +45,11 @@
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
</div> </div>
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<fieldset class="fieldset" data-bind='attr: {id: "payment_form_" + getCode()}'> <fieldset class="fieldset" data-bind='attr: {id: "payment_form_" + getCode()}'>
<div class="payment-method-note"> <div class="payment-method-note">
<!-- ko text: $t('You will be redirected to the Adyen App.') --><!-- /ko --> <!-- ko text: $t('You will be redirected to the Adyen App.') --><!-- /ko -->
......
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
<!--/ko--> <!--/ko-->
</div> </div>
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<form class="form" id="adyen-sepa-form" data-role="adyen-sepa-form" action="#" method="post" data-bind="mageInit: { <form class="form" id="adyen-sepa-form" data-role="adyen-sepa-form" action="#" method="post" data-bind="mageInit: {
'transparent':{ 'transparent':{
......
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