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 863c0bb4 authored by Rik ter Beek's avatar Rik ter Beek

#59 add payment method Boleto

parent cddb1830
<?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\Checkout;
/**
* Billing agreement information on Order success page
*/
class Success extends \Magento\Framework\View\Element\Template
{
/**
* @var \Magento\Sales\Model\Order $order
*/
protected $_order;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
/**
* @var \Magento\Checkout\Model\OrderFactory
*/
protected $_orderFactory;
/**
* Success constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Sales\Model\OrderFactory $orderFactory,
array $data = []
) {
$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
parent::__construct($context, $data);
}
/**
* Return Boleto PDF url
*
* @return string
*/
protected function _toHtml()
{
if ($this->isBoletoPayment()) {
$this->addData(
[
'boleto_pdf_url' => $this->getBoletoPdfUrl()
]
);
return parent::_toHtml();
}
return '';
}
/**
* Detect if Boleto is used as payment method
* @return bool
*/
public function isBoletoPayment()
{
if ($this->getOrder()->getPayment() &&
$this->getOrder()->getPayment()->getMethod() == \Adyen\Payment\Model\Method\Boleto::METHOD_CODE) {
return true;
}
return false;
}
/**
* @return null|\string[]
*/
public function getBoletoPdfUrl()
{
if ($this->isBoletoPayment()) {
return $this->getOrder()->getPayment()->getAdditionalInformation('url');
}
return null;
}
/**
* @return \Magento\Sales\Model\Order
*/
public function getOrder()
{
if ($this->_order == null) {
$this->_order = $this->_orderFactory->create()->load($this->_checkoutSession->getLastOrderId());
}
return $this->_order;
}
}
\ 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\Block\Form;
class Boleto extends \Magento\Payment\Block\Form
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::form/boleto.phtml';
}
\ 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\Block\Info;
class Boleto extends AbstractInfo
{
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_boleto.phtml';
}
......@@ -386,6 +386,28 @@ class Data extends AbstractHelper
return $this->getConfigData($field, 'adyen_pay_by_mail', $storeId, true);
}
/**
* @desc Gives back adyen_boleto configuration values
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenBoletoConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_boleto', $storeId);
}
/**
* @desc Gives back adyen_boleto configuration values as flag
* @param $field
* @param null $storeId
* @return mixed
*/
public function getAdyenBoletoConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_boleto', $storeId, true);
}
/**
* @desc Retrieve decrypted hmac key
* @return string
......@@ -585,4 +607,30 @@ class Data extends AbstractHelper
{
return (string) $this->_moduleList->getOne("Adyen_Payment")['setup_version'];
}
public function getBoletoTypes()
{
return [
[
'value' => 'boletobancario_hsbc',
'label' => __('boletobancario_hsbc'),
],
[
'value' => 'boletobancario_itau',
'label' => __('boletobancario_itau'),
],
[
'value' => 'boletobancario_santander',
'label' => __('boletobancario_santander'),
],
[
'value' => 'boletobancario_bradesco',
'label' => __('boletobancario_bradesco'),
],
[
'value' => 'boletobancario_bancodobrasil',
'label' => __('boletobancario_bancodobrasil'),
],
];
}
}
\ 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\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
class AdyenBoletoConfigProvider implements ConfigProviderInterface
{
/**
* @var PaymentHelper
*/
protected $_paymentHelper;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* @var string[]
*/
protected $_methodCodes = [
\Adyen\Payment\Model\Method\Boleto::METHOD_CODE
];
/**
* @var \Magento\Payment\Model\Method\AbstractMethod[]
*/
protected $_methods = [];
/**
* AdyenBoletoConfigProvider constructor.
*
* @param \Magento\Payment\Helper\Data $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Magento\Payment\Helper\Data $paymentHelper,
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper;
foreach ($this->_methodCodes as $code) {
$this->_methods[$code] = $this->_paymentHelper->getMethodInstance($code);
}
}
/**
* @return array
*/
public function getConfig()
{
$config = [];
foreach ($this->_methodCodes as $code) {
if ($this->_methods[$code]->isAvailable()) {
$config = [
'payment' => [
'adyenBoleto' => [
'boletoTypes' => $this->_adyenHelper->getBoletoTypes()
]
]
];
}
}
return $config;
}
}
\ No newline at end of file
......@@ -51,7 +51,8 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
\Adyen\Payment\Model\Method\Hpp::METHOD_CODE,
\Adyen\Payment\Model\Method\Oneclick::METHOD_CODE,
\Adyen\Payment\Model\Method\Pos::METHOD_CODE,
\Adyen\Payment\Model\Method\Sepa::METHOD_CODE
\Adyen\Payment\Model\Method\Sepa::METHOD_CODE,
\Adyen\Payment\Model\Method\Boleto::METHOD_CODE
];
/**
......
......@@ -281,6 +281,12 @@ class PaymentRequest extends DataObject
$cardDetails['card'] = $requestCreditCardDetails;
$request = array_merge($request, $cardDetails);
}
// if installments is set add it into the request
if ($payment->getAdditionalInformation('number_of_installments') &&
$payment->getAdditionalInformation('number_of_installments') > 0) {
$request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments');
}
} elseif ($paymentMethodCode == \Adyen\Payment\Model\Method\Sepa::METHOD_CODE) {
// set brand to sepa
......@@ -294,14 +300,34 @@ class PaymentRequest extends DataObject
];
$request['bankAccount'] = $bankAccount;
}
} elseif ($paymentMethodCode == \Adyen\Payment\Model\Method\Boleto::METHOD_CODE) {
// if installments is set add it into the request
if ($payment->getAdditionalInformation('number_of_installments') &&
$payment->getAdditionalInformation('number_of_installments') > 0) {
$request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments');
}
$request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number");
$request['selectedBrand'] = $payment->getAdditionalInformation("boleto_type");
$shopperName = [
'firstName' => $payment->getAdditionalInformation("firstname"),
'lastName' => $payment->getAdditionalInformation("lastname"),
];
$request['shopperName'] = $shopperName;
$deliveryDays = (int) $this->_adyenHelper->getAdyenBoletoConfigData("delivery_days", $storeId);
$deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5;
$deliveryDate = date(
"Y-m-d\TH:i:s ",
mktime(date("H"),
date("i"),
date("s"),
date("m"),
date("j") + $deliveryDays,
date("Y"))
);
$request['deliveryDate'] = $deliveryDate;
}
$result = $service->authorise($request);
return $result;
}
......
<?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\Config\Source;
/**
* Class BoletoType
* @package Adyen\Payment\Model\Config\Source
*/
class BoletoType implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* BoletoType constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function toOptionArray()
{
return $this->_adyenHelper->getBoletoTypes();
}
}
<?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 Boleto extends \Magento\Payment\Model\Method\AbstractMethod
{
const METHOD_CODE = 'adyen_boleto';
/**
* @var string
*/
protected $_code = self::METHOD_CODE;
/**
* @var string
*/
protected $_formBlockType = 'Adyen\Payment\Block\Form\Boleto';
/**
* @var string
*/
protected $_infoBlockType = 'Adyen\Payment\Block\Info\Boleto';
/**
* @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;
/**
* @var bool
*/
protected $_canCapture = true;
/**
* @var bool
*/
protected $_canCapturePartial = true;
/**
* @var bool
*/
protected $_canCaptureOnce = true;
/**
* @var bool
*/
protected $_canRefund = true;
/**
* @var bool
*/
protected $_canRefundInvoicePartial = true;
/**
* @var bool
*/
protected $_isGateway = true;
/**
* @var bool
*/
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);
if (!$data instanceof \Magento\Framework\DataObject) {
$data = new \Magento\Framework\DataObject($data);
}
$additionalData = $data->getAdditionalData();
$infoInstance = $this->getInfoInstance();
$infoInstance->setAdditionalInformation('social_security_number', $additionalData['social_security_number']);
$infoInstance->setAdditionalInformation('boleto_type', $additionalData['boleto_type']);
$infoInstance->setAdditionalInformation('firstname', $additionalData['firstname']);
$infoInstance->setAdditionalInformation('lastname', $additionalData['lastname']);
}
/**
* @param \Magento\Payment\Model\InfoInterface $payment
* @param float $amount
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
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 let magento set status to processing
$payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
// Do authorisation
$this->_processRequest($payment, "authorise");
return $this;
}
/**
* @param \Magento\Sales\Model\Order\Payment $payment
* @param $amount
* @param $request
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _processRequest(\Magento\Sales\Model\Order\Payment $payment, $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.'));
}
}
/**
* @param \Magento\Payment\Model\InfoInterface $payment
* @param $response
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response)
{
$payment->setAdditionalInformation('3dActive', false);
switch ($response['resultCode']) {
case "Received":
$this->_addStatusHistory($payment, $response['resultCode'], $response['pspReference']);
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
if (isset($response['additionalData']) && is_array($response['additionalData'])) {
$additionalData = $response['additionalData'];
if (isset($additionalData['boletobancario.dueDate'])) {
$payment->setAdditionalInformation(
'dueDate',
$additionalData['boletobancario.dueDate']
);
}
if (isset($additionalData['boletobancario.expirationDate'])) {
$payment->setAdditionalInformation(
'expirationDate',
$additionalData['boletobancario.expirationDate']
);
}
if (isset($additionalData['boletobancario.url'])) {
$payment->setAdditionalInformation(
'url',
$additionalData['boletobancario.url']
);
}
}
break;
case "Refused":
$errorMsg = __('The payment is REFUSED.');
$this->_logger->critical($errorMsg);
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break;
default:
$errorMsg = __('Error with payment method please select different payment method.');
$this->_logger->critical($errorMsg);
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break;
}
}
/**
* @param $payment
* @param $responseCode
* @param $pspReference
* @return $this
*/
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
......@@ -43,6 +43,7 @@
<include path="Adyen_Payment::system/adyen_sepa.xml"/>
<include path="Adyen_Payment::system/adyen_pos.xml"/>
<include path="Adyen_Payment::system/adyen_pay_by_mail.xml"/>
<include path="Adyen_Payment::system/adyen_boleto.xml"/>
</group>
<group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test</label>
......
<?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_boleto" translate="label" type="text" sortOrder="450" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Boleto integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process Boleto 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_boleto/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_boleto/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_boleto/sort_order</config_path>
</field>
<field id="cctypes" translate="label" type="multiselect" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Boleto Types</label>
<source_model>Adyen\Payment\Model\Config\Source\BoletoType</source_model>
<config_path>payment/adyen_boleto/boletotypes</config_path>
</field>
<field id="delivery_days" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Days for Delivery</label>
<tooltip>How many days to be added to the current date for delivery. Only numbers allowed.</tooltip>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_boleto/delivery_days</config_path>
</field>
<group id="adyen_boleto_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_boleto/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_boleto/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
......@@ -107,6 +107,16 @@
<payment_action>authorize</payment_action>
<group>adyen</group>
</adyen_pay_by_mail>
<adyen_boleto>
<active>0</active>
<model>Adyen\Payment\Model\Method\Boleto</model>
<title>Boleto</title>
<allowspecific>0</allowspecific>
<sort_order>7</sort_order>
<payment_action>authorize</payment_action>
<delivery_days>5</delivery_days>
<group>adyen</group>
</adyen_boleto>
</payment>
</default>
</config>
......@@ -32,6 +32,7 @@
<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_sepa_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenSepaConfigProvider</item>
<item name="adyen_boleto_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenBoletoConfigProvider</item>
</argument>
</arguments>
</type>
......
<?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>
*/
// @codingStandardsIgnoreFile
$code = $block->escapeHtml($block->getMethodCode());
?>
<fieldset class="admin__fieldset payment-method" id="payment_form_<?php /* @noEscape */ echo $code; ?>"
style="display:none">
</fieldset>
\ 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>
*/
// @codingStandardsIgnoreFile
?>
<?php
/**
* @see \Magento\Payment\Block\Info
*/
?>
<?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?>
<?php
$_info = $this->getInfo();
$_isDemoMode = $block->isDemoMode();
?>
<?php if ($_pspReference = $_info->getAdditionalInformation('pspReference')):?>
<div>
<?php if($_isDemoMode): ?>
<?php echo __('Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>', $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
<?php else: ?>
<?php echo __('Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>', $block->escapeHtml($_pspReference), $block->escapeHtml($_pspReference)) ?>
<?php endif; ?>
</div>
<?php endif;?>
<?php if ($_brandCode = $_info->getAdditionalInformation('brand_code')):?>
<div><?php echo __('Payment Method: %1', $_brandCode); ?>
</div>
<?php endif;?>
<?php if($_info->getAdditionalInformation('social_security_number') != ""): ?>
<div>
<?php echo __('Social Security Number: %1', $_info->getAdditionalInformation('social_security_number')) ?>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('boleto_type') != ""): ?>
<div>
<?php echo __('Boleto Type: %1', $_info->getAdditionalInformation('boleto_type')) ?>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('firstname') != ""): ?>
<div>
<?php echo __('Firstname: %1', $_info->getAdditionalInformation('firstname')) ?>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('lastname') != ""): ?>
<div>
<?php echo __('Firstname: %1', $_info->getAdditionalInformation('lastname')) ?>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('expirationDate') != ""): ?>
<div>
<?php echo __('Expiration Date: %1', $_info->getAdditionalInformation('expirationDate')) ?>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('dueDate') != ""): ?>
<div>
<?php echo __('Due Date: %1', $_info->getAdditionalInformation('dueDate')) ?>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('url') != ""): ?>
<div>
<a target="_blank" href="<?php echo $_info->getAdditionalInformation('url'); ?>"><?php echo __('PDF Url'); ?></a>
</div>
<?php endif; ?>
<?php if($_info->getAdditionalInformation('adyen_total_fraud_score') != ""): ?>
<div>
<?php echo __('Total fraud score: %1', $_info->getAdditionalInformation('adyen_total_fraud_score')) ?>
</div>
<?php endif; ?>
<?php if ($_specificInfo = $block->getSpecificInformation()):?>
<table class="data-table admin__table-secondary">
<?php foreach ($_specificInfo as $_label => $_value):?>
<tr>
<th><?php echo $block->escapeHtml($_label)?>:</th>
<td><?php echo nl2br(implode("\n", $block->getValueAsArray($_value, true)))?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif;?>
<?php echo $block->getChildHtml()?>
\ No newline at end of file
......@@ -58,6 +58,9 @@
<item name="adyen_sepa" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
<item name="adyen_boleto" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
</item>
</item>
</item>
......
<?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>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="order.success.additional.info">
<block class="Adyen\Payment\Block\Checkout\Success" name="onepage.success.adyen_payment" template="checkout/success.phtml"/>
</referenceContainer>
</body>
</page>
<?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>
*/
/**
* @var \Adyen\Payment\Block\Checkout\Success $block
*/
?>
<?php if ($block->isBoletoPayment()):?>
<p>
<?php echo $block->escapeHtml(__('Boleto PDF: ')); ?>
<a href="<?php echo $block->escapeUrl($block->getBoletoPdfUrl()); ?>">
<?php echo $block->escapeHtml(__('Click here to download the Boleto PDF')); ?>
</a>
</p>
<?php endif; ?>
<?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>
*/
// @codingStandardsIgnoreFile
?>
<?php
$_info = $this->getInfo();
?>
<dl class="payment-method adyen_cc">
<dt class="title"><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></dt>
<dt class="title"><?php echo $_info->getAdditionalInformation('social_security_number'); ?></dt>
<dt class="title"><?php echo $_info->getAdditionalInformation('boleto_type'); ?></dt>
<dt class="title"><?php echo $_info->getAdditionalInformation('firstname'); ?></dt>
<dt class="title"><?php echo $_info->getAdditionalInformation('lastname'); ?></dt>
<dt class="title">><a target="_blank" href="<?php echo $this->getMethod()->getInfoInstance()->getAdditionalInformation('url'); ?>"><?php echo __("Click here to download Boleto PDF."); ?></a></dt>
</dl>
......@@ -51,6 +51,10 @@ define(
{
type: 'adyen_pos',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-pos-method'
},
{
type: 'adyen_boleto',
component: 'Adyen_Payment/js/view/payment/method-renderer/adyen-boleto-method'
}
);
/** Add view logic here if needed */
......
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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_Checkout/js/model/quote',
'Magento_Payment/js/view/payment/cc-form',
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators'
],
function (_, $, quote, Component, placeOrderAction, $t, additionalValidators) {
'use strict';
var billingAddress = quote.billingAddress();
return Component.extend({
self: this,
defaults: {
template: 'Adyen_Payment/payment/boleto-form',
firstname: billingAddress.firstname,
lastname: billingAddress.lastname
},
initObservable: function () {
this._super()
.observe([
'socialSecurityNumber',
'boletoType',
'firstname',
'lastname'
]);
return this;
},
setPlaceOrderHandler: function(handler) {
this.placeOrderHandler = handler;
},
setValidateHandler: function(handler) {
this.validateHandler = handler;
},
getCode: function() {
return 'adyen_boleto';
},
getData: function() {
return {
'method': this.item.method,
'additional_data': {
'social_security_number': this.socialSecurityNumber(),
'boleto_type': this.boletoType(),
'firstname': this.firstname(),
'lastname': this.lastname()
}
};
},
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-boleto-form]';
var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) {
return false;
}
return true;
},
showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo;
},
getBoletoTypes: function() {
return _.map(window.checkoutConfig.payment.adyenBoleto.boletoTypes, function(value, key) {
return {
'key': value.value,
'value': value.label
}
});
}
});
}
);
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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-boleto-form" data-role="adyen-boleto-form" action="#" method="post" data-bind="mageInit: {
'transparent':{
'context': context(),
'controller': getControllerName(),
'orderSaveUrl':getPlaceOrderUrl(),
}, 'validation':[]}">
<fieldset data-bind="attr: {class: 'fieldset payment items adyen_boleto ' + 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 _social_security_number type required">
<label data-bind="attr: {for: getCode() + '_social_security_number'}" class="label">
<span><!-- ko text: $t('Social Security Number')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text"
name="payment[social_security_number]"
autocomplete="off"
data-bind="attr: {id: getCode() + '_social_security_number', 'data-container': getCode() + '-social-security-number', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
value: socialSecurityNumber"
data-validate="{required:true}">
</input>
</div>
</div>
<div class="field boleto_type type required">
<label data-bind="attr: {for: getCode() + '_boleto_type'}" class="label">
<span><!-- ko text: $t('Boleto Card Type')--><!-- /ko --></span>
</label>
<div class="control">
<select class="select select-boleto-type"
name="payment[boleto_type]"
data-bind="attr: {id: getCode() + '_boleto_type', 'data-container': getCode() + '-boleto-type', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
options: getBoletoTypes(),
optionsValue: 'key',
optionsText: 'value',
optionsCaption: $t('-Please select-'),
value: boletoType"
data-validate="{required:true}">
</select>
</div>
</div>
<div class="field firstname type required">
<label data-bind="attr: {for: getCode() + 'firstname'}" class="label">
<span><!-- ko text: $t('Firstname')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text"
name="payment[firstname]"
autocomplete="off"
data-bind="attr: {id: getCode() + '_firstname', 'data-container': getCode() + '-firstname', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
value: firstname"
data-validate="{required:true}">
</input>
</div>
</div>
<div class="field _lastname type required">
<label data-bind="attr: {for: getCode() + '_lastname'}" class="label">
<span><!-- ko text: $t('Lastname')--><!-- /ko --></span>
</label>
<div class="control">
<input type="text"
class="input-text"
name="payment[lastname]"
autocomplete="off"
data-bind="attr: {id: getCode() + '_lastname', 'data-container': getCode() + '-lastname', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
value: lastname"
data-validate="{required:true}">
</input>
</div>
</div>
</fieldset>
</form>
<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