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 2b56d0b6 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

Merge pull request #416 from Adyen/develop

Release 4.0.0
parents 17482425 c84a4038
...@@ -33,7 +33,7 @@ class Cctypes extends \Magento\Framework\View\Element\Html\Select ...@@ -33,7 +33,7 @@ class Cctypes extends \Magento\Framework\View\Element\Html\Select
protected $ccTypes = []; protected $ccTypes = [];
/** /**
* @var \Magento\Braintree\Model\Source\CcType * @var \Adyen\Payment\Model\Config\Source\CcType
*/ */
protected $ccTypeSource; protected $ccTypeSource;
......
...@@ -31,8 +31,9 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA ...@@ -31,8 +31,9 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
*/ */
protected $_installmentRenderer = null; protected $_installmentRenderer = null;
/** /**
* @var \Magento\Braintree\Block\Adminhtml\Form\Field\CcTypes * @var \Adyen\Payment\Block\Adminhtml\System\Config\Field\Cctypes
*/ */
protected $_ccTypesRenderer = null; protected $_ccTypesRenderer = null;
...@@ -57,7 +58,8 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA ...@@ -57,7 +58,8 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
/** /**
* Returns renderer for country element * Returns renderer for country element
* *
* @return \Magento\Braintree\Block\Adminhtml\Form\Field\Cctypes * @return \Magento\Framework\View\Element\BlockInterface|null
* @throws \Magento\Framework\Exception\LocalizedException
*/ */
protected function getCcTypesRenderer() protected function getCcTypesRenderer()
{ {
...@@ -106,7 +108,7 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA ...@@ -106,7 +108,7 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
* Prepare existing row data object * Prepare existing row data object
* *
* @param \Magento\Framework\DataObject $row * @param \Magento\Framework\DataObject $row
* @return void * @throws \Magento\Framework\Exception\LocalizedException
*/ */
protected function _prepareArrayRow(\Magento\Framework\DataObject $row) protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
{ {
...@@ -127,6 +129,5 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA ...@@ -127,6 +129,5 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
} }
} }
$row->setData('option_extra_attrs', $options); $row->setData('option_extra_attrs', $options);
return;
} }
} }
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Block\Customer;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Adyen\Payment\Helper\Data;
use Magento\Framework\View\Element\Template;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Block\AbstractCardRenderer;
use Magento\Payment\Model\CcConfigProvider;
class CardRenderer extends AbstractCardRenderer
{
/**
* @var Data
*/
protected $adyenHelper;
public function __construct(
Template\Context $context,
CcConfigProvider $iconsProvider,
array $data,
Data $adyenHelper
) {
parent::__construct($context, $iconsProvider, $data);
$this->adyenHelper = $adyenHelper;
}
/**
* Can render specified token
*
* @param PaymentTokenInterface $token
* @return boolean
*/
public function canRender(PaymentTokenInterface $token)
{
return $token->getPaymentMethodCode() === AdyenCcConfigProvider::CODE;
}
/**
* @return string
*/
public function getNumberLast4Digits()
{
return $this->getTokenDetails()['maskedCC'];
}
/**
* @return string
*/
public function getExpDate()
{
return $this->getTokenDetails()['expirationDate'];
}
/**
* @return string
*/
public function getIconUrl()
{
return $this->adyenHelper->getVariantIcon($this->getTokenDetails()['type'])['url'];
}
/**
* @return int
*/
public function getIconHeight()
{
return $this->adyenHelper->getVariantIcon($this->getTokenDetails()['type'])['height'];
}
/**
* @return int
*/
public function getIconWidth()
{
return $this->adyenHelper->getVariantIcon($this->getTokenDetails()['type'])['width'];
}
}
\ No newline at end of file
...@@ -194,7 +194,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -194,7 +194,7 @@ class Redirect extends \Magento\Payment\Block\Form
$this->_order->getGrandTotal(), $this->_order->getGrandTotal(),
$orderCurrencyCode $orderCurrencyCode
); );
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account')); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $this->_order->getStoreId()));
$shopperEmail = $this->_order->getCustomerEmail(); $shopperEmail = $this->_order->getCustomerEmail();
$customerId = $this->_order->getCustomerId(); $customerId = $this->_order->getCustomerId();
$shopperIP = $this->_order->getRemoteIp(); $shopperIP = $this->_order->getRemoteIp();
......
...@@ -84,7 +84,6 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -84,7 +84,6 @@ class Json extends \Magento\Framework\App\Action\Action
*/ */
public function execute() public function execute()
{ {
// if version is in the notification string show the module version // if version is in the notification string show the module version
$response = $this->getRequest()->getParams(); $response = $this->getRequest()->getParams();
if (isset($response['version'])) { if (isset($response['version'])) {
...@@ -99,14 +98,10 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -99,14 +98,10 @@ class Json extends \Magento\Framework\App\Action\Action
try { try {
$notificationItems = json_decode(file_get_contents('php://input'), true); $notificationItems = json_decode(file_get_contents('php://input'), true);
// log the notification
$this->_adyenLogger->addAdyenNotification(
"The content of the notification is: " . print_r($notificationItems, 1)
);
$notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : ""; $notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : "";
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'], $notificationItem['NotificationRequestItem'],
...@@ -178,6 +173,12 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -178,6 +173,12 @@ class Json extends \Magento\Framework\App\Action\Action
{ {
// validate the notification // validate the notification
if ($this->authorised($response)) { if ($this->authorised($response)) {
// log the notification
$this->_adyenLogger->addAdyenNotification(
"The content of the notification item is: " . print_r($response, 1)
);
// check if notification already exists // check if notification already exists
if (!$this->_isDuplicate($response)) { if (!$this->_isDuplicate($response)) {
try { try {
......
This diff is collapsed.
...@@ -67,9 +67,6 @@ class CcAuthorizationDataBuilder implements BuilderInterface ...@@ -67,9 +67,6 @@ class CcAuthorizationDataBuilder implements BuilderInterface
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail // If ccType is set use this. For bcmc you need bcmc otherwise it will fail
$request['paymentMethod']['type'] = "scheme"; $request['paymentMethod']['type'] = "scheme";
if ($variant = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::VARIANT)) {
$request['paymentMethod']['type'] = $variant;
}
if ($cardNumber = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER)) { if ($cardNumber = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER)) {
$request['paymentMethod']['encryptedCardNumber'] = $cardNumber; $request['paymentMethod']['encryptedCardNumber'] = $cardNumber;
......
...@@ -42,17 +42,26 @@ class CustomerDataBuilder implements BuilderInterface ...@@ -42,17 +42,26 @@ class CustomerDataBuilder 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);
$order = $paymentDataObject->getOrder(); $order = $paymentDataObject->getOrder();
$billingAddress = $order->getBillingAddress();
$customerEmail = $billingAddress->getEmail();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
if ($customerId > 0) { if ($customerId > 0) {
$result['shopperReference'] = $customerId; $result['shopperReference'] = $customerId;
} }
$result ['shopperEmail'] = $customerEmail; $billingAddress = $order->getBillingAddress();
if (!empty($billingAddress)) {
$customerEmail = $billingAddress->getEmail();
if ($customerEmail) {
$result['shopperEmail'] = $customerEmail;
}
$customerTelephone = trim($billingAddress->getTelephone());
if ($customerTelephone) {
$result['telephoneNumber'] = $customerTelephone;
}
}
return $result; return $result;
} }
......
...@@ -55,6 +55,18 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface ...@@ -55,6 +55,18 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail
$request['paymentMethod']['type'] = "scheme";
if ($variant = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::VARIANT)) {
$request['paymentMethod']['type'] = $variant;
}
if ($securityCode = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::ENCRYPTED_SECURITY_CODE)) {
$request['paymentMethod']['encryptedSecurityCode'] = $securityCode;
}
$payment->unsAdditionalInformation(AdyenOneclickDataAssignObserver::ENCRYPTED_SECURITY_CODE);
if ($payment->getAdditionalInformation('customer_interaction')) { if ($payment->getAdditionalInformation('customer_interaction')) {
$shopperInteraction = "Ecommerce"; $shopperInteraction = "Ecommerce";
} else { } else {
...@@ -79,6 +91,11 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface ...@@ -79,6 +91,11 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface
} }
} }
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0) {
$request['installments']['value'] = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS);
}
return $request; return $request;
} }
} }
...@@ -61,32 +61,35 @@ class RecurringDataBuilder implements BuilderInterface ...@@ -61,32 +61,35 @@ class RecurringDataBuilder implements BuilderInterface
{ {
$result = []; $result = [];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ // If the vault feature is on this logic is handled in the VaultDataBuilder
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
$payment = $paymentDataObject->getPayment(); /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$storeId = null; $storeId = null;
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$storeId = $payment->getOrder()->getStoreId(); $storeId = $payment->getOrder()->getStoreId();
} }
$enableOneclick = $this->adyenHelper->getAdyenAbstractConfigData('enable_oneclick', $storeId); $enableOneclick = $this->adyenHelper->getAdyenAbstractConfigData('enable_oneclick', $storeId);
$enableRecurring = $this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', $storeId); $enableRecurring = $this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', $storeId);
if ($enableOneclick) { if ($enableOneclick) {
$result['enableOneClick'] = true; $result['enableOneClick'] = true;
} else { } else {
$result['enableOneClick'] = false; $result['enableOneClick'] = false;
} }
if ($enableRecurring) { if ($enableRecurring) {
$result['enableRecurring'] = true; $result['enableRecurring'] = true;
} else { } else {
$result['enableRecurring'] = false; $result['enableRecurring'] = false;
} }
if ($payment->getAdditionalInformation('store_cc') === '1') { if ($payment->getAdditionalInformation('store_cc') === '1') {
$result['paymentMethod']['storeDetails'] = true; $result['paymentMethod']['storeDetails'] = true;
}
} }
return $result; return $result;
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
class RecurringVaultDataBuilder implements BuilderInterface
{
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
$result = [];
$recurring = ['contract' => \Adyen\Payment\Model\RecurringType::RECURRING];
$result['recurring'] = $recurring;
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$extensionAttributes = $payment->getExtensionAttributes();
$paymentToken = $extensionAttributes->getVaultPaymentToken();
$result['selectedRecurringDetailReference'] = $paymentToken->getGatewayToken();
$result['shopperInteraction'] = 'ContAuth';
return $result;
}
}
\ No newline at end of file
...@@ -191,7 +191,7 @@ class RefundDataBuilder implements BuilderInterface ...@@ -191,7 +191,7 @@ class RefundDataBuilder implements BuilderInterface
foreach ($creditMemo->getAllItems() as $refundItem) { foreach ($creditMemo->getAllItems() as $refundItem) {
++$count; ++$count;
$numberOfItems = $refundItem->getQty(); $numberOfItems = (int)$refundItem->getQty();
$formFields = $this->adyenHelper->createOpenInvoiceLineItem( $formFields = $this->adyenHelper->createOpenInvoiceLineItem(
$formFields, $formFields,
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Vault\Model\Ui\VaultConfigProvider;
use \Magento\Payment\Gateway\Helper\SubjectReader;
class VaultDataBuilder implements BuilderInterface
{
/**
* Recurring variable
* @var string
*/
private static $enableRecurring = 'enableRecurring';
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
// vault is enabled and shopper provided consent to store card this logic is triggered
$request = [];
$paymentDO = SubjectReader::readPayment($buildSubject);
$payment = $paymentDO->getPayment();
$data = $payment->getAdditionalInformation();
if (!empty($data[VaultConfigProvider::IS_ACTIVE_CODE]) &&
$data[VaultConfigProvider::IS_ACTIVE_CODE] === true
) {
// store it only as oneclick otherwise we store oneclick tokens (maestro+bcmc) that will fail
$request[self::$enableRecurring] = true;
} else {
// explicity turn this off as merchants have recurring on by default
$request[self::$enableRecurring] = false;
}
return $request;
}
}
\ No newline at end of file
...@@ -65,7 +65,8 @@ class CheckoutPaymentsDetailsHandler implements HandlerInterface ...@@ -65,7 +65,8 @@ class CheckoutPaymentsDetailsHandler implements HandlerInterface
$payment->setTransactionId($response['pspReference']); $payment->setTransactionId($response['pspReference']);
} }
if (!empty($response['additionalData']['recurring.recurringDetailReference']) if (!empty($response['additionalData']['recurring.recurringDetailReference']) &&
!$this->adyenHelper->isCreditCardVaultEnabled()
) { ) {
$order = $payment->getOrder(); $order = $payment->getOrder();
......
...@@ -105,7 +105,10 @@ class PaymentPosCloudHandler implements HandlerInterface ...@@ -105,7 +105,10 @@ class PaymentPosCloudHandler implements HandlerInterface
$additionalData['paymentMethod'] = $brand; $additionalData['paymentMethod'] = $brand;
$additionalData['recurring.recurringDetailReference'] = $recurringDetailReference; $additionalData['recurring.recurringDetailReference'] = $recurringDetailReference;
$additionalData['pos_payment'] = true; $additionalData['pos_payment'] = true;
$this->adyenHelper->createAdyenBillingAgreement($payment->getOrder(), $additionalData);
if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
$this->adyenHelper->createAdyenBillingAgreement($payment->getOrder(), $additionalData);
}
} }
} }
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Response;
use Magento\Vault\Api\Data\PaymentTokenFactoryInterface;
use Magento\Payment\Gateway\Response\HandlerInterface;
use Magento\Payment\Model\InfoInterface;
class VaultDetailsHandler implements HandlerInterface
{
/**
* @var PaymentTokenInterfaceFactory
*/
protected $paymentTokenFactory;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $_adyenLogger;
/**
* VaultDetailsHandler constructor.
*
* @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
PaymentTokenFactoryInterface $paymentTokenFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->_adyenLogger = $adyenLogger;
$this->paymentTokenFactory = $paymentTokenFactory;
}
/**
* @inheritdoc
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
// add vault payment token entity to extension attributes
$paymentToken = $this->getVaultPaymentToken($response);
if (null !== $paymentToken) {
$extensionAttributes = $this->getExtensionAttributes($payment);
$extensionAttributes->setVaultPaymentToken($paymentToken);
}
}
/**
* Get vault payment token entity
*
* @param array $response
* @return PaymentTokenInterface|null
*/
private function getVaultPaymentToken(array $response)
{
$paymentToken = null;
if (!empty($response['additionalData'])) {
$additionalData = $response['additionalData'];
if (empty($additionalData['recurring.recurringDetailReference'])) {
$this->_adyenLogger->error(
'Missing Token in Result please enable in ' .
'Settings -> API URLs and Response menu in the Adyen Customer Area Recurring details setting'
);
return null;
}
$token = $additionalData['recurring.recurringDetailReference'];
if (empty($additionalData['cardSummary'])) {
$this->_adyenLogger->error(
'Missing cardSummary in Result please login to the adyen portal ' .
'and go to Settings -> API URLs and Response and enable the Card summary property'
);
return null;
}
$cardSummary = $additionalData['cardSummary'];
if (empty($additionalData['expiryDate'])) {
$this->_adyenLogger->error(
'Missing expiryDate in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Expiry date property'
);
return null;
}
$expirationDate = $additionalData['expiryDate'];
if (empty($additionalData['paymentMethod'])) {
$this->_adyenLogger->error(
'Missing paymentMethod in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Variant property'
);
return null;
}
$cardType = $additionalData['paymentMethod'];
try {
/** @var PaymentTokenInterface $paymentToken */
$paymentToken = $this->paymentTokenFactory->create(
PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD
);
$paymentToken->setGatewayToken($token);
$paymentToken->setExpiresAt($this->getExpirationDate($expirationDate));
$details = [
'type' => $cardType,
'maskedCC' => $cardSummary,
'expirationDate' => $expirationDate
];
$paymentToken->setTokenDetails(json_encode($details));
} catch (\Exception $e) {
$this->_adyenLogger->error(print_r($e, true));
}
}
return $paymentToken;
}
/**
* @param $expirationDate
* @return string
* @throws \Exception
*/
private function getExpirationDate($expirationDate)
{
$expirationDate = explode('/', $expirationDate);
//add leading zero to month
$month = sprintf('%02d', $expirationDate[0]);
$expDate = new \DateTime(
$expirationDate[1]
. '-'
. $month
. '-'
. '01'
. ' '
. '00:00:00',
new \DateTimeZone('UTC')
);
// add one month
$expDate->add(new \DateInterval('P1M'));
return $expDate->format('Y-m-d 00:00:00');
}
/**
* Get payment extension attributes
* @param InfoInterface $payment
* @return OrderPaymentExtensionInterface
*/
private function getExtensionAttributes(InfoInterface $payment)
{
$extensionAttributes = $payment->getExtensionAttributes();
if (null === $extensionAttributes) {
$extensionAttributes = $this->paymentExtensionFactory->create();
$payment->setExtensionAttributes($extensionAttributes);
}
return $extensionAttributes;
}
}
\ No newline at end of file
...@@ -177,7 +177,7 @@ class Data extends AbstractHelper ...@@ -177,7 +177,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc return recurring types for configuration setting * return recurring types for configuration setting
* @return array * @return array
*/ */
public function getRecurringTypes() public function getRecurringTypes()
...@@ -190,7 +190,7 @@ class Data extends AbstractHelper ...@@ -190,7 +190,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc return recurring types for configuration setting * return recurring types for configuration setting
* @return array * @return array
*/ */
public function getModes() public function getModes()
...@@ -202,7 +202,7 @@ class Data extends AbstractHelper ...@@ -202,7 +202,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc return recurring types for configuration setting * eturn recurring types for configuration setting
* @return array * @return array
*/ */
public function getCaptureModes() public function getCaptureModes()
...@@ -214,7 +214,7 @@ class Data extends AbstractHelper ...@@ -214,7 +214,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc return recurring types for configuration setting * return recurring types for configuration setting
* @return array * @return array
*/ */
public function getPaymentRoutines() public function getPaymentRoutines()
...@@ -373,7 +373,8 @@ class Data extends AbstractHelper ...@@ -373,7 +373,8 @@ class Data extends AbstractHelper
/** /**
* @desc gives back global configuration values * gives back global configuration values
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -384,7 +385,8 @@ class Data extends AbstractHelper ...@@ -384,7 +385,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc gives back global configuration values as boolean * gives back global configuration values as boolean
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -395,7 +397,8 @@ class Data extends AbstractHelper ...@@ -395,7 +397,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_cc configuration values * Gives back adyen_cc configuration values
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -406,7 +409,8 @@ class Data extends AbstractHelper ...@@ -406,7 +409,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_cc configuration values as flag * Gives back adyen_cc configuration values as flag
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -417,7 +421,20 @@ class Data extends AbstractHelper ...@@ -417,7 +421,20 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_hpp configuration values * Gives back adyen_cc configuration values as flag
*
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenCcVaultConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_cc_vault', $storeId, true);
}
/**
* Gives back adyen_hpp configuration values
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -428,7 +445,8 @@ class Data extends AbstractHelper ...@@ -428,7 +445,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_hpp configuration values as flag * Gives back adyen_hpp configuration values as flag
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -439,7 +457,8 @@ class Data extends AbstractHelper ...@@ -439,7 +457,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_oneclick configuration values * Gives back adyen_oneclick configuration values
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -450,7 +469,8 @@ class Data extends AbstractHelper ...@@ -450,7 +469,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_oneclick configuration values as flag * Gives back adyen_oneclick configuration values as flag
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -481,7 +501,8 @@ class Data extends AbstractHelper ...@@ -481,7 +501,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_pay_by_mail configuration values * Gives back adyen_pay_by_mail configuration values
*
* @param $field * @param $field
* @param int|null $storeId * @param int|null $storeId
* @return mixed * @return mixed
...@@ -492,7 +513,8 @@ class Data extends AbstractHelper ...@@ -492,7 +513,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_pay_by_mail configuration values as flag * Gives back adyen_pay_by_mail configuration values as flag
*
* @param $field * @param $field
* @param int|null $storeId * @param int|null $storeId
* @return mixed * @return mixed
...@@ -503,7 +525,8 @@ class Data extends AbstractHelper ...@@ -503,7 +525,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_boleto configuration values * Gives back adyen_boleto configuration values
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -514,7 +537,8 @@ class Data extends AbstractHelper ...@@ -514,7 +537,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_boleto configuration values as flag * Gives back adyen_boleto configuration values as flag
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -525,7 +549,8 @@ class Data extends AbstractHelper ...@@ -525,7 +549,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Gives back adyen_apple_pay configuration values * Gives back adyen_apple_pay configuration values
*
* @param $field * @param $field
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -564,7 +589,8 @@ class Data extends AbstractHelper ...@@ -564,7 +589,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Retrieve decrypted hmac key * Retrieve decrypted hmac key
*
* @return string * @return string
*/ */
public function getHmac() public function getHmac()
...@@ -594,7 +620,7 @@ class Data extends AbstractHelper ...@@ -594,7 +620,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Check if configuration is set to demo mode * Check if configuration is set to demo mode
* *
* @param int|null $storeId * @param int|null $storeId
* @return mixed * @return mixed
...@@ -605,7 +631,8 @@ class Data extends AbstractHelper ...@@ -605,7 +631,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Retrieve the decrypted notification password * Retrieve the decrypted notification password
*
* @return string * @return string
*/ */
public function getNotificationPassword() public function getNotificationPassword()
...@@ -614,7 +641,7 @@ class Data extends AbstractHelper ...@@ -614,7 +641,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Retrieve the API key * Retrieve the API key
* *
* @param int|null $storeId * @param int|null $storeId
* @return string * @return string
...@@ -632,7 +659,7 @@ class Data extends AbstractHelper ...@@ -632,7 +659,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Retrieve the webserver username * Retrieve the webserver username
* *
* @param int|null $storeId * @param int|null $storeId
* @return string * @return string
...@@ -648,7 +675,7 @@ class Data extends AbstractHelper ...@@ -648,7 +675,7 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Retrieve the Live endpoint prefix key * Retrieve the Live endpoint prefix key
* *
* @param int|null $storeId * @param int|null $storeId
* @return string * @return string
...@@ -660,7 +687,8 @@ class Data extends AbstractHelper ...@@ -660,7 +687,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Cancels the order * Cancels the order
*
* @param $order * @param $order
*/ */
public function cancelOrder($order) public function cancelOrder($order)
...@@ -722,7 +750,8 @@ class Data extends AbstractHelper ...@@ -722,7 +750,8 @@ class Data extends AbstractHelper
} }
/** /**
* @desc Retrieve information from payment configuration * Retrieve information from payment configuration
*
* @param $field * @param $field
* @param $paymentMethodCode * @param $paymentMethodCode
* @param $storeId * @param $storeId
...@@ -943,7 +972,8 @@ class Data extends AbstractHelper ...@@ -943,7 +972,8 @@ class Data extends AbstractHelper
return $billingAgreements; return $billingAgreements;
} }
public function isPerStoreBillingAgreement($storeId) { public function isPerStoreBillingAgreement($storeId)
{
return !$this->getAdyenOneclickConfigDataFlag('share_billing_agreement', $storeId); return !$this->getAdyenOneclickConfigDataFlag('share_billing_agreement', $storeId);
} }
...@@ -1313,7 +1343,9 @@ class Data extends AbstractHelper ...@@ -1313,7 +1343,9 @@ class Data extends AbstractHelper
public function initializeAdyenClient($storeId = null, $apiKey = null) public function initializeAdyenClient($storeId = null, $apiKey = null)
{ {
// initialize client // initialize client
$apiKey = $this->getAPIKey($storeId); if (empty($apiKey)) {
$apiKey = $this->getAPIKey($storeId);
}
$client = $this->createAdyenClient(); $client = $this->createAdyenClient();
$client->setApplicationName("Magento 2 plugin"); $client->setApplicationName("Magento 2 plugin");
...@@ -1393,16 +1425,15 @@ class Data extends AbstractHelper ...@@ -1393,16 +1425,15 @@ class Data extends AbstractHelper
); );
$client = $this->initializeAdyenClient($storeId); $client = $this->initializeAdyenClient($storeId);
try { try {
$service = $this->createAdyenCheckoutUtilityService($client); $service = $this->createAdyenCheckoutUtilityService($client);
$response = $service->originKeys($params); $response = $service->originKeys($params);
} } catch (\Exception $e) {
catch(\Exception $e){
$this->adyenLogger->error($e->getMessage()); $this->adyenLogger->error($e->getMessage());
} }
$originKey = ""; $originKey = "";
if (!empty($response['originKeys'][$url])) { if (!empty($response['originKeys'][$url])) {
$originKey = $response['originKeys'][$url]; $originKey = $response['originKeys'][$url];
...@@ -1494,7 +1525,8 @@ class Data extends AbstractHelper ...@@ -1494,7 +1525,8 @@ class Data extends AbstractHelper
// add to order to save agreement // add to order to save agreement
$order->addRelatedObject($billingAgreement); $order->addRelatedObject($billingAgreement);
} else { } else {
$message = __('Failed to create billing agreement for this order. Reason(s): ') . join(', ', $billingAgreement->getErrors()); $message = __('Failed to create billing agreement for this order. Reason(s): ') . join(', ',
$billingAgreement->getErrors());
throw new \Exception($message); throw new \Exception($message);
} }
...@@ -1514,7 +1546,8 @@ class Data extends AbstractHelper ...@@ -1514,7 +1546,8 @@ class Data extends AbstractHelper
* @param \Magento\Sales\Model\Order $order * @param \Magento\Sales\Model\Order $order
* @return int|null * @return int|null
*/ */
public function getCustomerId(\Magento\Sales\Model\Order $order) { public function getCustomerId(\Magento\Sales\Model\Order $order)
{
return $order->getCustomerId(); return $order->getCustomerId();
} }
...@@ -1539,4 +1572,35 @@ class Data extends AbstractHelper ...@@ -1539,4 +1572,35 @@ class Data extends AbstractHelper
return \Adyen\Payment\Model\RecurringType::NONE; return \Adyen\Payment\Model\RecurringType::NONE;
} }
} }
/**
* Get icon from variant
*
* @param $variant
* @return array
*/
public function getVariantIcon($variant)
{
$asset = $this->createAsset(sprintf("Adyen_Payment::images/logos/%s_small.png", $variant));
list($width, $height) = getimagesize($asset->getSourceFile());
$icon = [
'url' => $asset->getUrl(),
'width' => $width,
'height' => $height
];
return $icon;
}
/**
* Check if CreditCard vault is enabled
*
* @param int|null $storeId
* @return mixed
*/
public function isCreditCardVaultEnabled($storeId = null)
{
return $this->getAdyenCcVaultConfigDataFlag('active', $storeId);
}
} }
...@@ -191,7 +191,7 @@ class PaymentMethods extends AbstractHelper ...@@ -191,7 +191,7 @@ class PaymentMethods extends AbstractHelper
protected function _fetchHppMethods($store, $country) protected function _fetchHppMethods($store, $country)
{ {
$skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code'); $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code');
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account'); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $store->getId());
if (!$skinCode || !$merchantAccount) { if (!$skinCode || !$merchantAccount) {
return []; return [];
......
...@@ -101,26 +101,24 @@ class PaymentRequest extends DataObject ...@@ -101,26 +101,24 @@ class PaymentRequest extends DataObject
$md = $payment->getAdditionalInformation('md'); $md = $payment->getAdditionalInformation('md');
$paResponse = $payment->getAdditionalInformation('paResponse'); $paResponse = $payment->getAdditionalInformation('paResponse');
$paymentData = $payment->getAdditionalInformation('paymentData'); $paymentData = $payment->getAdditionalInformation('paymentData');
$request = [ $request = [
"paymentData" => $paymentData, "paymentData" => $paymentData,
"details" => [ "details" => [
"MD" => $md, "MD" => $md,
"PaRes" => $paResponse "PaRes" => $paResponse
] ]
]; ];
try { try {
$client = $this->_adyenHelper->initializeAdyenClient($storeId); $client = $this->_adyenHelper->initializeAdyenClient($storeId);
$service = new \Adyen\Service\Checkout($client); $service = new \Adyen\Service\Checkout($client);
$result = $service->paymentsDetails($request); $result = $service->paymentsDetails($request);
} catch(\Adyen\AdyenException $e) { } catch (\Adyen\AdyenException $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed')); throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed'));
} }
$this->_adyenHelper->createAdyenBillingAgreement($order, $result['additionalData']);
return $result; return $result;
} }
...@@ -183,8 +181,8 @@ class PaymentRequest extends DataObject ...@@ -183,8 +181,8 @@ class PaymentRequest extends DataObject
// rest call to get list of recurring details // rest call to get list of recurring details
$contract = ['contract' => $recurringType]; $contract = ['contract' => $recurringType];
$request = [ $request = [
"merchantAccount" => $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId), "merchantAccount" => $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId),
"shopperReference" => $shopperReference, "shopperReference" => $shopperReference,
"recurring" => $contract, "recurring" => $contract,
]; ];
......
...@@ -56,7 +56,7 @@ class CcType extends \Magento\Payment\Model\Source\Cctype ...@@ -56,7 +56,7 @@ class CcType extends \Magento\Payment\Model\Source\Cctype
*/ */
public function getAllowedTypes() public function getAllowedTypes()
{ {
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN', 'BCMC', 'HIPERCARD','ELO','AURA']; return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN', 'BCMC', 'HIPERCARD','ELO', 'TROY'];
} }
/** /**
......
This diff is collapsed.
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 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\InstantPurchase\CreditCard;
use Magento\InstantPurchase\PaymentMethodIntegration\AvailabilityCheckerInterface;
/**
* Availability of Adyen vaults for instant purchase.
*/
class AvailabilityChecker implements AvailabilityCheckerInterface
{
/**
* @inheritdoc
*/
public function isAvailable(): bool
{
return true;
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 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\InstantPurchase\CreditCard;
use Magento\InstantPurchase\PaymentMethodIntegration\PaymentTokenFormatterInterface;
use Magento\Vault\Api\Data\PaymentTokenInterface;
/**
* Adyen stored credit card formatter.
*/
class TokenFormatter implements PaymentTokenFormatterInterface
{
/**
* Most used credit card types
* @var array
*/
public static $baseCardTypes = [
'AE' => 'American Express',
'VI' => 'Visa',
'MC' => 'MasterCard',
'DI' => 'Discover',
'JBC' => 'JBC',
'CUP' => 'China Union Pay',
'MI' => 'Maestro',
];
/**
* @inheritdoc
*/
public function formatPaymentToken(PaymentTokenInterface $paymentToken): string
{
$details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
if (!isset($details['type'], $details['maskedCC'], $details['expirationDate'])) {
throw new \InvalidArgumentException('Invalid Adyen credit card token details.');
}
if (isset(self::$baseCardTypes[$details['type']])) {
$ccType = self::$baseCardTypes[$details['type']];
} else {
$ccType = $details['type'];
}
$formatted = sprintf(
'%s: %s, %s: %s (%s: %s)',
__('Credit Card'),
$ccType,
__('ending'),
$details['maskedCC'],
__('expires'),
$details['expirationDate']
);
return $formatted;
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2017 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\Ui\Adminhtml;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Adyen\Payment\Helper\Data;
use Magento\Framework\View\Element\Template;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Model\Ui\TokenUiComponentInterfaceFactory;
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
{
/**
* @var TokenUiComponentInterfaceFactory
*/
private $componentFactory;
/**
* @var Data
*/
private $adyenHelper;
/**
* TokenUiComponentProvider constructor.
*
* @param TokenUiComponentInterfaceFactory $componentFactory
* @param Data $adyenHelper
*/
public function __construct(
TokenUiComponentInterfaceFactory $componentFactory,
Data $adyenHelper
) {
$this->componentFactory = $componentFactory;
$this->adyenHelper = $adyenHelper;
}
/**
* @inheritdoc
*/
public function getComponentForToken(PaymentTokenInterface $paymentToken)
{
$details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
$details['icon'] = $this->adyenHelper->getVariantIcon($details['type']);
$component = $this->componentFactory->create(
[
'config' => [
'code' => AdyenCcConfigProvider::CC_VAULT_CODE,
TokenUiComponentProviderInterface::COMPONENT_DETAILS => $details,
TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
'template' => 'Adyen_Payment::form/vault.phtml'
],
'name' => Template::class
]
);
return $component;
}
}
\ No newline at end of file
...@@ -30,6 +30,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -30,6 +30,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
const CODE = 'adyen_cc'; const CODE = 'adyen_cc';
const CC_VAULT_CODE = 'adyen_cc_vault';
/** /**
* @var PaymentHelper * @var PaymentHelper
*/ */
...@@ -62,30 +64,30 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -62,30 +64,30 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
*/ */
private $ccConfig; private $ccConfig;
/** /**
* @var \Magento\Store\Model\StoreManagerInterface * @var \Magento\Store\Model\StoreManagerInterface
*/ */
private $storeManager; private $storeManager;
/** /**
* AdyenCcConfigProvider constructor. * AdyenCcConfigProvider constructor.
* *
* @param \Magento\Payment\Helper\Data $paymentHelper * @param \Magento\Payment\Helper\Data $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Framework\View\Asset\Source $assetSource * @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Payment\Model\CcConfig $ccConfig * @param \Magento\Payment\Model\CcConfig $ccConfig
*/ */
public function __construct( public function __construct(
\Magento\Payment\Helper\Data $paymentHelper, \Magento\Payment\Helper\Data $paymentHelper,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\View\Asset\Source $assetSource, \Magento\Framework\View\Asset\Source $assetSource,
\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Payment\Model\CcConfig $ccConfig \Magento\Payment\Model\CcConfig $ccConfig
) { ) {
$this->_paymentHelper = $paymentHelper; $this->_paymentHelper = $paymentHelper;
...@@ -94,7 +96,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -94,7 +96,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$this->_urlBuilder = $urlBuilder; $this->_urlBuilder = $urlBuilder;
$this->_assetSource = $assetSource; $this->_assetSource = $assetSource;
$this->ccConfig = $ccConfig; $this->ccConfig = $ccConfig;
$this->storeManager = $storeManager; $this->storeManager = $storeManager;
} }
/** /**
...@@ -106,6 +108,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -106,6 +108,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$config = [ $config = [
'payment' => [ 'payment' => [
self::CODE => [ self::CODE => [
'vaultCode' => self::CC_VAULT_CODE,
'isActive' => true, 'isActive' => true,
'redirectUrl' => $this->_urlBuilder->getUrl( 'redirectUrl' => $this->_urlBuilder->getUrl(
'adyen/process/validate3d/', 'adyen/process/validate3d/',
...@@ -120,8 +123,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -120,8 +123,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$config = array_merge_recursive($config, [ $config = array_merge_recursive($config, [
'payment' => [ 'payment' => [
'ccform' => [ 'ccform' => [
'availableTypes' => [$methodCode => $this->getCcAvailableTypes($methodCode)], 'availableTypes' => [$methodCode => $this->getCcAvailableTypes()],
'availableTypesByAlt' => [$methodCode => $this->getCcAvailableTypesByAlt($methodCode)], 'availableTypesByAlt' => [$methodCode => $this->getCcAvailableTypesByAlt()],
'months' => [$methodCode => $this->getCcMonths()], 'months' => [$methodCode => $this->getCcMonths()],
'years' => [$methodCode => $this->getCcYears()], 'years' => [$methodCode => $this->getCcYears()],
'hasVerification' => [$methodCode => $this->hasVerification($methodCode)], 'hasVerification' => [$methodCode => $this->hasVerification($methodCode)],
...@@ -137,15 +140,15 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -137,15 +140,15 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$canCreateBillingAgreement = true; $canCreateBillingAgreement = true;
} }
$config['payment']['adyenCc']['methodCode'] = self::CODE; $config['payment']['adyenCc']['methodCode'] = self::CODE;
$config['payment']['adyenCc']['locale'] = $this->_adyenHelper->getStoreLocale($this->storeManager->getStore()->getId()); $config['payment']['adyenCc']['locale'] = $this->_adyenHelper->getStoreLocale($this->storeManager->getStore()->getId());
$config['payment']['adyenCc']['canCreateBillingAgreement'] = $canCreateBillingAgreement; $config['payment']['adyenCc']['canCreateBillingAgreement'] = $canCreateBillingAgreement;
$config['payment']['adyenCc']['icons'] = $this->getIcons(); $config['payment']['adyenCc']['icons'] = $this->getIcons();
$config['payment']['adyenCc']['originKey'] = $this->_adyenHelper->getOriginKeyForBaseUrl(); $config['payment']['adyenCc']['originKey'] = $this->_adyenHelper->getOriginKeyForBaseUrl();
$config['payment']['adyenCc']['checkoutUrl'] = $this->_adyenHelper->getCheckoutContextUrl($this->storeManager->getStore()->getId()); $config['payment']['adyenCc']['checkoutUrl'] = $this->_adyenHelper->getCheckoutContextUrl($this->storeManager->getStore()->getId());
// has installments by default false // has installments by default false
$config['payment']['adyenCc']['hasInstallments'] = false; $config['payment']['adyenCc']['hasInstallments'] = false;
...@@ -167,10 +170,9 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -167,10 +170,9 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
/** /**
* Retrieve availables credit card types * Retrieve availables credit card types
* *
* @param string $methodCode
* @return array * @return array
*/ */
protected function getCcAvailableTypes($methodCode) protected function getCcAvailableTypes()
{ {
$types = []; $types = [];
$ccTypes = $this->_adyenHelper->getAdyenCcTypes(); $ccTypes = $this->_adyenHelper->getAdyenCcTypes();
...@@ -187,28 +189,28 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -187,28 +189,28 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
return $types; return $types;
} }
/** /**
* Retrieve availables credit card type codes by alt code * Retrieve availables credit card type codes by alt code
* *
* @param string $methodCode * @param string $methodCode
* @return array * @return array
*/ */
protected function getCcAvailableTypesByAlt($methodCode) protected function getCcAvailableTypesByAlt()
{ {
$types = []; $types = [];
$ccTypes = $this->_adyenHelper->getAdyenCcTypes(); $ccTypes = $this->_adyenHelper->getAdyenCcTypes();
$availableTypes = $this->_adyenHelper->getAdyenCcConfigData('cctypes'); $availableTypes = $this->_adyenHelper->getAdyenCcConfigData('cctypes');
if ($availableTypes) { if ($availableTypes) {
$availableTypes = explode(',', $availableTypes); $availableTypes = explode(',', $availableTypes);
foreach (array_keys($ccTypes) as $code) { foreach (array_keys($ccTypes) as $code) {
if (in_array($code, $availableTypes)) { if (in_array($code, $availableTypes)) {
$types[$ccTypes[$code]['code_alt']] = $code; $types[$ccTypes[$code]['code_alt']] = $code;
} }
} }
} }
return $types; return $types;
} }
/** /**
* Get icons for available payment methods * Get icons for available payment methods
......
...@@ -35,34 +35,39 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -35,34 +35,39 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
/** /**
* @var PaymentHelper * @var PaymentHelper
*/ */
protected $_paymentHelper; protected $paymentHelper;
/** /**
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
protected $_adyenHelper; protected $adyenHelper;
/** /**
* Request object * Request object
* *
* @var \Magento\Framework\App\RequestInterface * @var \Magento\Framework\App\RequestInterface
*/ */
protected $_request; protected $request;
/** /**
* @var \Magento\Framework\UrlInterface * @var \Magento\Framework\UrlInterface
*/ */
protected $_urlBuilder; protected $urlBuilder;
/** /**
* @var \Magento\Customer\Model\Session * @var \Magento\Customer\Model\Session
*/ */
protected $_customerSession; protected $customerSession;
/** /**
* @var \Magento\Checkout\Model\Session * @var \Magento\Checkout\Model\Session
*/ */
protected $_session; protected $session;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/** /**
* AdyenHppConfigProvider constructor. * AdyenHppConfigProvider constructor.
...@@ -80,14 +85,16 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -80,14 +85,16 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Model\Session $session \Magento\Checkout\Model\Session $session,
\Magento\Store\Model\StoreManagerInterface $storeManager
) { ) {
$this->_paymentHelper = $paymentHelper; $this->paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->_request = $request; $this->request = $request;
$this->_urlBuilder = $urlBuilder; $this->urlBuilder = $urlBuilder;
$this->_customerSession = $customerSession; $this->customerSession = $customerSession;
$this->_session = $session; $this->session = $session;
$this->storeManager = $storeManager;
} }
/** /**
...@@ -102,9 +109,9 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -102,9 +109,9 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
'payment' => [ 'payment' => [
self::CODE => [ self::CODE => [
'isActive' => true, 'isActive' => true,
'redirectUrl' => $this->_urlBuilder->getUrl( 'redirectUrl' => $this->urlBuilder->getUrl(
'adyen/process/redirect', 'adyen/process/redirect',
['_secure' => $this->_getRequest()->isSecure()] ['_secure' => $this->getRequest()->isSecure()]
) )
] ]
] ]
...@@ -114,19 +121,21 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -114,19 +121,21 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$dob = ""; $dob = "";
// get customer // get customer
if ($this->_customerSession->isLoggedIn()) { if ($this->customerSession->isLoggedIn()) {
$gender = \Adyen\Payment\Model\Gender::getAdyenGenderFromMagentoGender( $gender = \Adyen\Payment\Model\Gender::getAdyenGenderFromMagentoGender(
$this->_customerSession->getCustomerData()->getGender() $this->customerSession->getCustomerData()->getGender()
); );
// format to calendar date // format to calendar date
$dob = $this->_customerSession->getCustomerData()->getDob(); $dob = $this->customerSession->getCustomerData()->getDob();
if ($dob) { if ($dob) {
$dob = strtotime($dob); $dob = strtotime($dob);
$dob = date('m/d/Y', $dob); $dob = date('m/d/Y', $dob);
} }
} }
$config['payment']['adyenHpp']['locale'] = $this->adyenHelper->getStoreLocale($this->storeManager->getStore()->getId());
// add to config // add to config
$config['payment'] ['adyenHpp']['gender'] = $gender; $config['payment'] ['adyenHpp']['gender'] = $gender;
$config['payment'] ['adyenHpp']['dob'] = $dob; $config['payment'] ['adyenHpp']['dob'] = $dob;
...@@ -135,16 +144,16 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -135,16 +144,16 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes(); $config['payment'] ['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes();
$paymentMethodSelectionOnAdyen = $paymentMethodSelectionOnAdyen =
$this->_adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen'); $this->adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen');
$config['payment'] ['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen; $config['payment'] ['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen;
$config['payment'] ['adyenHpp']['showGender'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_gender'); $config['payment'] ['adyenHpp']['showGender'] = $this->adyenHelper->getAdyenHppConfigDataFlag('show_gender');
$config['payment'] ['adyenHpp']['showDob'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_dob'); $config['payment'] ['adyenHpp']['showDob'] = $this->adyenHelper->getAdyenHppConfigDataFlag('show_dob');
$config['payment'] ['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag( $config['payment'] ['adyenHpp']['showTelephone'] = $this->adyenHelper->getAdyenHppConfigDataFlag(
'show_telephone' 'show_telephone'
); );
$config['payment'] ['adyenHpp']['ratePayId'] = $this->_adyenHelper->getRatePayId(); $config['payment'] ['adyenHpp']['ratePayId'] = $this->adyenHelper->getRatePayId();
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId() . date('c')); $config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->session->getQuoteId() . date('c'));
$config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI']; $config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI'];
return $config; return $config;
...@@ -155,8 +164,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -155,8 +164,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
* *
* @return \Magento\Framework\App\RequestInterface * @return \Magento\Framework\App\RequestInterface
*/ */
protected function _getRequest() protected function getRequest()
{ {
return $this->_request; return $this->request;
} }
} }
...@@ -72,17 +72,17 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -72,17 +72,17 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
*/ */
private $ccConfig; private $ccConfig;
/** /**
* AdyenOneclickConfigProvider constructor. * AdyenOneclickConfigProvider constructor.
* *
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $session * @param \Magento\Checkout\Model\Session $session
* @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Payment\Model\CcConfig $ccConfig * @param \Magento\Payment\Model\CcConfig $ccConfig
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\RequestInterface $request,
...@@ -103,6 +103,8 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -103,6 +103,8 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
/** /**
* @return array * @return array
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/ */
public function getConfig() public function getConfig()
{ {
...@@ -119,12 +121,20 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -119,12 +121,20 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
] ]
]; ];
// don't show this payment method if vault is enabled
if ($this->_adyenHelper->isCreditCardVaultEnabled()) {
$config['payment']['adyenOneclick']['methodCode'] = self::CODE;
$config['payment'][self::CODE]['isActive'] = false;
return $config;
}
$methodCode = self::CODE; $methodCode = self::CODE;
$config = array_merge_recursive($config, [ $config = array_merge_recursive($config, [
'payment' => [ 'payment' => [
'ccform' => [ 'ccform' => [
'availableTypes' => [$methodCode => $this->getCcAvailableTypes($methodCode)], 'availableTypes' => [$methodCode => $this->getCcAvailableTypes()],
'months' => [$methodCode => $this->getCcMonths()], 'months' => [$methodCode => $this->getCcMonths()],
'years' => [$methodCode => $this->getCcYears()], 'years' => [$methodCode => $this->getCcYears()],
'hasVerification' => [$methodCode => $this->hasVerification($methodCode)], 'hasVerification' => [$methodCode => $this->hasVerification($methodCode)],
...@@ -133,10 +143,10 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -133,10 +143,10 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
] ]
]); ]);
$config['payment']['adyenOneclick']['methodCode'] = self::CODE; $config['payment']['adyenOneclick']['methodCode'] = self::CODE;
$config['payment']['adyenOneclick']['originKey'] = $this->_adyenHelper->getOriginKeyForBaseUrl(); $config['payment']['adyenOneclick']['originKey'] = $this->_adyenHelper->getOriginKeyForBaseUrl();
$config['payment']['adyenOneclick']['checkoutUrl'] = $this->_adyenHelper->getCheckoutContextUrl($this->_storeManager->getStore()->getId()); $config['payment']['adyenOneclick']['checkoutUrl'] = $this->_adyenHelper->getCheckoutContextUrl($this->_storeManager->getStore()->getId());
$config['payment']['adyenOneclick']['locale'] = $this->_adyenHelper->getStoreLocale($this->_storeManager->getStore()->getId()); $config['payment']['adyenOneclick']['locale'] = $this->_adyenHelper->getStoreLocale($this->_storeManager->getStore()->getId());
$enableOneclick = $this->_adyenHelper->getAdyenAbstractConfigData('enable_oneclick'); $enableOneclick = $this->_adyenHelper->getAdyenAbstractConfigData('enable_oneclick');
$canCreateBillingAgreement = false; $canCreateBillingAgreement = false;
...@@ -150,9 +160,9 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -150,9 +160,9 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods(); $config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods();
if ($recurringContractType == \Adyen\Payment\Model\RecurringType::ONECLICK) { if ($recurringContractType == \Adyen\Payment\Model\RecurringType::ONECLICK) {
$config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = true; $config['payment']['adyenOneclick']['hasCustomerInteraction'] = true;
} else { } else {
$config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = false; $config['payment']['adyenOneclick']['hasCustomerInteraction'] = false;
} }
return $config; return $config;
...@@ -201,10 +211,9 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -201,10 +211,9 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
/** /**
* Retrieve availables credit card types * Retrieve availables credit card types
* *
* @param string $methodCode
* @return array * @return array
*/ */
protected function getCcAvailableTypes($methodCode) protected function getCcAvailableTypes()
{ {
$types = []; $types = [];
$ccTypes = $this->_adyenHelper->getAdyenCcTypes(); $ccTypes = $this->_adyenHelper->getAdyenCcTypes();
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\Ui;
use Adyen\Payment\Helper\Data;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Model\Ui\TokenUiComponentInterface;
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
use Magento\Vault\Model\Ui\TokenUiComponentInterfaceFactory;
use Magento\Framework\UrlInterface;
/**
* Class TokenUiComponentProvider
*/
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
{
/**
* @var TokenUiComponentInterfaceFactory
*/
private $componentFactory;
/**
* @var Data
*/
private $adyenHelper;
/**
* @param TokenUiComponentInterfaceFactory $componentFactory
* @param UrlInterface $urlBuilder
*/
public function __construct(
TokenUiComponentInterfaceFactory $componentFactory,
Data $adyenHelper
) {
$this->componentFactory = $componentFactory;
$this->adyenHelper = $adyenHelper;
}
/**
* Get UI component for token
* @param PaymentTokenInterface $paymentToken
* @return TokenUiComponentInterface
*/
public function getComponentForToken(PaymentTokenInterface $paymentToken)
{
$details = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
$details['icon'] = $this->adyenHelper->getVariantIcon($details['type']);
$component = $this->componentFactory->create(
[
'config' => [
'code' => AdyenCcConfigProvider::CC_VAULT_CODE,
TokenUiComponentProviderInterface::COMPONENT_DETAILS => $details,
TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash()
],
'name' => 'Adyen_Payment/js/view/payment/method-renderer/vault'
]
);
return $component;
}
}
\ No newline at end of file
...@@ -34,11 +34,11 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver ...@@ -34,11 +34,11 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
const CC_TYPE = 'cc_type'; const CC_TYPE = 'cc_type';
const NUMBER_OF_INSTALLMENTS = 'number_of_installments'; const NUMBER_OF_INSTALLMENTS = 'number_of_installments';
const STORE_CC = 'store_cc'; const STORE_CC = 'store_cc';
const ENCRYPTED_CREDIT_CARD_NUMBER = 'number'; const ENCRYPTED_CREDIT_CARD_NUMBER = 'number';
const ENCRYPTED_SECURITY_CODE = 'cvc'; const ENCRYPTED_SECURITY_CODE = 'cvc';
const ENCRYPTED_EXPIRY_MONTH = 'expiryMonth'; const ENCRYPTED_EXPIRY_MONTH = 'expiryMonth';
const ENCRYPTED_EXPIRY_YEAR = 'expiryYear'; const ENCRYPTED_EXPIRY_YEAR = 'expiryYear';
const HOLDER_NAME = 'holderName'; const HOLDER_NAME = 'holderName';
const VARIANT = 'variant'; const VARIANT = 'variant';
/** /**
...@@ -48,11 +48,11 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver ...@@ -48,11 +48,11 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
self::CC_TYPE, self::CC_TYPE,
self::NUMBER_OF_INSTALLMENTS, self::NUMBER_OF_INSTALLMENTS,
self::STORE_CC, self::STORE_CC,
self::ENCRYPTED_CREDIT_CARD_NUMBER, self::ENCRYPTED_CREDIT_CARD_NUMBER,
self::ENCRYPTED_SECURITY_CODE, self::ENCRYPTED_SECURITY_CODE,
self::ENCRYPTED_EXPIRY_MONTH, self::ENCRYPTED_EXPIRY_MONTH,
self::ENCRYPTED_EXPIRY_YEAR, self::ENCRYPTED_EXPIRY_YEAR,
self::HOLDER_NAME, self::HOLDER_NAME,
self::VARIANT self::VARIANT
]; ];
...@@ -72,10 +72,12 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver ...@@ -72,10 +72,12 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
$paymentInfo = $this->readPaymentModelArgument($observer); $paymentInfo = $this->readPaymentModelArgument($observer);
// set ccType // set ccType
$paymentInfo->setCcType($additionalData['cc_type']); if (!empty($additionalData['cc_type'])) {
$paymentInfo->setCcType($additionalData['cc_type']);
}
foreach ($this->additionalInformationList as $additionalInformationKey) { foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) { if (!empty($additionalData[$additionalInformationKey])) {
$paymentInfo->setAdditionalInformation( $paymentInfo->setAdditionalInformation(
$additionalInformationKey, $additionalInformationKey,
$additionalData[$additionalInformationKey] $additionalData[$additionalInformationKey]
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Plugin;
use Magento\Vault\Api\Data\PaymentTokenInterface;
class PaymentVaultDeleteToken
{
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected $paymentRequest;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
* PaymentVaultDeleteToken constructor.
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
*/
public function __construct(
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->paymentRequest = $paymentRequest;
$this->storeManager = $storeManager;
}
public function beforeDelete(
\Magento\Vault\Api\PaymentTokenRepositoryInterface $subject,
PaymentTokenInterface $paymentToken
) {
if (strpos($paymentToken->getPaymentMethodCode(), 'adyen_') !== 0) {
return [$paymentToken];
}
try {
$this->paymentRequest->disableRecurringContract(
$paymentToken->getGatewayToken(),
$paymentToken->getCustomerId(),
$this->storeManager->getStore()->getStoreId()
);
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract'));
}
}
}
\ No newline at end of file
# Adyen Payment plugin for Magento2 # Adyen Payment plugin for Magento2
Use Adyen's plugin for Magento 2 to offer frictionless payments online, in-app, and in-store. Use Adyen's plugin for Magento 2 to offer frictionless payments online, in-app, and in-store.
## Integration
The plugin integrates card component(Secured Fields) using Adyen Checkout for all card payments. Local/redirect payment methods are integrated with DirectoryLookup and HPP. For Point Of Sale (POS) payments we use Terminal API using Cloud-based communication. Boleto and SEPA are a direct API integration into Adyen.
### Support Vault and Instant Purchase ###
Inside Adyen toggle the following settings on inside the API and Responses section (settings -> API and Responses)
* Recurring details
* Card summary
* Expiry date
* Variant
## Requirements ## Requirements
This plugin supports Magento2 version 2.1 and higher This plugin supports Magento2 version 2.2 and higher.
## Collaboration ## Collaboration
We commit all our new features directly into our GitHub repository. We commit all our new features directly into our GitHub repository.
......
...@@ -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": "3.0.0", "version": "4.0.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
], ],
"require": { "require": {
"adyen/php-api-library": ">=1.5.3", "adyen/php-api-library": ">=1.5.3",
"magento/framework": ">=100.1.0" "magento/framework": ">=101.0.0",
"magento/module-vault": "101.0.*"
}, },
"autoload": { "autoload": {
"files": [ "files": [
......
...@@ -9,4 +9,11 @@ ...@@ -9,4 +9,11 @@
</argument> </argument>
</arguments> </arguments>
</type> </type>
<type name="Magento\Vault\Model\Ui\Adminhtml\TokensConfigProvider">
<arguments>
<argument name="tokenUiComponentProviders" xsi:type="array">
<item name="adyen_cc" xsi:type="object">Adyen\Payment\Model\Ui\Adminhtml\TokenUiComponentProvider</item>
</argument>
</arguments>
</type>
</config> </config>
...@@ -48,46 +48,6 @@ ...@@ -48,46 +48,6 @@
<include path="Adyen_Payment::system/adyen_boleto.xml"/> <include path="Adyen_Payment::system/adyen_boleto.xml"/>
<include path="Adyen_Payment::system/adyen_apple_pay.xml"/> <include path="Adyen_Payment::system/adyen_apple_pay.xml"/>
</group> </group>
<group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
</field>
<field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
</field>
<field id="payable_to" translate="label" sortOrder="61" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Make Check Payable to</label>
</field>
<field id="mailing_address" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Send Check to</label>
</field>
<field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Minimum Order Total</label>
</field>
<field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Maximum Order Total</label>
</field>
<field id="model"></field>
</group>
</section> </section>
</system> </system>
</config> </config>
\ No newline at end of file
...@@ -22,52 +22,74 @@ ...@@ -22,52 +22,74 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
--> -->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd"> <include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<group id="adyen_cc" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1"> xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_cc" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1"
showInStore="1">
<label><![CDATA[CreditCard API integration]]></label> <label><![CDATA[CreditCard API integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css> <fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process creditcard payments inside your checkout.</comment> <comment>Process creditcard payments inside your checkout.</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Enabled</label> <label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/active</config_path> <config_path>payment/adyen_cc/active</config_path>
</field> </field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Title</label> <label>Title</label>
<config_path>payment/adyen_cc/title</config_path> <config_path>payment/adyen_cc/title</config_path>
</field> </field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1"
showInStore="0">
<label>Sort Order</label> <label>Sort Order</label>
<frontend_class>validate-number</frontend_class> <frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_cc/sort_order</config_path> <config_path>payment/adyen_cc/sort_order</config_path>
</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>Credit Card Types</label> <label>Credit Card Types</label>
<source_model>Adyen\Payment\Model\Config\Source\CcType</source_model> <source_model>Adyen\Payment\Model\Config\Source\CcType</source_model>
<config_path>payment/adyen_cc/cctypes</config_path> <config_path>payment/adyen_cc/cctypes</config_path>
</field> </field>
<field id="adyen_cc_vault" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1"
showInStore="0">
<label>Vault Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc_vault/active</config_path>
</field>
<group id="adyen_cc_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="150"> <group id="adyen_cc_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" showInStore="1"
sortOrder="150">
<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="enable_moto" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="enable_moto" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Enable MOTO</label> <label>Enable MOTO</label>
<tooltip><![CDATA[Important you have to activate MOTO for your account contact magento@adyen.com.]]></tooltip> <tooltip>
<![CDATA[Important you have to activate MOTO for your account contact magento@adyen.com.]]></tooltip>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/enable_moto</config_path> <config_path>payment/adyen_cc/enable_moto</config_path>
</field> </field>
<field id="enable_installments" translate="label" type="select" sortOrder="219" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="enable_installments" translate="label" type="select" sortOrder="219" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Enable Installments</label> <label>Enable Installments</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<tooltip>Enable installments for each credit card type.</tooltip> <tooltip>Enable installments for each credit card type.</tooltip>
<config_path>payment/adyen_cc/enable_installments</config_path> <config_path>payment/adyen_cc/enable_installments</config_path>
</field> </field>
<field id="installments" translate="label" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="installments" translate="label" sortOrder="220" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Installments</label> <label>Installments</label>
<depends><field id="enable_installments">1</field></depends> <depends>
<tooltip>Configure your installment for each credit card type: Insert the minimum amount required to make the configured installment available in the amount range column. <field id="enable_installments">1</field>
Example: if the amount range is configured to 100 and the number of installments to 4x, the shopper will see the 4x option only if the payment total is higher or equal than 100.</tooltip> </depends>
<tooltip>Configure your installment for each credit card type: Insert the minimum amount required to
make the configured installment available in the amount range column.
Example: if the amount range is configured to 100 and the number of installments to 4x, the shopper
will see the 4x option only if the payment total is higher or equal than 100.
</tooltip>
<frontend_model>Adyen\Payment\Block\Adminhtml\System\Config\Field\Installments</frontend_model> <frontend_model>Adyen\Payment\Block\Adminhtml\System\Config\Field\Installments</frontend_model>
<backend_model>Adyen\Payment\Model\Config\Backend\Installments</backend_model> <backend_model>Adyen\Payment\Model\Config\Backend\Installments</backend_model>
<config_path>payment/adyen_cc/installments</config_path> <config_path>payment/adyen_cc/installments</config_path>
...@@ -77,12 +99,14 @@ ...@@ -77,12 +99,14 @@
<group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200"> <group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<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="100" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="allowspecific" translate="label" type="allowspecific" sortOrder="100" showInDefault="1"
showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label> <label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_cc/allowspecific</config_path> <config_path>payment/adyen_cc/allowspecific</config_path>
</field> </field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="specificcountry" translate="label" type="multiselect" sortOrder="200" showInDefault="1"
showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label> <label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model> <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty> <can_be_empty>1</can_be_empty>
......
...@@ -61,21 +61,21 @@ ...@@ -61,21 +61,21 @@
<label>UnionPay</label> <label>UnionPay</label>
<code_alt>cup</code_alt> <code_alt>cup</code_alt>
</type> </type>
<type id="BCMC" order="80"> <type id="BCMC" order="90">
<label>Bancontact</label> <label>Bancontact</label>
<code_alt>bcmc</code_alt> <code_alt>bcmc</code_alt>
</type> </type>
<type id="HIPERCARD" order="80"> <type id="HIPERCARD" order="100">
<label>Hipercard</label> <label>Hipercard</label>
<code_alt>hipercard</code_alt> <code_alt>hipercard</code_alt>
</type> </type>
<type id="ELO" order="80"> <type id="ELO" order="110">
<label>Elo</label> <label>Elo</label>
<code_alt>elo</code_alt> <code_alt>elo</code_alt>
</type> </type>
<type id="AURA" order="80"> <type id="TROY" order="130">
<label>Aura</label> <label>Troy</label>
<code_alt>aura</code_alt> <code_alt>troy</code_alt>
</type> </type>
</adyen_credit_cards> </adyen_credit_cards>
</payment> </payment>
...@@ -60,8 +60,18 @@ ...@@ -60,8 +60,18 @@
<can_refund>1</can_refund> <can_refund>1</can_refund>
<can_void>1</can_void> <can_void>1</can_void>
<can_cancel>1</can_cancel> <can_cancel>1</can_cancel>
<can_authorize_vault>1</can_authorize_vault>
<can_capture_vault>1</can_capture_vault>
<group>adyen</group> <group>adyen</group>
</adyen_cc> </adyen_cc>
<adyen_cc_vault>
<model>AdyenPaymentCcVaultFacade</model>
<title>Stored Cards (Adyen)</title>
<instant_purchase>
<available>Adyen\Payment\Model\InstantPurchase\CreditCard\AvailabilityChecker</available>
<tokenFormat>Adyen\Payment\Model\InstantPurchase\CreditCard\TokenFormatter</tokenFormat>
</instant_purchase>
</adyen_cc_vault>
<adyen_oneclick> <adyen_oneclick>
<active>1</active> <active>1</active>
<model>AdyenPaymentOneclickFacade</model> <model>AdyenPaymentOneclickFacade</model>
......
This diff is collapsed.
...@@ -27,14 +27,35 @@ ...@@ -27,14 +27,35 @@
<type name="Magento\Checkout\Model\CompositeConfigProvider"> <type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments> <arguments>
<argument name="configProviders" xsi:type="array"> <argument name="configProviders" xsi:type="array">
<item name="adyen_generic_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenGenericConfigProvider</item> <item name="adyen_generic_config_provider" xsi:type="object">
<item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenCcConfigProvider</item> Adyen\Payment\Model\Ui\AdyenGenericConfigProvider
<item name="adyen_oneclick_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider</item> </item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenHppConfigProvider</item> <item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenCcConfigProvider
<item name="adyen_sepa_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenSepaConfigProvider</item> </item>
<item name="adyen_boleto_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider</item> <item name="adyen_oneclick_config_provider" xsi:type="object">
<item name="adyen_pos_cloud_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider</item> Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider
<item name="adyen_apple_pay_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenApplePayConfigProvider</item> </item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\Ui\AdyenHppConfigProvider
</item>
<item name="adyen_sepa_config_provider" xsi:type="object">
Adyen\Payment\Model\Ui\AdyenSepaConfigProvider
</item>
<item name="adyen_boleto_config_provider" xsi:type="object">
Adyen\Payment\Model\Ui\AdyenBoletoConfigProvider
</item>
<item name="adyen_pos_cloud_config_provider" xsi:type="object">
Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider
</item>
<item name="adyen_apple_pay_config_provider" xsi:type="object">
Adyen\Payment\Model\Ui\AdyenApplePayConfigProvider
</item>
</argument>
</arguments>
</type>
<type name="Magento\Vault\Model\Ui\TokensConfigProvider">
<arguments>
<argument name="tokenUiComponentProviders" xsi:type="array">
<item name="adyen_cc" xsi:type="object">Adyen\Payment\Model\Ui\TokenUiComponentProvider</item>
</argument> </argument>
</arguments> </arguments>
</type> </type>
......
...@@ -24,13 +24,14 @@ ...@@ -24,13 +24,14 @@
--> -->
<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="3.0.0"> <module name="Adyen_Payment" setup_version="4.0.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
<module name="Magento_Checkout"/> <module name="Magento_Checkout"/>
<module name="Magento_Paypal"/> <module name="Magento_Paypal"/>
<module name="Magento_AdminNotification"/> <module name="Magento_AdminNotification"/>
<module name="Magento_Vault"/>
</sequence> </sequence>
</module> </module>
</config> </config>
...@@ -22,8 +22,17 @@ ...@@ -22,8 +22,17 @@
* Author: Adyen <magento@adyen.com> * Author: Adyen <magento@adyen.com>
*/ */
--> -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head> <head>
<css src="Adyen_Payment::css/order_create_styles.css"/> <css src="Adyen_Payment::css/order_create_styles.css"/>
</head> </head>
<body>
<referenceBlock name="order_create_billing_form">
<action method="setMethodFormTemplate">
<argument name="method" xsi:type="string">adyen_cc_vault</argument>
<argument name="template" xsi:type="string">Magento_Vault::form/vault.phtml</argument>
</action>
</referenceBlock>
</body>
</page> </page>
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="order.create.billing.method.form">
<action method="setMethodFormTemplate">
<argument name="method" xsi:type="string">adyen_cc_vault</argument>
<argument name="template" xsi:type="string">Magento_Vault::form/vault.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
// @codingStandardsIgnoreFile
/** @var \Magento\Framework\View\Element\Template $block */
$details = $block->getData(TokenUiComponentProviderInterface::COMPONENT_DETAILS);
$id = $block->escapeHtml($block->getData('id'));
?>
<div data-mage-init='{
"Adyen_Payment/js/vault": {
"container": "payment_<?= /* @noEscape */
$id ?>",
"publicHash": "<?= $block->escapeHtml($block->getData(TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH)) ?>",
"code": "<?= $block->escapeHtml($block->getData('code')) ?>"
}
}' id="payment_<?= /* @noEscape */
$id ?>" class="admin__field">
<div class="admin__field-control control">
<input type="radio" id="token_switcher_<?= /* @noEscape */
$id ?>" name="payment[token_switcher]"/>
<img src="<?= $block->escapeUrl($details['icon']['url']) ?>"
width="<?= $block->escapeHtml($details['icon']['width']) ?>"
height="<?= $block->escapeHtml($details['icon']['height']) ?>"
class="payment-icon">
<span><?= $block->escapeHtml(__('ending')) ?></span>
<span><?= $block->escapeHtml($details['maskedCC']) ?></span>
(<span><?= $block->escapeHtml(__('expires')) ?></span>:
<span><?= $block->escapeHtml($details['expirationDate']) ?></span>)
</div>
</div>
\ No newline at end of file
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define([
'jquery',
'uiComponent'
], function ($, Class) {
'use strict';
return Class.extend({
defaults: {
$selector: null,
selector: 'edit_form'
},
initObservable: function () {
var self = this;
self.$selector = $('#' + self.selector);
this._super();
this.initEventHandlers();
return this;
},
getCode: function () {
return this.code;
},
initEventHandlers: function () {
$('#' + this.container).find('[name="payment[token_switcher]"]')
.on('click', this.setPaymentDetails.bind(this));
},
setPaymentDetails: function () {
this.$selector.find('[name="payment[public_hash]"]').val(this.publicHash);
}
});
});
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceBlock name="vault.cards.list">
<block class="Adyen\Payment\Block\Customer\CardRenderer" name="adyen.card.renderer"
template="Magento_Vault::customer_account/credit_card.phtml"/>
</referenceBlock>
</referenceContainer>
</body>
</page>
...@@ -1002,24 +1002,20 @@ ...@@ -1002,24 +1002,20 @@
} }
/*.adyen-checkout__card__form .adyen-checkout__input {*/ /*
/*max-height: 40px;*/ Custom style for ideal component
/*}*/ */
/*.adyen-checkout__card__form .adyen-checkout__input img{*/ #iDealContainer .adyen-checkout__dropdown__button{
/*display: none;*/ padding: 0 0 0 8px;
/*}*/ max-width: 290px;
}
/*#adyen-cc-form .fieldset > .field > .label, .fieldset > .fields > .field > .label {*/
/*font-weight: 400;*/ #iDealContainer .adyen-checkout__dropdown__element{
/*}*/ margin-bottom: 0;
}
/*#adyen-cc-form .fieldset > .holdername.field{*/
/*margin-bottom: 10px;*/ .message.error.hpp-message{
/*}*/ margin-top: 10px;
display: none;
/*#adyen-cc-form .helper-text{*/ }
/*font-size: 11px;*/ \ No newline at end of file
/*color: rgb(144, 162, 189);*/
/*font-weight: 100;*/
/*}*/
\ No newline at end of file
...@@ -29,13 +29,17 @@ define( ...@@ -29,13 +29,17 @@ define(
'Magento_Checkout/js/model/payment/additional-validators', 'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Adyen_Payment/js/model/installments', 'Adyen_Payment/js/model/installments',
'mage/url' 'mage/url',
'Magento_Vault/js/view/payment/vault-enabler'
], ],
function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url) { function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url, VaultEnabler) {
'use strict'; 'use strict';
return Component.extend({ return Component.extend({
// need to duplicate as without the button will never activate on first time page view
isPlaceOrderActionAllowed: ko.observable(quote.billingAddress() != null),
defaults: { defaults: {
template: 'Adyen_Payment/payment/cc-form', template: 'Adyen_Payment/payment/cc-form',
creditCardOwner: '', creditCardOwner: '',
...@@ -43,6 +47,17 @@ define( ...@@ -43,6 +47,17 @@ define(
installment: '', installment: '',
creditCardDetailsValid: false creditCardDetailsValid: false
}, },
/**
* @returns {exports.initialize}
*/
initialize: function () {
this._super();
this.vaultEnabler = new VaultEnabler();
this.vaultEnabler.setPaymentCode(this.getVaultCode());
this.vaultEnabler.isActivePaymentTokenEnabler(false);
return this;
},
initObservable: function () { initObservable: function () {
this._super() this._super()
.observe([ .observe([
...@@ -70,7 +85,6 @@ define( ...@@ -70,7 +85,6 @@ define(
*/ */
renderSecureFields: function () { renderSecureFields: function () {
var self = this; var self = this;
self.placeOrderAllowed(false);
if (!self.getOriginKey()) { if (!self.getOriginKey()) {
return; return;
} }
...@@ -162,7 +176,7 @@ define( ...@@ -162,7 +176,7 @@ define(
self.creditCardDetailsValid(true); self.creditCardDetailsValid(true);
self.placeOrderAllowed(true); self.placeOrderAllowed(true);
}, },
onError: function (state) { onError: function () {
self.creditCardDetailsValid(false); self.creditCardDetailsValid(false);
self.placeOrderAllowed(false); self.placeOrderAllowed(false);
} }
...@@ -176,7 +190,7 @@ define( ...@@ -176,7 +190,7 @@ define(
* @returns {{method: *, additional_data: {cc_type: *, number: *, cvc, expiryMonth: *, expiryYear: *, holderName: *, store_cc: *, number_of_installments: *}}} * @returns {{method: *, additional_data: {cc_type: *, number: *, cvc, expiryMonth: *, expiryYear: *, holderName: *, store_cc: *, number_of_installments: *}}}
*/ */
getData: function () { getData: function () {
return { var data = {
'method': this.item.method, 'method': this.item.method,
additional_data: { additional_data: {
'card_brand': this.variant(), 'card_brand': this.variant(),
...@@ -190,6 +204,8 @@ define( ...@@ -190,6 +204,8 @@ define(
'number_of_installments': this.installment() 'number_of_installments': this.installment()
} }
}; };
this.vaultEnabler.visitAdditionalData(data);
return data;
}, },
/** /**
* Returns state of place order button * Returns state of place order button
...@@ -360,6 +376,18 @@ define( ...@@ -360,6 +376,18 @@ define(
}, },
context: function () { context: function () {
return this; return this;
},
/**
* @returns {Bool}
*/
isVaultEnabled: function () {
return this.vaultEnabler.isVaultEnabled();
},
/**
* @returns {String}
*/
getVaultCode: function () {
return window.checkoutConfig.payment[this.getCode()].vaultCode;
} }
}); });
} }
......
...@@ -60,8 +60,8 @@ define( ...@@ -60,8 +60,8 @@ define(
'dfValue' 'dfValue'
]); ]);
return this; return this;
}, },initialize: function () {
initialize: function () {
var self = this; var self = this;
this._super(); this._super();
...@@ -164,6 +164,12 @@ define( ...@@ -164,6 +164,12 @@ define(
result.value = value.brandCode; result.value = value.brandCode;
result.name = value; result.name = value;
result.method = self.item.method; result.method = self.item.method;
/**
* Observable to enable and disable place order buttons for payment methods
* Default value is true to be able to send the real hpp requiests that doesn't require any input
* @type {observable}
*/
result.placeOrderAllowed = ko.observable(true);
result.getCode = function () { result.getCode = function () {
return self.item.method; return self.item.method;
}; };
...@@ -176,6 +182,17 @@ define( ...@@ -176,6 +182,17 @@ define(
result.isPlaceOrderActionAllowed = function(bool) { result.isPlaceOrderActionAllowed = function(bool) {
return self.isPlaceOrderActionAllowed(bool); return self.isPlaceOrderActionAllowed(bool);
}; };
/**
* Set and get if the place order action is allowed
* Sets the placeOrderAllowed observable and the original isPlaceOrderActionAllowed as well
* @param bool
* @returns {*}
*/
result.isPlaceOrderAllowed = function(bool) {
self.isPlaceOrderActionAllowed(bool);
return result.placeOrderAllowed(bool);
};
result.afterPlaceOrder = function() { result.afterPlaceOrder = function() {
return self.afterPlaceOrder(); return self.afterPlaceOrder();
}; };
...@@ -199,6 +216,61 @@ define( ...@@ -199,6 +216,61 @@ define(
return false; return false;
}; };
// Can be removed after checkout api feature branch goes live since the issuerId key is changed to
// id there and just use the value.issuers in the component
result.getIssuerListForComponent = function() {
if (result.isIssuerListAvailable()) {
return _.map(value.issuers, function (issuer, key) {
return {
"id": issuer.issuerId,
"name": issuer.name
};
});
}
return [];
};
result.isIdeal = function () {
if (value.brandCode.indexOf("ideal") >= 0) {
return true;
}
return false;
};
/**
* Renders the secure fields,
* creates the ideal component,
* sets up the callbacks for ideal components and
*/
result.renderIdealComponent = function () {
result.isPlaceOrderAllowed(false);
var secureFieldsNode = document.getElementById('iDealContainer');
var checkout = new AdyenCheckout({
locale: self.getLocale()
});
var ideal = checkout.create('ideal', {
items: result.getIssuerListForComponent(),
onChange: function (state) {
// isValid is not present on start
if (typeof state.isValid !== 'undefined' && state.isValid === false) {
result.isPlaceOrderAllowed(false);
}
},
onValid: function (state) {
result.issuerId(state.data.issuer);
result.isPlaceOrderAllowed(true);
},
onError: function (state) {
result.isPlaceOrderAllowed(false);
}
});
ideal.mount(secureFieldsNode);
};
if (value.hasOwnProperty("issuers")) { if (value.hasOwnProperty("issuers")) {
if (value.issuers.length == 0) { if (value.issuers.length == 0) {
...@@ -318,18 +390,30 @@ define( ...@@ -318,18 +390,30 @@ define(
placeRedirectOrder: function(data) { placeRedirectOrder: function(data) {
// Place Order but use our own redirect url after // Place Order but use our own redirect url after
var self = this; var self = this;
fullScreenLoader.startLoader();
var messageContainer = this.messageContainer; var messageContainer = this.messageContainer;
if(brandCode()) { if(brandCode()) {
messageContainer = self.messageComponents['messages-' + brandCode()]; messageContainer = self.messageComponents['messages-' + brandCode()];
} }
$('.hpp-message').slideUp();
this.isPlaceOrderActionAllowed(false); this.isPlaceOrderActionAllowed(false);
fullScreenLoader.startLoader();
$.when( $.when(
placeOrderAction(data, messageContainer) placeOrderAction(data, messageContainer)
).fail( ).fail(
function () { function (response) {
fullScreenLoader.stopLoader();
if (!!response['responseJSON'].parameters) {
$("#messages-" + brandCode()).text((response['responseJSON'].message).replace('%1', response['responseJSON'].parameters[0])).slideDown();
} else {
$("#messages-" + brandCode()).text(response['responseJSON'].message).slideDown();
}
setTimeout(function(){
$("#messages-" + brandCode()).slideUp();
}, 10000);
self.isPlaceOrderActionAllowed(true); self.isPlaceOrderActionAllowed(true);
} }
).done( ).done(
...@@ -370,6 +454,9 @@ define( ...@@ -370,6 +454,9 @@ define(
}, },
getRatePayDeviceIdentToken: function () { getRatePayDeviceIdentToken: function () {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken; return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
},
getLocale: function () {
return window.checkoutConfig.payment.adyenHpp.locale;
} }
}); });
} }
......
...@@ -261,8 +261,11 @@ define( ...@@ -261,8 +261,11 @@ define(
} }
} else { } else {
self.encryptedCreditCardVerificationNumber = ''; self.encryptedCreditCardVerificationNumber = '';
self.placeOrderAllowed(false); // onChange is called on the startup so make sure maestro has always optional cvc field
isValid(false); if (self.agreement_data.variant != "maestro") {
self.placeOrderAllowed(false);
isValid(false);
}
} }
}, },
onValid: function (state) { onValid: function (state) {
......
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
/*browser:true*/
/*global define*/
define([
'jquery',
'Magento_Vault/js/view/payment/method-renderer/vault'
], function ($, VaultComponent) {
'use strict';
return VaultComponent.extend({
defaults: {
template: 'Magento_Vault/payment/form'
},
/**
* Get last 4 digits of card
* @returns {String}
*/
getMaskedCard: function () {
return this.details.maskedCC;
},
/**
* Get expiration date
* @returns {String}
*/
getExpirationDate: function () {
return this.details.expirationDate;
},
/**
* Get card type
* @returns {String}
*/
getCardType: function () {
return this.details.type;
},
/**
* @returns {String}
*/
getToken: function () {
return this.publicHash;
},
/**
* @param {String} type
* @returns {Boolean}
*/
getIcons: function (type) {
return this.details.icon;
}
});
});
\ No newline at end of file
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
<div class="payment-method-content"> <div class="payment-method-content">
<!-- ko ifnot: (getOriginKey()) --> <!-- ko ifnot: (getOriginKey()) -->
<span class="message message-error error"><!-- ko text: $t('Please configure an API Key and a live endpoint prefix(if in Production Mode) in your Adyen Required Settings')--><!-- /ko --></span> <span class="message message-error error"><!-- ko text: $t('Please configure an API Key and a live endpoint prefix(if in Production Mode) in your Adyen Required Settings')-->
<!-- /ko --></span>
<!--/ko--> <!--/ko-->
<div class="payment-method-billing-address"> <div class="payment-method-billing-address">
...@@ -104,8 +105,20 @@ ...@@ -104,8 +105,20 @@
<!-- /ko --> <!-- /ko -->
<!-- ko if: (isVaultEnabled())-->
<div class="field choice">
<input type="checkbox"
name="vault[is_enabled]"
class="checkbox"
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
</label>
</div>
<!-- /ko -->
<!-- ko if: (canCreateBillingAgreement())--> <!-- ko if: (canCreateBillingAgreement() && !isVaultEnabled())-->
<div class="field choice"> <div class="field choice">
<input type="checkbox" <input type="checkbox"
......
...@@ -55,17 +55,22 @@ ...@@ -55,17 +55,22 @@
<form class="form" data-role="adyen-hpp-form" action="#" method="post" data-bind="mageInit: { 'validation':[]}, attr: {id: 'payment_form_' + $parent.getCode() + '_' + value}"> <form class="form" data-role="adyen-hpp-form" action="#" method="post" data-bind="mageInit: { 'validation':[]}, attr: {id: 'payment_form_' + $parent.getCode() + '_' + value}">
<fieldset class="fieldset" data-bind='attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'> <fieldset class="fieldset" data-bind='attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'>
<!-- ko if: isIssuerListAvailable() --> <!-- ko if: isIssuerListAvailable() -->
<label data-bind="attr: {'for': 'issuerId'}" class="label"> <!-- ko if: isIdeal() -->
<span><!-- ko text: $t('Select Your Bank') --><!-- /ko --></span> <div afterRender="renderIdealComponent()" data-bind="attr: { id: 'iDealContainer'}"></div>
</label> <!--/ko-->
<!-- ko ifnot: isIdeal() -->
<select name="payment[issuer_id]" data-bind=" <label data-bind="attr: {'for': 'issuerId'}" class="label">
options: name.issuers, <span><!-- ko text: $t('Select Your Bank') --><!-- /ko --></span>
optionsText: 'name', </label>
optionsValue: 'issuerId',
value: issuerId, <select name="payment[issuer_id]" data-bind="
optionsCaption: $t('Choose Your Bank')"> options: name.issuers,
</select> optionsText: 'name',
optionsValue: 'issuerId',
value: issuerId,
optionsCaption: $t('Choose Your Bank')">
</select>
<!--/ko-->
<!--/ko--> <!--/ko-->
<!-- ko if: isPaymentMethodOpenInvoiceMethod() --> <!-- ko if: isPaymentMethodOpenInvoiceMethod() -->
...@@ -168,11 +173,15 @@ ...@@ -168,11 +173,15 @@
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
</div> </div>
<div>
<span class="message message-error error hpp-message" data-bind="attr: {id: 'messages-' + value}"></span>
</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="click: $parent.continueToAdyenBrandCode, enable: (value == $parent.isBrandCodeChecked())" data-bind="click: $parent.continueToAdyenBrandCode, enable: placeOrderAllowed() && (value == $parent.isBrandCodeChecked())"
disabled> disabled>
<span data-bind="text: $t('Place Order')"></span> <span data-bind="text: $t('Place Order')"></span>
</button> </button>
......
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