Commit 9cf7b31d authored by Rik ter Beek's avatar Rik ter Beek

Initial commit for vault system

parent 6ad4e588
......@@ -33,7 +33,7 @@ class Cctypes extends \Magento\Framework\View\Element\Html\Select
protected $ccTypes = [];
/**
* @var \Magento\Braintree\Model\Source\CcType
* @var \Adyen\Payment\Model\Config\Source\CcType
*/
protected $ccTypeSource;
......
......@@ -31,9 +31,6 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
*/
protected $_installmentRenderer = null;
/**
* @var \Magento\Braintree\Block\Adminhtml\Form\Field\CcTypes
*/
protected $_ccTypesRenderer = null;
/**
......@@ -57,7 +54,8 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
/**
* 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()
{
......
<?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>
*/
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
<?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>
*/
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
<?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>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
class VaultDataBuilder implements BuilderInterface
{
/**
* Additional options in request to gateway
*/
const OPTIONS = 'options';
/**
* The option that determines whether the payment method associated with
* the successful transaction should be stored in the Vault.
*/
const STORE_IN_VAULT_ON_SUCCESS = 'storeInVaultOnSuccess';
/**
* @inheritdoc
*/
public function build(array $buildSubject)
{
// indicates if the user want to store it or not
// ignore for now
// needs to define if we need to store it as oneclick or recurring
$request = [];
return $request;
}
}
\ No newline at end of file
......@@ -27,6 +27,18 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentAuthorisationDetailsHandler implements HandlerInterface
{
public function __construct(
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
)
{
$this->_adyenLogger = $adyenLogger;
$this->_adyenLogger->error("Constructor PaymentAuthorisationDetailsHandler");
$this->_adyenLogger->addNotificationLog("Constructor PaymentAuthorisationDetailsHandler");
}
/**
* @param array $handlingSubject
* @param array $response
......
<?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>
*/
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->_adyenLogger->error("Constructor1");
$this->_adyenLogger->addNotificationLog("Constructor1");
$this->_adyenLogger->error("Constructo2r");
$this->paymentTokenFactory = $paymentTokenFactory;
$this->_adyenLogger->error("Constructor2");
}
/**
* @inheritdoc
*/
public function handle(array $handlingSubject, array $response)
{
$this->_adyenLogger->error("Test handle Adyen NEWWW");
// $this->_adyenLogger->error(print_r($response, true));
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
$this->_adyenLogger->error("Class Payment" . get_class($payment));
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
$this->_adyenLogger->error("Class Payment2" . get_class($payment));
$this->_adyenLogger->error("Test handle Adyen 2");
// add vault payment token entity to extension attributes
$paymentToken = $this->getVaultPaymentToken($response);
if (null !== $paymentToken) {
$this->_adyenLogger->error("Test handle Adyen 3");
$extensionAttributes = $this->getExtensionAttributes($payment);
$this->_adyenLogger->error("Test handle Adyen 4");
$extensionAttributes->setVaultPaymentToken($paymentToken);
$this->_adyenLogger->error("Test handle Adyen 5");
}
$this->_adyenLogger->error("Test handle Adyen 6");
}
/**
* Get vault payment token entity
*
* @param array $response
* @return PaymentTokenInterface|null
*/
private function getVaultPaymentToken(array $response)
{
$this->_adyenLogger->error("getVaultPaymentToken");
$additionalData = $response['additionalData'];
if(empty($additionalData['recurring.recurringDetailReference'])) {
$this->_adyenLogger->error("Missing Token in Result please send email to magento@adyen.com to enable the rechargeSynchronousStoreDetails property");
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 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 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 and Response and enable the Variant property");
return null;
}
// do we need to convert this ???
$cardType = $additionalData['paymentMethod'];
//additional data then recurring.recurringDetailReference
$this->_adyenLogger->error("getVaultPaymentToken2");
try {
$this->_adyenLogger->error("getVaultPaymentToken3");
/** @var PaymentTokenInterface $paymentToken */
$paymentToken = $this->paymentTokenFactory->create(PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD);
$paymentToken->setGatewayToken($token);
$paymentToken->setExpiresAt($this->getExpirationDate($expirationDate));
$this->_adyenLogger->error("getVaultPaymentToken4");
$details = [
'type' => $cardType,
'maskedCC' => $cardSummary,
'expirationDate' => $expirationDate
];
$this->_adyenLogger->error(print_r($details, true));
$this->_adyenLogger->error("getVaultPaymentToken5");
$paymentToken->setTokenDetails(json_encode($details));
$this->_adyenLogger->error(json_encode($details));
$this->_adyenLogger->error("getVaultPaymentToken6");
} catch(Exception $e) {
$this->_adyenLogger->error("EXCEPTION!");
$this->_adyenLogger->error(print_r($e, true));
}
$this->_adyenLogger->error("getVaultPaymentToken before end");
return $paymentToken;
}
/**
* @param $expirationDate
* @return string
*/
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)
{
$this->_adyenLogger->error("getExtensionAttributes 1");
$extensionAttributes = $payment->getExtensionAttributes();
$this->_adyenLogger->error("getExtensionAttributes 2");
if (null === $extensionAttributes) {
$this->_adyenLogger->error("getExtensionAttributes 3");
$extensionAttributes = $this->paymentExtensionFactory->create();
$this->_adyenLogger->error("getExtensionAttributes 4");
$payment->setExtensionAttributes($extensionAttributes);
$this->_adyenLogger->error("getExtensionAttributes 5");
}
return $extensionAttributes;
}
}
\ No newline at end of file
......@@ -973,4 +973,23 @@ class Data extends AbstractHelper
return "https://" . $environment . ".adyen.com/hpp/cse/js/" . $this->getLibraryToken($storeId) . ".shtml";
}
/**
* 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;
}
}
\ No newline at end of file
<?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\UrlInterface;
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;
/**
* @param TokenUiComponentInterfaceFactory $componentFactory
* @param UrlInterface $urlBuilder
*/
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,
// 'nonceUrl' => $this->getNonceRetrieveUrl(),
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
......@@ -33,6 +33,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
const CODE = 'adyen_cc';
const CC_VAULT_CODE = 'adyen_cc_vault';
/**
* @var PaymentHelper
*/
......@@ -103,6 +105,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$config = [
'payment' => [
self::CODE => [
'vaultCode' => self::CC_VAULT_CODE,
'isActive' => true,
'redirectUrl' => $this->_urlBuilder->getUrl(
'adyen/process/validate3d/', ['_secure' => $this->_getRequest()->isSecure()])
......
<?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>
*/
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 \Magento\Framework\UrlInterface
*/
private $urlBuilder;
/**
* @var Data
*/
private $adyenHelper;
/**
* @param TokenUiComponentInterfaceFactory $componentFactory
* @param UrlInterface $urlBuilder
*/
public function __construct(
TokenUiComponentInterfaceFactory $componentFactory,
UrlInterface $urlBuilder,
Data $adyenHelper
) {
$this->componentFactory = $componentFactory;
$this->urlBuilder = $urlBuilder;
$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;
}
}
......@@ -62,10 +62,12 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
$paymentInfo = $this->readPaymentModelArgument($observer);
// set ccType
if(!empty($additionalData['cc_type'])) {
$paymentInfo->setCcType($additionalData['cc_type']);
}
foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) {
if (!empty($additionalData[$additionalInformationKey])) {
$paymentInfo->setAdditionalInformation(
$additionalInformationKey,
$additionalData[$additionalInformationKey]
......
......@@ -15,7 +15,8 @@
],
"require": {
"adyen/php-api-library": "*",
"magento/framework": ">=100.1.0"
"magento/framework": ">=100.1.0",
"magento/module-vault": "100.1.*"
},
"autoload": {
"files": [
......
......@@ -8,4 +8,11 @@
</argument>
</arguments>
</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>
......@@ -57,6 +57,11 @@
<tooltip>Copy this from the Live Adyen Customer Area => Settings => Users => System => [web service user]=> Library token.</tooltip>
<config_path>payment/adyen_cc/cse_library_token_live</config_path>
</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" sortOrder="150">
<label>Advanced Settings</label>
......
......@@ -58,8 +58,14 @@
<can_refund>1</can_refund>
<can_void>1</can_void>
<can_cancel>1</can_cancel>
<can_authorize_vault>1</can_authorize_vault>
<can_capture_vault>1</can_capture_vault>
<group>adyen</group>
</adyen_cc>
<adyen_cc_vault>
<model>AdyenPaymentCcVaultFacade</model>
<title>Stored Cards (Adyen)</title>
</adyen_cc_vault>
<adyen_oneclick>
<active>1</active>
<model>AdyenPaymentOneclickFacade</model>
......
......@@ -44,6 +44,14 @@
<argument name="commandPool" xsi:type="object">AdyenPaymentCcCommandPool</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultFacade" type="Magento\Vault\Model\Method\Vault">
<arguments>
<argument name="code" xsi:type="const">Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CC_VAULT_CODE</argument>
<argument name="config" xsi:type="object">AdyenPaymentCcVaultConfig</argument>
<argument name="valueHandlerPool" xsi:type="object">AdyenPaymentCcVaultPaymentValueHandlerPool</argument>
<argument name="vaultProvider" xsi:type="object">AdyenPaymentCcFacade</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentOneclickFacade" type="Adyen\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="const">Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider::CODE</argument>
......@@ -143,6 +151,22 @@
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultPaymentValueHandler" type="VaultPaymentDefaultValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">AdyenPaymentCcVaultConfig</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultPaymentValueHandlerPool" type="VaultPaymentValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="default" xsi:type="string">AdyenPaymentCcVaultPaymentValueHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentOneclickValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
......@@ -246,6 +270,11 @@
<argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CODE</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CC_VAULT_CODE</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentOneclickConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="const">Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider::CODE</argument>
......@@ -293,6 +322,7 @@
<item name="void" xsi:type="string">AdyenPaymentCancelCommand</item>
<item name="refund" xsi:type="string">AdyenPaymentRefundCommand</item>
<item name="cancel" xsi:type="string">AdyenPaymentCancelCommand</item>
<item name="vault_authorize" xsi:type="string">AdyenPaymentCcVaultAuthorizeCommand</item>
</argument>
</arguments>
</virtualType>
......@@ -382,6 +412,21 @@
</arguments>
</virtualType>
<!-- Command managers section for Vault -->
<virtualType name="AdyenPaymentCcCommandManager" type="Magento\Payment\Gateway\Command\CommandManager">
<arguments>
<argument name="commandPool" xsi:type="object">AdyenPaymentCcCommandPool</argument>
</arguments>
</virtualType>
<type name="Magento\Payment\Gateway\Command\CommandManagerPool">
<arguments>
<argument name="executors" xsi:type="array">
<item name="adyen_cc" xsi:type="string">AdyenPaymentCcCommandManager</item>
</argument>
</arguments>
</type>
<!-- Authorization command -->
<virtualType name="AdyenPaymentCcAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments>
......@@ -392,6 +437,16 @@
<argument name="handler" xsi:type="object">AdyenPaymentCcResponseHandlerComposite</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments>
<argument name="requestBuilder" xsi:type="object">AdyenPaymentCcVaultAuthorizeRequest</argument>
<argument name="transferFactory" xsi:type="object">Adyen\Payment\Gateway\Http\TransferFactory</argument>
<argument name="client" xsi:type="object">Adyen\Payment\Gateway\Http\Client\TransactionAuthorization</argument>
<argument name="validator" xsi:type="object">GeneralResponseValidator</argument>
<argument name="handler" xsi:type="object">AdyenPaymentCcVaultResponseHandlerComposite</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentAuthorize3DCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments>
<argument name="requestBuilder" xsi:type="object">AdyenPaymentAuthorize3DRequest</argument>
......@@ -485,10 +540,28 @@
<item name="browserinfo" xsi:type="string">Adyen\Payment\Gateway\Request\BrowserInfoDataBuilder</item>
<item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringDataBuilder</item>
<item name="transaction" xsi:type="string">Adyen\Payment\Gateway\Request\CcAuthorizationDataBuilder</item>
<item name="vault" xsi:type="string">Adyen\Payment\Gateway\Request\VaultDataBuilder</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultAuthorizeRequest" type="Magento\Payment\Gateway\Request\BuilderComposite">
<arguments>
<argument name="builders" xsi:type="array">
<item name="merchantaccount" xsi:type="string">Adyen\Payment\Gateway\Request\MerchantAccountDataBuilder</item>
<item name="customer" xsi:type="string">Adyen\Payment\Gateway\Request\CustomerDataBuilder</item>
<item name="customerip" xsi:type="string">Adyen\Payment\Gateway\Request\CustomerIpDataBuilder</item>
<item name="address" xsi:type="string">Adyen\Payment\Gateway\Request\AddressDataBuilder</item>
<item name="payment" xsi:type="string">Adyen\Payment\Gateway\Request\PaymentDataBuilder</item>
<item name="browserinfo" xsi:type="string">Adyen\Payment\Gateway\Request\BrowserInfoDataBuilder</item>
<item name="recurring" xsi:type="string">Adyen\Payment\Gateway\Request\RecurringVaultDataBuilder</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentAuthorize3DRequest" type="Magento\Payment\Gateway\Request\BuilderComposite">
<arguments>
<argument name="builders" xsi:type="array">
......@@ -591,6 +664,15 @@
<!-- Response handlers -->
<virtualType name="AdyenPaymentCcResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="payment_details" xsi:type="string">Adyen\Payment\Gateway\Response\PaymentAuthorisationDetailsHandler</item>
<item name="vault_details" xsi:type="string">Adyen\Payment\Gateway\Response\VaultDetailsHandler</item>
<item name="payment_comments" xsi:type="string">Adyen\Payment\Gateway\Response\PaymentCommentHistoryHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentCcVaultResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="payment_details" xsi:type="string">Adyen\Payment\Gateway\Response\PaymentAuthorisationDetailsHandler</item>
......@@ -598,6 +680,7 @@
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentSepaResponseHandlerComposite" type="Magento\Payment\Gateway\Response\HandlerChain">
<arguments>
<argument name="handlers" xsi:type="array">
......
......@@ -38,4 +38,13 @@
</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>
</arguments>
</type>
</config>
\ No newline at end of file
......@@ -31,6 +31,7 @@
<module name="Magento_Checkout"/>
<module name="Magento_Paypal"/>
<module name="Magento_AdminNotification"/>
<module name="Magento_Vault"/>
</sequence>
</module>
</config>
<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_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
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<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>
<?php
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @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>
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
/*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"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<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>
......@@ -29,9 +29,10 @@ define(
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote',
'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';
var cvcLength = ko.observable(4);
......@@ -68,6 +69,9 @@ define(
var self = this;
this._super();
this.vaultEnabler = new VaultEnabler();
this.vaultEnabler.setPaymentCode(this.getVaultCode());
installments.setInstallments(0);
......@@ -135,7 +139,7 @@ define(
return 'adyen_cc';
},
getData: function () {
return {
var data = {
'method': this.item.method,
additional_data: {
'cc_type': this.creditCardType(),
......@@ -145,6 +149,9 @@ define(
'number_of_installments': this.installment()
}
};
this.vaultEnabler.visitAdditionalData(data);
return data;
},
getCvcLength: function () {
return cvcLength();
......@@ -275,6 +282,19 @@ define(
},
getAllInstallments: function () {
return window.checkoutConfig.payment.adyenCc.installments;
},
/**
* @returns {Bool}
*/
isVaultEnabled: function () {
return this.vaultEnabler.isVaultEnabled();
},
/**
* @returns {String}
*/
getVaultCode: function () {
return window.checkoutConfig.payment[this.getCode()].vaultCode;
}
});
}
......
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/*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;
}
});
});
......@@ -241,6 +241,20 @@
<!-- /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())-->
<div class="field choice">
......
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