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 12a4cd22 authored by rikterbeek's avatar rikterbeek

#32 Added SEPA as seperate payment method using our API integration

parent b8c2a0bc
...@@ -49,7 +49,8 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface ...@@ -49,7 +49,8 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
\Adyen\Payment\Model\Method\Cc::METHOD_CODE, \Adyen\Payment\Model\Method\Cc::METHOD_CODE,
\Adyen\Payment\Model\Method\Hpp::METHOD_CODE, \Adyen\Payment\Model\Method\Hpp::METHOD_CODE,
\Adyen\Payment\Model\Method\Oneclick::METHOD_CODE, \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE,
\Adyen\Payment\Model\Method\Pos::METHOD_CODE \Adyen\Payment\Model\Method\Pos::METHOD_CODE,
\Adyen\Payment\Model\Method\Sepa::METHOD_CODE
]; ];
/** /**
......
...@@ -175,12 +175,14 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -175,12 +175,14 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$ccEnabled = $this->_config->getValue('payment/'.\Adyen\Payment\Model\Method\Cc::METHOD_CODE.'/active'); $ccEnabled = $this->_config->getValue('payment/'.\Adyen\Payment\Model\Method\Cc::METHOD_CODE.'/active');
$ccTypes = array_keys($this->_adyenHelper->getCcTypesAltData()); $ccTypes = array_keys($this->_adyenHelper->getCcTypesAltData());
$sepaEnabled = $this->_config->getValue('payment/'.\Adyen\Payment\Model\Method\Sepa::METHOD_CODE.'/active');
foreach ($this->_fetchHppMethods($store) as $methodCode => $methodData) { foreach ($this->_fetchHppMethods($store) as $methodCode => $methodData) {
// skip payment methods if it is a creditcard that is enabled in adyen_cc // skip payment methods if it is a creditcard that is enabled in adyen_cc or if payment is sepadirectdebit and SEPA api is enabled
if ($ccEnabled if ($ccEnabled && in_array($methodCode, $ccTypes)) {
&& in_array($methodCode, $ccTypes)) { continue;
} elseif($methodCode == 'sepadirectdebit' && $sepaEnabled) {
continue; continue;
} }
......
<?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;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Payment\Helper\Data as PaymentHelper;
use Magento\Directory\Helper\Data;
class AdyenSepaConfigProvider implements ConfigProviderInterface
{
/**
* @var string[]
*/
protected $methodCodes = [
'adyen_sepa'
];
/**
* @var \Magento\Payment\Model\Method\AbstractMethod[]
*/
protected $methods = [];
/**
* @var PaymentHelper
*/
protected $_paymentHelper;
/**
* @var \Magento\Directory\Model\Config\Source\Country
*/
protected $_country;
/**
* AdyenSepaConfigProvider constructor.
*/
public function __construct(
PaymentHelper $paymentHelper,
\Magento\Directory\Model\Config\Source\Country $country
) {
$this->_paymentHelper = $paymentHelper;
$this->_country = $country;
foreach ($this->methodCodes as $code) {
$this->methods[$code] = $this->_paymentHelper->getMethodInstance($code);
}
}
public function getConfig()
{
$config = [
'payment' => [
'adyenSepa' => [
'countries' => $this->getCountries()
]
]
];
return $config;
}
public function getCountries()
{
$sepaCountriesAllowed = array(
"AT",
"BE",
"BG",
"CH",
"CY",
"CZ",
"DE",
"DK",
"EE",
"ES",
"FI",
"FR",
"GB",
"GF",
"GI",
"GP",
"GR",
"HR",
"HU",
"IE",
"IS",
"IT",
"LI",
"LT",
"LU",
"LV",
"MC",
"MQ",
"MT",
"NL",
"NO",
"PL",
"PT",
"RE",
"RO",
"SE",
"SI",
"SK"
);
$countryList = $this->_country->toOptionArray();
$sepaCountries = [];
foreach ($countryList as $key => $country) {
$value = $country['value'];
if(in_array($value, $sepaCountriesAllowed)) {
$sepaCountries[$value] = $country['label'];
}
}
return $sepaCountries;
}
}
\ No newline at end of file
...@@ -266,6 +266,8 @@ class PaymentRequest extends DataObject ...@@ -266,6 +266,8 @@ class PaymentRequest extends DataObject
$request['selectedRecurringDetailReference'] = $recurringDetailReference; $request['selectedRecurringDetailReference'] = $recurringDetailReference;
} }
if($paymentMethodCode == \Adyen\Payment\Model\Method\Cc::METHOD_CODE || $paymentMethodCode == \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE) {
// If cse is enabled add encrypted card date into request // If cse is enabled add encrypted card date into request
if($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) { if($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) {
$request['additionalData']['card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data"); $request['additionalData']['card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
...@@ -280,6 +282,21 @@ class PaymentRequest extends DataObject ...@@ -280,6 +282,21 @@ class PaymentRequest extends DataObject
$cardDetails['card'] = $requestCreditCardDetails; $cardDetails['card'] = $requestCreditCardDetails;
$request = array_merge($request, $cardDetails); $request = array_merge($request, $cardDetails);
} }
} elseif($paymentMethodCode == \Adyen\Payment\Model\Method\Sepa::METHOD_CODE) {
// set brand to sepa
$request['selectedBrand'] = "sepadirectdebit";
// add bankDetails into request
$bankAccount = [
'iban' => $payment->getAdditionalInformation("iban"),
'ownerName' => $payment->getAdditionalInformation("account_name"),
'countryCode' => $payment->getAdditionalInformation("country")
];
$request['bankAccount'] = $bankAccount;
}
$result = $service->authorise($request); $result = $service->authorise($request);
......
...@@ -191,7 +191,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -191,7 +191,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
* @return $this * @return $this
* @throws \Magento\Framework\Exception\LocalizedException * @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.NPathComplexity)authorize
*/ */
public function validate() public function validate()
{ {
......
...@@ -97,6 +97,13 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -97,6 +97,13 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
*/ */
protected $_adyenLogger; protected $_adyenLogger;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected $_request;
/** /**
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest * @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\UrlInterface $urlBuilder
......
...@@ -103,6 +103,13 @@ class Pos extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa ...@@ -103,6 +103,13 @@ class Pos extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
*/ */
protected $_currencyFactory; protected $_currencyFactory;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected $_request;
/** /**
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest * @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\UrlInterface $urlBuilder
......
<?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\Method;
/**
* Class Sepa
* @package Adyen\Payment\Model\Method
*/
class Sepa extends \Magento\Payment\Model\Method\AbstractMethod
{
const METHOD_CODE = 'adyen_sepa';
/**
* @var string
*/
protected $_code = self::METHOD_CODE;
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected $_paymentRequest;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $_urlBuilder;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected $_request;
/**
* Payment Method feature
*
* @var bool
*/
protected $_canAuthorize = true;
protected $_canCapture = true;
protected $_canCapturePartial = true;
protected $_canCaptureOnce = true;
protected $_canRefund = true;
protected $_canRefundInvoicePartial = true;
protected $_isGateway = true;
protected $_canUseInternal = true;
/**
* Sepa constructor.
* @param \Magento\Framework\App\RequestInterface $request
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Payment\Model\Method\Logger $logger
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
\Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Payment\Model\Method\Logger $logger,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
$context,
$registry,
$extensionFactory,
$customAttributeFactory,
$paymentData,
$scopeConfig,
$logger,
$resource,
$resourceCollection,
$data
);
$this->_paymentRequest = $paymentRequest;
$this->_urlBuilder = $urlBuilder;
$this->_request = $request;
}
/**
* Assign data to info model instance
*
* @param \Magento\Framework\DataObject|mixed $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function assignData(\Magento\Framework\DataObject $data)
{
parent::assignData($data);
// set data to additionalInformation
$infoInstance = $this->getInfoInstance();
$infoInstance->setAdditionalInformation('account_name', $data['account_name']);
$infoInstance->setAdditionalInformation('iban', $data['iban']);
$infoInstance->setAdditionalInformation('country', $data['country']);
$infoInstance->setAdditionalInformation('accept_sepa', $data['accept_sepa']);
}
/**
* Validate payment method information object
*
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)authorize
*/
public function validate()
{
$infoInstance = $this->getInfoInstance();
$iban = $infoInstance->getAdditionalInformation('iban');
if(empty($iban) || !$this->validateIban($iban)){
throw new \Magento\Framework\Exception\LocalizedException(__('Invalid Iban number.'));
}
return $this;
}
public function validateIban($iban) {
$iban = strtolower(str_replace(' ','',$iban));
$Countries = ['al'=>28,'ad'=>24,'at'=>20,'az'=>28,'bh'=>22,'be'=>16,'ba'=>20,'br'=>29,'bg'=>22,'cr'=>21,'hr'=>21,'cy'=>28,'cz'=>24,'dk'=>18,'do'=>28,'ee'=>20,'fo'=>18,'fi'=>18,'fr'=>27,'ge'=>22,'de'=>22,'gi'=>23,'gr'=>27,'gl'=>18,'gt'=>28,'hu'=>28,'is'=>26,'ie'=>22,'il'=>23,'it'=>27,'jo'=>30,'kz'=>20,'kw'=>30,'lv'=>21,'lb'=>28,'li'=>21,'lt'=>20,'lu'=>20,'mk'=>19,'mt'=>31,'mr'=>27,'mu'=>30,'mc'=>27,'md'=>24,'me'=>22,'nl'=>18,'no'=>15,'pk'=>24,'ps'=>29,'pl'=>28,'pt'=>25,'qa'=>29,'ro'=>24,'sm'=>27,'sa'=>24,'rs'=>22,'sk'=>24,'si'=>19,'es'=>24,'se'=>24,'ch'=>21,'tn'=>24,'tr'=>26,'ae'=>23,'gb'=>22,'vg'=>24];
$Chars = ['a'=>10,'b'=>11,'c'=>12,'d'=>13,'e'=>14,'f'=>15,'g'=>16,'h'=>17,'i'=>18,'j'=>19,'k'=>20,'l'=>21,'m'=>22,'n'=>23,'o'=>24,'p'=>25,'q'=>26,'r'=>27,'s'=>28,'t'=>29,'u'=>30,'v'=>31,'w'=>32,'x'=>33,'y'=>34,'z'=>35];
if(isset($Countries[substr($iban,0,2)]) && strlen($iban) == $Countries[substr($iban,0,2)]){
$MovedChar = substr($iban, 4).substr($iban,0,4);
$MovedCharArray = str_split($MovedChar);
$NewString = "";
foreach($MovedCharArray AS $key => $value){
if(!is_numeric($MovedCharArray[$key])){
$MovedCharArray[$key] = $Chars[$MovedCharArray[$key]];
}
$NewString .= $MovedCharArray[$key];
}
if(bcmod($NewString, '97') == 1)
{
return true;
}
else{
return false;
}
}
else{
return false;
}
}
public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
if (!$this->canAuthorize()) {
throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.'));
}
/*
* do not send order confirmation mail after order creation wait for
* Adyen AUTHORIISATION notification
*/
$order = $payment->getOrder();
$order->setCanSendNewEmailFlag(false);
// do not let magento set status to processing
$payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
// DO authorisation
$this->_processRequest($payment, $amount, "authorise");
return $this;
}
protected function _processRequest(\Magento\Sales\Model\Order\Payment $payment, $amount, $request)
{
switch ($request) {
case "authorise":
$response = $this->_paymentRequest->fullApiRequest($payment, $this->_code);
break;
}
if (!empty($response)) {
$this->_processResponse($payment, $response);
} else {
throw new \Magento\Framework\Exception\LocalizedException(__('Empty result.'));
}
}
protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response)
{
$payment->setAdditionalInformation('3dActive', false);
switch ($response['resultCode']) {
case "Authorised":
//$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status'));
$this->_addStatusHistory($payment, $response['resultCode'], $response['pspReference']);
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "Refused":
$errorMsg = __('The payment is REFUSED.');
$this->_logger->critical($errorMsg);
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break;
}
}
protected function _addStatusHistory($payment, $responseCode, $pspReference)
{
$type = 'Adyen Result URL response:';
$comment = __('%1 <br /> authResult: %2 <br /> pspReference: %3 <br /> paymentMethod: %4', $type, $responseCode, $pspReference, "");
$payment->getOrder()->setAdyenResulturlEventCode($responseCode);
$payment->getOrder()->addStatusHistoryComment($comment);
return $this;
}
/**
* Checkout redirect URL getter for onepage checkout (hardcode)
*
* @see \Magento\Checkout\Controller\Onepage::savePaymentAction()
* @see \Magento\Quote\Model\Quote\Payment::getCheckoutRedirectUrl()
* @return string
*/
public function getCheckoutRedirectUrl()
{
return $this->_urlBuilder->getUrl('checkout/onepage/success/',['_secure' => $this->_getRequest()->isSecure()]);
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function _getRequest()
{
return $this->_request;
}
}
\ No newline at end of file
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<include path="Adyen_Payment::system/adyen_cc.xml"/> <include path="Adyen_Payment::system/adyen_cc.xml"/>
<include path="Adyen_Payment::system/adyen_oneclick.xml"/> <include path="Adyen_Payment::system/adyen_oneclick.xml"/>
<include path="Adyen_Payment::system/adyen_hpp.xml"/> <include path="Adyen_Payment::system/adyen_hpp.xml"/>
<include path="Adyen_Payment::system/adyen_sepa.xml"/>
<include path="Adyen_Payment::system/adyen_pos.xml"/> <include path="Adyen_Payment::system/adyen_pos.xml"/>
</group> </group>
<group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> <group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
......
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_sepa" translate="label" type="text" sortOrder="250" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[SEPA integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process SEPA transactions</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_sepa/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_sepa/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_sepa/sort_order</config_path>
</field>
<group id="adyen_sepa_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_sepa/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="50" 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>
<config_path>payment/adyen_sepa/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
...@@ -74,13 +74,22 @@ ...@@ -74,13 +74,22 @@
<order_place_redirect_url>adyen/process/redirect</order_place_redirect_url> <order_place_redirect_url>adyen/process/redirect</order_place_redirect_url>
<group>adyen</group> <group>adyen</group>
</adyen_hpp> </adyen_hpp>
<adyen_sepa>
<active>0</active>
<model>Adyen\Payment\Model\Method\Sepa</model>
<title>Sepa Direct Debit</title>
<allowspecific>0</allowspecific>
<sort_order>4</sort_order>
<payment_action>authorize</payment_action>
<group>adyen</group>
</adyen_sepa>
<adyen_pos> <adyen_pos>
<active>0</active> <active>0</active>
<model>Adyen\Payment\Model\Method\Pos</model> <model>Adyen\Payment\Model\Method\Pos</model>
<order_status>pending</order_status> <order_status>pending</order_status>
<title>Adyen POS</title> <title>Adyen POS</title>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>4</sort_order> <sort_order>5</sort_order>
<place_order_url>adyen/process/redirect</place_order_url> <place_order_url>adyen/process/redirect</place_order_url>
<order_place_redirect_url>adyen/process/redirect</order_place_redirect_url> <order_place_redirect_url>adyen/process/redirect</order_place_redirect_url>
<group>adyen</group> <group>adyen</group>
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenCcConfigProvider</item> <item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenCcConfigProvider</item>
<item name="adyen_oneclick_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenOneclickConfigProvider</item> <item name="adyen_oneclick_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenOneclickConfigProvider</item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item> <item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item>
<item name="adyen_sepa_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenSepaConfigProvider</item>
</argument> </argument>
</arguments> </arguments>
</type> </type>
......
...@@ -36,9 +36,6 @@ ...@@ -36,9 +36,6 @@
<method name="adyen_hpp"> <method name="adyen_hpp">
<allow_multiple_address>1</allow_multiple_address> <allow_multiple_address>1</allow_multiple_address>
</method> </method>
<method name="test">
<allow_multiple_address>1</allow_multiple_address>
</method>
</methods> </methods>
</payment> </payment>
......
...@@ -55,6 +55,9 @@ ...@@ -55,6 +55,9 @@
<item name="adyen_hpp" xsi:type="array"> <item name="adyen_hpp" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item> <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item> </item>
<item name="adyen_sepa" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
</item> </item>
</item> </item>
</item> </item>
......
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
background-position: 0 -1819px; background-position: 0 -1819px;
} }
.checkout-payment-method .payment-method-title label div.adyen-sprite.adyen_sepa {
background-position: 0 -1910px;
}
......
...@@ -44,6 +44,10 @@ define( ...@@ -44,6 +44,10 @@ define(
type: 'adyen_hpp', type: 'adyen_hpp',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-hpp-method' component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-hpp-method'
}, },
{
type: 'adyen_sepa',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-sepa-method'
},
{ {
type: 'adyen_pos', type: 'adyen_pos',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-pos-method' component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-pos-method'
......
...@@ -34,11 +34,6 @@ define( ...@@ -34,11 +34,6 @@ define(
function (_, $, Component, placeOrderAction, $t, additionalValidators, adyenEncrypt) { function (_, $, Component, placeOrderAction, $t, additionalValidators, adyenEncrypt) {
'use strict'; 'use strict';
$.validator.addMethod(
'validate-custom-required', function (value) {
return (value === 'test'); // Validation logic here
}, $.mage.__('Enter This is a required field custom.')
);
return Component.extend({ return Component.extend({
defaults: { defaults: {
template: 'Adyen_Payment/payment/cc-form', template: 'Adyen_Payment/payment/cc-form',
......
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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(
[
'underscore',
'jquery',
'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
],
function (_, $, Component, placeOrderAction, $t, additionalValidators) {
'use strict';
return Component.extend({
self: this,
defaults: {
template: 'Adyen_Payment/payment/sepa-form'
},
initObservable: function () {
this._super()
.observe([
'accountName',
'iban',
'country',
'setAcceptSepa'
]);
return this;
},
setPlaceOrderHandler: function(handler) {
this.placeOrderHandler = handler;
},
setValidateHandler: function(handler) {
this.validateHandler = handler;
},
getCode: function() {
return 'adyen_sepa';
},
getData: function() {
return {
'method': this.item.method,
'additional_data': {
'account_name': this.accountName(),
'iban': this.iban(),
'country': this.country(),
'accept_sepa': this.setAcceptSepa()
}
};
},
isActive: function() {
return true;
},
/**
* @override
*/
placeOrder: function(data, event) {
var self = this,
placeOrder;
if (event) {
event.preventDefault();
}
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(response) {
self.isPlaceOrderActionAllowed(true);
});
return true;
}
return false;
},
getControllerName: function() {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
},
getPlaceOrderUrl: function() {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
},
context: function() {
return this;
},
validate: function () {
var form = 'form[data-role=adyen-sepa-form]';
var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) {
return false;
}
return true;
},
showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo;
},
getCountries: function() {
return _.map(window.checkoutConfig.payment.adyenSepa.countries, function(value, key) {
return {
'key': key,
'value': value
}
});
}
});
}
);
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
-->
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
<div class="payment-method-title field choice">
<input type="radio"
name="payment[method]"
class="radio"
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label data-bind="attr: {'for': getCode()}" class="label">
<!-- ko if: showLogo() -->
<div data-bind="attr: { 'class': 'adyen-sprite ' + getCode() }"></div>
<!--/ko-->
<span data-bind="text: getTitle()"></span>
</label>
</div>
<div class="payment-method-content">
<div class="payment-method-billing-address">
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<form class="form" id="adyen-sepa-form" data-role="adyen-sepa-form" action="#" method="post" data-bind="mageInit: {
'transparent':{
'context': context(),
'controller': getControllerName(),
'orderSaveUrl':getPlaceOrderUrl(),
}, 'validation':[]}">
<fieldset data-bind="attr: {class: 'fieldset payment items adyen_sepa ' + getCode(), id: 'payment_form_' + getCode()}">
<!-- ko if: (isShowLegend())-->
<legend class="legend">
<span><!-- ko text: $t('Sepa Information')--><!-- /ko --></span>
</legend><br />
<!-- /ko -->
<div class="field accountname type required">
<label data-bind="attr: {for: getCode() + '_account_name'}" class="label">
<span><!-- ko text: $t('Bank account holder name')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text"
name="payment[account_name]"
autocomplete="off"
data-bind="attr: {id: getCode() + '_account_name', 'data-container': getCode() + '-account-name', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
value: accountName"
data-validate="{required:true}">
</input>
</div>
</div>
<div class="field iban type required">
<label data-bind="attr: {for: getCode() + '_iban'}" class="label">
<span><!-- ko text: $t('IBAN')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text"
name="payment[iban]"
autocomplete="off"
data-bind="attr: {id: getCode() + '_iban', 'data-container': getCode() + '-iban', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
value: iban"
data-validate="{required:true}">
</input>
</div>
</div>
<div class="field country type required">
<label data-bind="attr: {for: getCode() + '_country'}" class="label">
<span><!-- ko text: $t('Country')--><!-- /ko --></span>
</label>
<div class="control">
<select class="select select-country"
name="payment[country]"
data-bind="attr: {id: getCode() + '_country', 'data-container': getCode() + '-country', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
options: getCountries(),
optionsValue: 'key',
optionsText: 'value',
optionsCaption: $t('Select your country'),
value: country"
data-validate="{required:true}">
</select>
</div>
</div>
<div class="field choice required">
<input type="checkbox"
name="payment[accept_sepa]"
autocomplete="off"
class="checkbox"
data-bind="attr: {id: getCode() + '_accept_sepa', title: $t('I agree that the above amount will be debited from my bank account.')}, checked: setAcceptSepa"
data-validate="{required:true}"
/>
<label data-bind="attr: {for: getCode() + '_accept_sepa'}" class="label">
<span><!-- ko text: $t('I agree that the above amount will be debited from my bank account.')--><!-- /ko --></span>
</label>
</div>
</fieldset>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
css: {disabled: !isPlaceOrderActionAllowed()}
"
disabled>
<span data-bind="text: $t('Place Order')"></span>
</button>
</div>
</div>
</div>
</div>
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