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

Merge pull request #81 from Adyen/develop

Merge 'develop' branche
parents 2261d06f f168d9d7
......@@ -37,6 +37,10 @@ interface NotificationInterface
* Pspreference.
*/
const PSPREFRENCE = 'pspreference';
/*
* Pspreference.
*/
const ORIGINAL_REFERENCE = 'original_reference';
/*
* Merchantreference
*/
......@@ -117,6 +121,22 @@ interface NotificationInterface
*/
public function setPspreference($pspreference);
/**
* Sets OriginalReference.
*
* @param string $originalReference
* @return $this
*/
public function setOriginalReference($originalReference);
/**
* Gets the OriginalReference for the notification.
*
* @return int|null OriginalReference.
*/
public function getOriginalReference();
/**
* Gets the Merchantreference for the notification.
*
......
<?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\Api\Data;
interface OrderPaymentInterface
{
/**#@+
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/
/*
* Entity ID.
*/
const ENTITY_ID = 'entity_id';
/*
* Pspreference.
*/
const PSPREFRENCE = 'pspreference';
/*
* Merchantreference
*/
const MERCHANT_REFERENCE = 'merchant_reference';
/*
* payment_id
*/
const PAYMENT_ID = 'payment_id';
/*
* Paymentmethod
*/
const PAYMENT_METHOD = 'payment_method';
/*
* Amount
*/
const AMOUNT = 'amount';
/*
* Amount
*/
const TOTAL_REFUNDED = 'total_refunded';
/*
* Created-at timestamp.
*/
const CREATED_AT = 'created_at';
/*
* Updated-at timestamp.
*/
const UPDATED_AT = 'updated_at';
/**
* Gets the ID for the payment.
*
* @return int|null Entity ID.
*/
public function getEntityId();
/**
* Sets entity ID.
*
* @param int $entityId
* @return $this
*/
public function setEntityId($entityId);
/**
* Gets the Pspreference for the payment.
*
* @return int|null Pspreference.
*/
public function getPspreference();
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference);
/**
* Gets the Merchantreference for the payment.
*
* @return int|null MerchantReference.
*/
public function getMerchantReference();
/**
* Sets MerchantReference.
*
* @param string $merchantReference
* @return $this
*/
public function setMerchantReference($merchantReference);
/**
* Gets the PaymentId for the payment.
*
* @return int|null PaymentId.
*/
public function getPaymentId();
/**
* Sets PaymentId.
*
* @param string $paymentId
* @return $this
*/
public function setPaymentId($paymentId);
/**
* Gets the Paymentmethod for the payment.
*
* @return int|null PaymentMethod.
*/
public function getPaymentMethod();
/**
* Sets PaymentMethod.
*
* @param string $paymentMethod
* @return $this
*/
public function setPaymentMethod($paymentMethod);
/**
* Gets the Amount for the payment.
*
* @return int|null Amount.
*/
public function getAmount();
/**
* Sets Amount.
*
* @param string $amount
* @return $this
*/
public function setAmount($amount);
/**
* Gets the TotalRefunded for the payment.
*
* @return int|null TotalRefunded.
*/
public function getTotalRefunded();
/**
* Sets Total Refunded.
*
* @param string $totalRefunded
* @return $this
*/
public function setTotalRefunded($totalRefunded);
/**
* Gets the created-at timestamp for the payment.
*
* @return string|null Created-at timestamp.
*/
public function getCreatedAt();
/**
* Sets the created-at timestamp for the payment.
*
* @param string $createdAt timestamp
* @return $this
*/
public function setCreatedAt($createdAt);
/**
* Gets the updated-at timestamp for the payment.
*
* @return string|null Updated-at timestamp.
*/
public function getUpdatedAt();
/**
* Sets the updated-at timestamp for the payment.
*
* @param string $timestamp
* @return $this
*/
public function setUpdatedAt($timestamp);
}
\ 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\Adminhtml\System\Config\Field;
class Cctypes extends \Magento\Framework\View\Element\Html\Select
{
/**
* All possible credit card types
*
* @var array
*/
protected $ccTypes = [];
/**
* @var \Magento\Braintree\Model\Source\CcType
*/
protected $ccTypeSource;
/**
* Cctypes constructor.
*
* @param \Magento\Framework\View\Element\Context $context
* @param \Adyen\Payment\Model\Config\Source\CcType $ccTypeSource
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Context $context,
\Adyen\Payment\Model\Config\Source\CcType $ccTypeSource,
array $data = []
) {
parent::__construct($context, $data);
$this->ccTypeSource = $ccTypeSource;
}
/**
* Render block HTML
*
* @return string
*/
public function _toHtml()
{
if (!$this->getOptions()) {
foreach ($this->_getCcTypes() as $country) {
if (isset($country['value']) && $country['value'] && isset($country['label']) && $country['label']) {
$this->addOption($country['value'], $country['label']);
}
}
}
$this->setClass('cc-type-select');
$this->setExtraParams('multiple="multiple"');
return parent::_toHtml();
}
/**
* All possible credit card types
*
* @return array
*/
protected function _getCcTypes()
{
if (!$this->ccTypes) {
$this->ccTypes = $this->ccTypeSource->toOptionArray();
}
return $this->ccTypes;
}
/**
* Sets name for input element
*
* @param string $value
* @return $this
*/
public function setInputName($value)
{
return $this->setName($value . '[]');
}
}
<?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\Adminhtml\System\Config\Field;
class Installment extends \Magento\Framework\View\Element\Html\Select
{
/**
* Options
*
* @var array
*/
protected $_options = [ '1' => '1x',
'2' => '2x',
'3' => '3x',
'4' => '4x',
'5' => '5x',
'6' => '6x',
'7' => '7x',
'8' => '8x',
'9' => '9x',
'10' => '10x',
'11' => '11x',
'12' => '12x'
];
/**
* Sets name for input element
*
* @param string $value
* @return $this
*/
public function setInputName($value)
{
return $this->setName($value);
}
}
<?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\Adminhtml\System\Config\Field;
class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
/**
* @var \Adyen\Payment\Block\Adminhtml\System\Config\Field\Installment
*/
protected $_installmentRenderer = null;
/**
* @var \Magento\Braintree\Block\Adminhtml\Form\Field\CcTypes
*/
protected $_ccTypesRenderer = null;
/**
* Return renderer for installments
*
* @return Installment|\Magento\Framework\View\Element\BlockInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function getNumberOfInstallmentsRenderer()
{
if (!$this->_installmentRenderer) {
$this->_installmentRenderer = $this->getLayout()->createBlock(
'\Adyen\Payment\Block\Adminhtml\System\Config\Field\Installment',
'',
['data' => ['is_render_to_js_template' => true]]
);
}
return $this->_installmentRenderer;
}
/**
* Returns renderer for country element
*
* @return \Magento\Braintree\Block\Adminhtml\Form\Field\Cctypes
*/
protected function getCcTypesRenderer()
{
if (!$this->_ccTypesRenderer) {
$this->_ccTypesRenderer = $this->getLayout()->createBlock(
'\Adyen\Payment\Block\Adminhtml\System\Config\Field\Cctypes',
'',
['data' => ['is_render_to_js_template' => true]]
);
}
return $this->_ccTypesRenderer;
}
/**
* Prepare to render
* @return void
*/
protected function _prepareToRender()
{
$this->addColumn(
'amount',
[
'label' => __('Amount Range (minor units)'),
'renderer' => false,
]
);
$this->addColumn(
'installments',
[
'label' => __('Max Number Of Installments'),
'renderer' => $this->getNumberOfInstallmentsRenderer(),
]
);
$this->addColumn(
'cc_types',
[
'label' => __('Allowed Credit Card Types'),
'renderer' => $this->getCcTypesRenderer(),
]
);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add Rule');
}
/**
* Prepare existing row data object
*
* @param \Magento\Framework\DataObject $row
* @return void
*/
protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
{
$installlments = $row->getInstallments();
$options = [];
if ($installlments) {
$options['option_' . $this->getNumberOfInstallmentsRenderer()->calcOptionHash($installlments)]
= 'selected="selected"';
$ccTypes = $row->getCcTypes();
if (!is_array($ccTypes)) {
$ccTypes = [$ccTypes];
}
foreach ($ccTypes as $cardType) {
$options['option_' . $this->getCcTypesRenderer()->calcOptionHash($cardType)]
= 'selected="selected"';
}
}
$row->setData('option_extra_attrs', $options);
return;
}
}
<?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\Ui\AdyenBoletoConfigProvider::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';
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* Boleto constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Adyen\Payment\Helper\Data $adyenHelper,
array $data = []
) {
parent::__construct($context, $data);
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function getBoletoTypes()
{
$boletoTypes = $this->_adyenHelper->getBoletoTypes();
$types = [];
foreach ($boletoTypes as $boletoType) {
$types[$boletoType['value']] = $boletoType['label'];
}
return $types;
}
}
\ No newline at end of file
......@@ -29,4 +29,49 @@ class Oneclick extends \Adyen\Payment\Block\Form\Cc
* @var string
*/
protected $_template = 'Adyen_Payment::form/oneclick.phtml';
/**
* @var \Magento\Backend\Model\Session\Quote
*/
protected $_sessionQuote;
/**
* Cc constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Payment\Model\Config $paymentConfig,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Backend\Model\Session\Quote $sessionQuote,
array $data = []
) {
parent::__construct($context, $paymentConfig, $adyenHelper, $checkoutSession, $data);
$this->_sessionQuote = $sessionQuote;
}
/**
* @return array
*/
public function getOneClickCards()
{
$customerId = $this->_sessionQuote->getCustomerId();
$storeId = $this->_sessionQuote->getStoreId();
$grandTotal = $this->_sessionQuote->getQuote()->getGrandTotal();
// For backend only allow recurring payments
$recurringType = \Adyen\Payment\Model\RecurringType::RECURRING;
$cards = $this->_adyenHelper->getOneClickPaymentMethods($customerId, $storeId, $grandTotal, $recurringType);
return $cards;
}
}
\ No newline at end of file
......@@ -40,8 +40,8 @@ class Sepa extends \Magento\Payment\Block\Form
* Sepa constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
......
......@@ -32,23 +32,30 @@ class AbstractInfo extends \Magento\Payment\Block\Info
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* @var \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory
*/
protected $_adyenOrderPaymentCollectionFactory;
/**
* Constructor
*
* AbstractInfo constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param Template\Context $context
* @param array $data
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
Template\Context $context,
array $data = []
)
{
parent::__construct($context, $data);
$this->_adyenHelper = $adyenHelper;
$this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory;
}
/**
......
<?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';
}
......@@ -39,4 +39,22 @@ class Hpp extends AbstractInfo
{
return $this->_adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen');
}
/**
* @return null
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getSplitPayments()
{
// retrieve split payments of the order
$orderPaymentCollection = $this->_adyenOrderPaymentCollectionFactory
->create()
->addPaymentFilterAscending($this->getInfo()->getId());
if ($orderPaymentCollection->getSize() > 0) {
return $orderPaymentCollection;
} else {
return null;
}
}
}
......@@ -27,6 +27,10 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class Pos extends \Magento\Payment\Block\Form
{
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
protected $_orderFactory;
/**
......@@ -39,6 +43,17 @@ class Pos extends \Magento\Payment\Block\Form
*/
protected $_order;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_adyenLogger;
/**
* Pos constructor.
*
......@@ -46,17 +61,29 @@ class Pos extends \Magento\Payment\Block\Form
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [],
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Checkout\Model\Session $checkoutSession
\Magento\Checkout\Model\Session $checkoutSession,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data);
$this->_getOrder();
$this->_request = $context->getRequest();
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
if (!$this->_order) {
$incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
}
}
/**
......@@ -72,33 +99,162 @@ class Pos extends \Magento\Payment\Block\Form
*/
public function getLaunchLink()
{
$result = "";
$launchlink = "";
try {
$order = $this->_order;
if($order->getPayment())
if($this->_order->getPayment())
{
$result = $this->_order->getPayment()->getMethodInstance()->getLaunchLink();
$realOrderId = $this->_order->getRealOrderId();
$orderCurrencyCode = $this->_order->getOrderCurrencyCode();
$amount = $this->_adyenHelper->formatAmount(
$this->_order->getGrandTotal(), $orderCurrencyCode
);
$shopperEmail = $this->_order->getCustomerEmail();
$customerId = $this->_order->getCustomerId();
$callbackUrl = $this->_urlBuilder->getUrl('adyen/process/resultpos',
['_secure' => $this->_getRequest()->isSecure()]);
$addReceiptOrderLines = $this->_adyenHelper->getAdyenPosConfigData("add_receipt_order_lines");
$recurringContract = $this->_adyenHelper->getAdyenPosConfigData('recurring_type');
$currencyCode = $orderCurrencyCode;
$paymentAmount = $amount;
$merchantReference = $realOrderId;
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
$shopperEmail = $shopperEmail;
$recurringParams = "";
if ($this->_order->getPayment()->getAdditionalInformation("store_cc") != "") {
$recurringParams = "&recurringContract=" . urlencode($recurringContract) . "&shopperReference=" .
urlencode($shopperReference) . "&shopperEmail=" . urlencode($shopperEmail);
}
$receiptOrderLines = "";
if ($addReceiptOrderLines) {
$orderLines = base64_encode($this->_getReceiptOrderLines($this->_order));
$receiptOrderLines = "&receiptOrderLines=" . urlencode($orderLines);
}
// extra parameters so that you alway's return these paramters from the application
$extraParamaters = urlencode("/?originalCustomCurrency=".$currencyCode."&originalCustomAmount=".
$paymentAmount. "&originalCustomMerchantReference=".
$merchantReference . "&originalCustomSessionId=".session_id());
$launchlink = "adyen://payment?sessionId=".session_id()."&amount=".$paymentAmount.
"&currency=".$currencyCode."&merchantReference=".$merchantReference. $recurringParams .
$receiptOrderLines . "&callback=".$callbackUrl . $extraParamaters;
// cash not working see ticket
// https://youtrack.is.adyen.com/issue/IOS-130#comment=102-20285
// . "&transactionType=CASH";
$this->_adyenLogger->addAdyenDebug(print_r($launchlink, true));
}
} catch(Exception $e) {
// do nothing for now
throw($e);
}
return $result;
return $launchlink;
}
/**
* Get order object
*
* @return \Magento\Sales\Model\Order
* @param \Magento\Sales\Model\Order $order
* @return string
*/
protected function _getOrder()
protected function _getReceiptOrderLines(\Magento\Sales\Model\Order $order)
{
if (!$this->_order) {
$incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
$myReceiptOrderLines = "";
$currency = $order->getOrderCurrencyCode();
$formattedAmountValue = $this->_currencyFactory->create()->format(
$order->getGrandTotal(),
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$taxAmount = $order->getTaxAmount();
$formattedTaxAmount = $this->_currencyFactory->create()->format(
$taxAmount,
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$myReceiptOrderLines .= "---||C\n".
"====== YOUR ORDER DETAILS ======||CB\n".
"---||C\n".
" No. Description |Piece Subtotal|\n";
foreach ($order->getItemsCollection() as $item) {
//skip dummies
if ($item->isDummy()) {
continue;
};
$singlePriceFormat = $this->_currencyFactory->create()->format(
$item->getPriceInclTax(),
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$itemAmount = $item->getPriceInclTax() * (int) $item->getQtyOrdered();
$itemAmountFormat = $this->_currencyFactory->create()->format(
$itemAmount,
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$myReceiptOrderLines .= " " . (int) $item->getQtyOrdered() . " " . trim(substr($item->getName(), 0, 25)) .
"| " . $currency . " " . $singlePriceFormat . " " . $currency . " " . $itemAmountFormat . "|\n";
}
//discount cost
if ($order->getDiscountAmount() > 0 || $order->getDiscountAmount() < 0) {
$discountAmountFormat = $this->_currencyFactory->create()->format(
$order->getDiscountAmount(),
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$myReceiptOrderLines .= " " . 1 . " " . $this->__('Total Discount') . "| " .
$currency . " " . $discountAmountFormat ."|\n";
}
//shipping cost
if ($order->getShippingAmount() > 0 || $order->getShippingTaxAmount() > 0) {
$shippingAmountFormat = $this->_currencyFactory->create()->format(
$order->getShippingAmount(),
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$myReceiptOrderLines .= " " . 1 . " " . $order->getShippingDescription() . "| " .
$currency . " " . $shippingAmountFormat ."|\n";
}
if ($order->getPaymentFeeAmount() > 0) {
$paymentFeeAmount = $this->_currencyFactory->create()->format(
$order->getPaymentFeeAmount(),
['display'=>\Magento\Framework\Currency::NO_SYMBOL],
false
);
$myReceiptOrderLines .= " " . 1 . " " . $this->__('Payment Fee') . "| " .
$currency . " " . $paymentFeeAmount ."|\n";
}
return $this->_order;
$myReceiptOrderLines .= "|--------|\n".
"|Order Total: ".$currency." ".$formattedAmountValue."|B\n".
"|Tax: ".$currency." ".$formattedTaxAmount."|B\n".
"||C\n";
/*
* New header for card details section!
* Default location is After Header so simply add to Order Details as separator
*/
$myReceiptOrderLines .= "---||C\n".
"====== YOUR PAYMENT DETAILS ======||CB\n".
"---||C\n";
return $myReceiptOrderLines;
}
/**
......@@ -110,4 +266,14 @@ class Pos extends \Magento\Payment\Block\Form
{
return $this->_checkoutSession;
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function _getRequest()
{
return $this->_request;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -165,6 +165,9 @@ class Json extends \Magento\Framework\App\Action\Action
if (isset($response['pspReference'])) {
$notification->setPspreference($response['pspReference']);
}
if (isset($response['originalReference'])) {
$notification->setOriginalReference($response['originalReference']);
}
if (isset($response['merchantReference'])) {
$notification->setMerchantReference($response['merchantReference']);
}
......
......@@ -262,17 +262,29 @@ class Result extends \Magento\Framework\App\Action\Action
protected function _authenticate($response) {
$hmacKey = $this->_adyenHelper->getHmac();
$merchantSigNotification = $response['merchantSig'];
// do it like this because $_GET is converting dot to underscore
$queryString = $_SERVER['QUERY_STRING'];
$result = [];
$pairs = explode("&", $queryString);
foreach ($pairs as $pair) {
$nv = explode("=", $pair);
$name = urldecode($nv[0]);
$value = urldecode($nv[1]);
$result[$name] = $value;
}
// do not include the merchantSig in the merchantSig calculation
$merchantSigNotification = $response['merchantSig'];
unset($response['merchantSig']);
unset($result['merchantSig']);
// Sort the array by key using SORT_STRING order
ksort($response, SORT_STRING);
ksort($result, SORT_STRING);
// Generate the signing data string
$signData = implode(":", array_map([$this, 'escapeString'],
array_merge(array_keys($response), array_values($response))));
array_merge(array_keys($result), array_values($result))));
$merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true));
......
......@@ -45,21 +45,29 @@ class Validate3d extends \Magento\Framework\App\Action\Action
*/
protected $_adyenHelper;
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected $_paymentRequest;
/**
* Validate3d constructor.
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
) {
parent::__construct($context);
$this->_adyenLogger = $adyenLogger;
$this->_adyenHelper = $adyenHelper;
$this->_paymentRequest = $paymentRequest;
}
/**
......@@ -93,7 +101,16 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$order->getPayment()->setAdditionalInformation('paResponse', $requestPaRes);
try {
$result = $order->getPayment()->getMethodInstance()->authorise3d($order->getPayment());
/**
* Magento should allow this.
* https://github.com/magento/magento2/issues/5819
*/
// $result = $order->getPayment()->getMethodInstance()->executeCommand(
// 'authorise_3d',
// ['payment' => $order->getPayment(), 'amount' => $order->getGrandTotal()]
// );
// old fashion way:
$result = $this->_authorise3d($order->getPayment());
} catch (\Exception $e) {
$this->_adyenLogger->addAdyenResult("Process 3D secure payment was refused");
$result = 'Refused';
......@@ -134,6 +151,24 @@ class Validate3d extends \Magento\Framework\App\Action\Action
}
}
/**
* Called by validate3d controller when cc payment has 3D secure
*
* @param $payment
* @return mixed
* @throws \Exception
*/
protected function _authorise3d($payment)
{
try {
$response = $this->_paymentRequest->authorise3d($payment);
} catch(\Exception $e) {
throw $e;
}
$responseCode = $response['resultCode'];
return $responseCode;
}
/**
* Get order object
*
......@@ -156,4 +191,4 @@ class Validate3d extends \Magento\Framework\App\Action\Action
{
return $this->_objectManager->get('Magento\Checkout\Model\Session');
}
}
\ 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\Command;
use Magento\Payment\Gateway\Command;
use Magento\Payment\Gateway\CommandInterface;
class HppCommand implements CommandInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* HppCommand constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->_adyenHelper = $adyenHelper;
}
/**
* @param array $commandSubject
* @return $this
*/
public function execute(array $commandSubject)
{
$payment =\Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
$stateObject = \Magento\Payment\Gateway\Helper\SubjectReader::readStateObject($commandSubject);
// do not send email
$payment = $payment->getPayment();
$order = $payment->getOrder();
$order->setCanSendNewEmailFlag(false);
// update customer based on additionalFields
if ($payment->getAdditionalInformation("gender")) {
$order->setCustomerGender(\Adyen\Payment\Model\Gender::getMagentoGenderFromAdyenGender(
$payment->getAdditionalInformation("gender"))
);
}
if ($payment->getAdditionalInformation("dob")) {
$order->setCustomerDob($payment->getAdditionalInformation("dob"));
}
if ($payment->getAdditionalInformation("telephone")) {
$order->getBillingAddress()->setTelephone($payment->getAdditionalInformation("telephone"));
}
// update status and state
$stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
$stateObject->setStatus($this->_adyenHelper->getAdyenAbstractConfigData('order_status'));
$stateObject->setIsNotified(false);
return $this;
}
}
\ 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\Command;
use Magento\Payment\Gateway\Command;
use Magento\Payment\Gateway\CommandInterface;
class PosCommand implements CommandInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* HppCommand constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->_adyenHelper = $adyenHelper;
}
/**
* @param array $commandSubject
* @return $this
*/
public function execute(array $commandSubject)
{
$payment =\Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
$stateObject = \Magento\Payment\Gateway\Helper\SubjectReader::readStateObject($commandSubject);
// do not send email
$payment = $payment->getPayment();
$payment->getOrder()->setCanSendNewEmailFlag(false);
// update status and state
$stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
$stateObject->setStatus($this->_adyenHelper->getAdyenAbstractConfigData('order_status'));
$stateObject->setIsNotified(false);
return $this;
}
}
\ 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\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
/**
* Class TransactionSale
*/
class TransactionAuthorization implements ClientInterface
{
/**
* @var \Adyen\Client
*/
protected $_client;
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
// initialize client
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
}
/**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return mixed
* @throws ClientException
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
// call lib
$service = new \Adyen\Service\Payment($this->_client);
try {
$response = $service->authorise($request);
} catch(\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
return $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\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
/**
* Class TransactionSale
*/
class TransactionCancel implements ClientInterface
{
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
// initialize client
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
}
/**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return null
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
// call lib
$service = new \Adyen\Service\Modification($this->_client);
try {
$response = $service->cancelOrRefund($request);
} catch(\Adyen\AdyenException $e) {
$response = null;
}
return $response;
}
}
\ 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\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
/**
* Class TransactionSale
*/
class TransactionCapture implements ClientInterface
{
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
// initialize client
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
}
/**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return null
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
// call lib
$service = new \Adyen\Service\Modification($this->_client);
try {
$response = $service->capture($request);
} catch(\Adyen\AdyenException $e) {
$this->_adyenLogger->error($e); // add this for now not in the lib yet
$response = null;
}
return $response;
}
}
\ 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\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
/**
* Class TransactionSale
*/
class TransactionRefund implements ClientInterface
{
/**
* PaymentRequest constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Model\RecurringType $recurringType
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\RecurringType $recurringType,
array $data = []
) {
$this->_encryptor = $encryptor;
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->_recurringType = $recurringType;
$this->_appState = $context->getAppState();
// initialize client
$webserviceUsername = $this->_adyenHelper->getWsUsername();
$webservicePassword = $this->_adyenHelper->getWsPassword();
$client = new \Adyen\Client();
$client->setApplicationName("Magento 2 plugin");
$client->setUsername($webserviceUsername);
$client->setPassword($webservicePassword);
if ($this->_adyenHelper->isDemoMode()) {
$client->setEnvironment(\Adyen\Environment::TEST);
} else {
$client->setEnvironment(\Adyen\Environment::LIVE);
}
// assign magento log
$client->setLogger($adyenLogger);
$this->_client = $client;
}
/**
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return null
*/
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$requests = $transferObject->getBody();
$responses = [];
foreach ($requests as $request) {
// call lib
$service = new \Adyen\Service\Modification($this->_client);
try {
$responses[] = $service->refund($request);
} catch(\Adyen\AdyenException $e) {
$responses[] = null;
}
}
return $responses;
}
}
\ 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\Http;
use Magento\Payment\Gateway\Http\TransferBuilder;
use Magento\Payment\Gateway\Http\TransferFactoryInterface;
use Magento\Payment\Gateway\Http\TransferInterface;
class TransferFactory implements TransferFactoryInterface
{
/**
* @var TransferBuilder
*/
private $transferBuilder;
/**
* @param TransferBuilder $transferBuilder
*/
public function __construct(
TransferBuilder $transferBuilder
) {
$this->transferBuilder = $transferBuilder;
}
/**
* Builds gateway transfer object
*
* @param array $request
* @return TransferInterface
*/
public function create(array $request)
{
return $this->transferBuilder
->setBody($request)
->build();
}
}
\ 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 AddressDataBuilder
*/
class AddressDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* AddressDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* Add delivery\billing details into request
*
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$result = [];
$billingAddress = $order->getBillingAddress();
if ($billingAddress) {
// filter housenumber from streetLine1
$requestBilling = ["street" => $billingAddress->getStreetLine1(),
"postalCode" => $billingAddress->getPostcode(),
"city" => $billingAddress->getCity(),
"houseNumberOrName" => 'NA',
"stateOrProvince" => $billingAddress->getRegionCode(),
"country" => $billingAddress->getCountryId()
];
// houseNumberOrName is mandatory
if ($requestBilling['houseNumberOrName'] == "") {
$requestBilling['houseNumberOrName'] = "NA";
}
$result['billingAddress'] = $requestBilling;
}
$shippingAddress = $order->getShippingAddress();
if ($shippingAddress) {
// filter housenumber from streetLine1
$requestDelivery = ["street" => $shippingAddress->getStreetLine1(),
"postalCode" => $shippingAddress->getPostcode(),
"city" => $shippingAddress->getCity(),
"houseNumberOrName" => 'NA',
"stateOrProvince" => $shippingAddress->getRegionCode(),
"country" => $shippingAddress->getCountryId()
];
// houseNumberOrName is mandatory
if ($requestDelivery['houseNumberOrName'] == "") {
$requestDelivery['houseNumberOrName'] = "NA";
}
$result['deliveryAddress'] = $requestDelivery;
}
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\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
/**
* Payment Data Builder
*/
class Authorize3DSecureDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* PaymentDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$md = $payment->getAdditionalInformation('md');
$paResponse = $payment->getAdditionalInformation('paResponse');
return [
"md" => $md,
"paResponse" => $paResponse,
];
}
}
\ 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 BoletoAuthorizationDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* @param array $buildSubject
* @return mixed
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$order = $paymentDataObject->getOrder();
$storeId = $order->getStoreId();
$request = [];
$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;
return $request;
}
}
\ 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;
/**
* Payment Data Builder
*/
class BrowserInfoDataBuilder implements BuilderInterface
{
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
return [
'browserInfo' =>
[
'userAgent' => $_SERVER['HTTP_USER_AGENT'],
'acceptHeader' => $_SERVER['HTTP_ACCEPT']
]
];
}
}
\ 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 CustomerDataBuilder
*/
class CancelDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* Create cancel_or_refund request
*
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$payment = $paymentDataObject->getPayment();
$pspReference = $payment->getCcTransId();
return [
"reference" => $order->getOrderIncrementId(),
"originalReference" => $pspReference
];
}
}
\ 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 CustomerDataBuilder
*/
class CaptureDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* Create capture request
*
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject);
$payment = $paymentDataObject->getPayment();
$pspReference = $payment->getCcTransId();
$currency = $payment->getOrder()->getOrderCurrencyCode();
//format the amount to minor units
$amount = $this->adyenHelper->formatAmount($amount, $currency);
$modificationAmount = ['currency' => $currency, 'value' => $amount];
return [
"modificationAmount" => $modificationAmount,
"reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $pspReference
];
}
}
\ 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 CcAuthorizationDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* @var \Magento\Framework\App\State
*/
private $appState;
/**
* CcAuthorizationDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Model\Context $context
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Model\Context $context
) {
$this->adyenHelper = $adyenHelper;
$this->appState = $context->getAppState();
}
/**
* @param array $buildSubject
* @return mixed
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$order = $paymentDataObject->getOrder();
$storeId = $order->getStoreId();
$request = [];
if ($this->adyenHelper->getAdyenCcConfigDataFlag('cse_enabled', $storeId)) {
$request['additionalData']['card.encrypted.json'] =
$payment->getAdditionalInformation("encrypted_data");
} else {
$requestCreditCardDetails = [
"expiryMonth" => $payment->getCcExpMonth(),
"expiryYear" => $payment->getCcExpYear(),
"holderName" => $payment->getCcOwner(),
"number" => $payment->getCcNumber(),
"cvc" => $payment->getCcCid(),
];
$cardDetails['card'] = $requestCreditCardDetails;
$request = array_merge($request, $cardDetails);
}
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
*/
$enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE &&
$enableMoto) {
$request['shopperInteraction'] = "Moto";
}
// 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');
}
return $request;
}
}
\ 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 CustomerDataBuilder
*/
class CustomerDataBuilder implements BuilderInterface
{
/**
* quest prefix
*/
const GUEST_ID = 'customer_';
/**
* Add shopper data into request
*
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$billingAddress = $order->getBillingAddress();
$customerEmail = $billingAddress->getEmail();
$realOrderId = $order->getOrderIncrementId();
$customerId = $order->getCustomerId();
$shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
return [
"shopperEmail" => $customerEmail,
"shopperReference" => $shopperReference
];
}
}
<?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 CustomerDataBuilder
*/
class CustomerIpDataBuilder implements BuilderInterface
{
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
return ['shopperIP' => $order->getRemoteIp()];
}
}
<?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 MerchantAccountDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* RecurringDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper;
}
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$storeId = $order->getStoreId();
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
return ["merchantAccount" => $merchantAccount];
}
}
\ 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 OneclickAuthorizationDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* @param array $buildSubject
* @return mixed
*/
public function build(array $buildSubject)
{
$request = [];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
if ($payment->getAdditionalInformation('customer_interaction')) {
$shopperInteraction = "Ecommerce";
} else {
$shopperInteraction = "ContAuth";
}
$request['selectedRecurringDetailReference'] = $recurringDetailReference;
$request['shopperInteraction'] = $shopperInteraction;
// if it is a sepadirectdebit set selectedBrand to sepadirectdebit in the case of oneclick
if ($payment->getCcType() == "sepadirectdebit") {
$request['selectedBrand'] = "sepadirectdebit";
}
/*
* For recurring Ideal and Sofort needs to be converted to SEPA
* for this it is mandatory to set selectBrand to sepadirectdebit
*/
if (!$payment->getAdditionalInformation('customer_interaction')) {
if ($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") {
$request['selectedBrand'] = "sepadirectdebit";
}
}
return $request;
}
}
\ 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;
/**
* Payment Data Builder
*/
class PaymentDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* PaymentDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$payment = $paymentDataObject->getPayment();
$fullOrder = $payment->getOrder();
$currencyCode = $fullOrder->getOrderCurrencyCode();
$amount = $fullOrder->getGrandTotal();
$amount = ['currency' => $currencyCode,
'value' => $this->adyenHelper->formatAmount($amount, $currencyCode)];
return [
"amount" => $amount,
"reference" => $order->getOrderIncrementId(),
"fraudOffset" => "0"
];
}
}
\ 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 RecurringDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* @var \Magento\Framework\App\State
*/
private $appState;
/**
* RecurringDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Model\Context $context
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Model\Context $context
) {
$this->adyenHelper = $adyenHelper;
$this->appState = $context->getAppState();
}
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
$result = [];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
// Needs to change when oneclick,cc using facade impl.
$paymentMethodCode = $payment->getMethodInstance()->getCode();
$storeId = null;
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$storeId = $payment->getOrder()->getStoreId();
}
$recurringType = $this->adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId);
// set the recurring type
$recurringContractType = null;
if ($recurringType) {
if ($paymentMethodCode == \Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider::CODE) {
/*
* For ONECLICK look at the recurringPaymentType that the merchant
* has selected in Adyen ONECLICK settings
*/
if ($payment->getAdditionalInformation('customer_interaction')) {
$recurringContractType = \Adyen\Payment\Model\RecurringType::ONECLICK;
} else {
$recurringContractType = \Adyen\Payment\Model\RecurringType::RECURRING;
}
} else if ($paymentMethodCode == \Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CODE) {
if ($payment->getAdditionalInformation("store_cc") == "" &&
($recurringType == "ONECLICK,RECURRING" || $recurringType == "RECURRING")) {
$recurringContractType = \Adyen\Payment\Model\RecurringType::RECURRING;
} elseif ($payment->getAdditionalInformation("store_cc") == "1") {
$recurringContractType = $recurringType;
}
} else {
$recurringContractType = $recurringType;
}
}
if ($recurringContractType) {
$recurring = ['contract' => $recurringContractType];
$result['recurring'] = $recurring;
}
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 CustomerDataBuilder
*/
class RefundDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* @var \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory
*/
private $orderPaymentCollectionFactory;
/**
* RefundDataBuilder constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $orderPaymentCollectionFactory
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $orderPaymentCollectionFactory
)
{
$this->adyenHelper = $adyenHelper;
$this->orderPaymentCollectionFactory = $orderPaymentCollectionFactory;
}
/**
* @param array $buildSubject
* @return array
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject);
$order = $paymentDataObject->getOrder();
$payment = $paymentDataObject->getPayment();
$pspReference = $payment->getCcTransId();
$currency = $payment->getOrder()->getOrderCurrencyCode();
$storeId = $order->getStoreId();
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$grandTotal = $payment->getOrder()->getGrandTotal();
// check if it contains a split payment
$orderPaymentCollection = $this->orderPaymentCollectionFactory
->create()
->addFieldToFilter('payment_id', $payment->getId());
// partial refund if multiple payments check refund strategy
if ($orderPaymentCollection->getSize() > 1) {
$refundStrategy = $this->adyenHelper->getAdyenAbstractConfigData(
'split_payments_refund_strategy',
$order->getStoreId()
);
$ratio = null;
if ($refundStrategy == "1") {
// Refund in ascending order
$orderPaymentCollection->addPaymentFilterAscending($payment->getId());
} elseif ($refundStrategy == "2") {
// Refund in descending order
$orderPaymentCollection->addPaymentFilterDescending($payment->getId());
} elseif ($refundStrategy == "3") {
// refund based on ratio
$ratio = $amount / $grandTotal;
$orderPaymentCollection->addPaymentFilterAscending($payment->getId());
}
// loop over payment methods and refund them all
$result = [];
foreach ($orderPaymentCollection as $splitPayment) {
// could be that not all the split payments need a refund
if ($amount > 0) {
if ($ratio) {
// refund based on ratio calculate refund amount
$modificationAmount = $ratio * (
$splitPayment->getAmount() - $splitPayment->getTotalRefunded()
);
} else {
// total authorised amount of the split payment
$splitPaymentAmount = $splitPayment->getAmount() - $splitPayment->getTotalRefunded();
// if rest amount is zero go to next payment
if (!$splitPaymentAmount > 0) {
continue;
}
// if refunded amount is greather then split payment amount do a full refund
if ($amount >= $splitPaymentAmount) {
$modificationAmount = $splitPaymentAmount;
} else {
$modificationAmount = $amount;
}
// update amount with rest of the available amount
$amount = $amount - $splitPaymentAmount;
}
$modificationAmountObject = [
'currency' => $currency,
'value' => $this->adyenHelper->formatAmount($modificationAmount, $currency)
];
$result[] = [
"modificationAmount" => $modificationAmountObject,
"reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $splitPayment->getPspreference(),
"merchantAccount" => $merchantAccount
];
}
}
} else {
//format the amount to minor units
$amount = $this->adyenHelper->formatAmount($amount, $currency);
$modificationAmount = ['currency' => $currency, 'value' => $amount];
$result = [
[
"modificationAmount" => $modificationAmount,
"reference" => $payment->getOrder()->getIncrementId(),
"originalReference" => $pspReference,
"merchantAccount" => $merchantAccount
]
];
}
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 SepaAuthorizationDataBuilder implements BuilderInterface
{
/**
* @param array $buildSubject
* @return mixed
*/
public function build(array $buildSubject)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
$request = [];
// 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;
return $request;
}
}
\ 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\Response;
use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentAuthorisationDetailsHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
// set transaction not to processing by default wait for notification
$payment->setIsTransactionPending(true);
// no not send order confirmation mail
$payment->getOrder()->setCanSendNewEmailFlag(false);
// set pspReference as transactionId
$payment->setCcTransId($response['pspReference']);
$payment->setLastTransId($response['pspReference']);
// set transaction
$payment->setTransactionId($response['pspReference']);
// do not close transaction so you can do a cancel() and void
$payment->setIsTransactionClosed(false);
$payment->setShouldCloseParentTransaction(false);
}
}
\ 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\Response;
use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentCancelDetailsHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
// set pspReference as lastTransId only!
$payment->setLastTransId($response['pspReference']);
// close transaction because you have cancelled the transaction
$payment->setIsTransactionClosed(true);
$payment->setShouldCloseParentTransaction(true);
}
}
\ 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\Response;
use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentCaptureDetailsHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
// set pspReference as lastTransId only!
$payment->setLastTransId($response['pspReference']);
/**
* close current transaction because you have capture the goods
* but do not close the authorisation becasue you can still cancel/refund order
*/
$payment->setIsTransactionClosed(true);
$payment->setShouldCloseParentTransaction(false);
}
}
\ 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\Response;
use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentCommentHistoryHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
* @return $this
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
if (isset($response['resultCode'])) {
$responseCode = $response['resultCode'];
} else {
// try to get response from response key (used for modifications
if (isset($response['response'])) {
$responseCode = $response['response'];
} else {
$responseCode = "";
}
}
if (isset($response['pspReference'])) {
$pspReference = $response['pspReference'];
} else {
$pspReference = "";
}
$type = 'Adyen Result response:';
$comment = __('%1 <br /> authResult: %2 <br /> pspReference: %3 ',
$type, $responseCode, $pspReference);
if ($responseCode) {
$payment->getOrder()->setAdyenResulturlEventCode($responseCode);
}
$payment->getOrder()->addStatusHistoryComment($comment);
return $this;
}
}
<?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\Payment\Gateway\Response\HandlerInterface;
class PaymentCommentHistoryRefundHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
* @return $this
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
foreach ($response as $singleResponse) {
if (isset($singleResponse['resultCode'])) {
$responseCode = $singleResponse['resultCode'];
} else {
// try to get response from response key (used for modifications
if (isset($singleResponse['response'])) {
$responseCode = $singleResponse['response'];
} else {
$responseCode = "";
}
}
if (isset($singleResponse['pspReference'])) {
$pspReference = $singleResponse['pspReference'];
} else {
$pspReference = "";
}
$type = 'Adyen Result response:';
$comment = __('%1 <br /> authResult: %2 <br /> pspReference: %3 ',
$type, $responseCode, $pspReference);
if ($responseCode) {
$payment->getOrder()->setAdyenResulturlEventCode($responseCode);
}
$payment->getOrder()->addStatusHistoryComment($comment);
}
return $this;
}
}
<?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\Payment\Gateway\Response\HandlerInterface;
class PaymentRefundDetailsHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
*/
public function handle(array $handlingSubject, array $response)
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
foreach ($response as $singleResponse) {
// set pspReference as lastTransId only!
$payment->setLastTransId($singleResponse['pspReference']);
}
/**
* close current transaction because you have refunded the goods
* but only on full refund close the authorisation
*/
$payment->setIsTransactionClosed(true);
$closeParent = !(bool)$payment->getCreditmemo()->getInvoice()->canRefund();
$payment->setShouldCloseParentTransaction($closeParent);
}
}
\ 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\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
class CancelResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* GeneralResponseValidator constructor.
*
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->adyenLogger = $adyenLogger;
parent::__construct($resultFactory);
}
/**
* @param array $validationSubject
* @return \Magento\Payment\Gateway\Validator\ResultInterface
*/
public function validate(array $validationSubject)
{
$response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
$isValid = true;
$errorMessages = [];
if ($response['response'] != '[cancelOrRefund-received]') {
$errorMsg = __('Error with cancellation');
$this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg;
}
return $this->createResult($isValid, $errorMessages);
}
}
\ 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\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
class CaptureResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* GeneralResponseValidator constructor.
*
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->adyenLogger = $adyenLogger;
parent::__construct($resultFactory);
}
/**
* @param array $validationSubject
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function validate(array $validationSubject)
{
$response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
$isValid = true;
$errorMessages = [];
if ($response['response'] != '[capture-received]') {
$errorMsg = __('Error with capture');
$this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg;
}
return $this->createResult($isValid, $errorMessages);
}
}
\ 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\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
class GeneralResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* GeneralResponseValidator constructor.
*
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->adyenLogger = $adyenLogger;
parent::__construct($resultFactory);
}
/**
* @param array $validationSubject
* @return \Magento\Payment\Gateway\Validator\ResultInterface
*/
public function validate(array $validationSubject)
{
$response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
$paymentDataObjectInterface = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($validationSubject);
$payment = $paymentDataObjectInterface->getPayment();
$payment->setAdditionalInformation('3dActive', false);
$isValid = true;
$errorMessages = [];
// validate result
if ($response && isset($response['resultCode'])) {
switch ($response['resultCode']) {
case "Authorised":
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "Received":
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
// set additionalData
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 "RedirectShopper":
$payment->setAdditionalInformation('3dActive', true);
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
$issuerUrl = $response['issuerUrl'];
$paReq = $response['paRequest'];
$md = $response['md'];
if (!empty($paReq) && !empty($md) && !empty($issuerUrl)) {
$payment->setAdditionalInformation('issuerUrl', $response['issuerUrl']);
$payment->setAdditionalInformation('paRequest', $response['paRequest']);
$payment->setAdditionalInformation('md', $response['md']);
} else {
$isValid = false;
$errorMsg = __('3D secure is not valid.');
$this->adyenLogger->error($errorMsg);;
$errorMessages[] = $errorMsg;
}
break;
case "Refused":
if ($response['refusalReason']) {
$refusalReason = $response['refusalReason'];
switch($refusalReason) {
case "Transaction Not Permitted":
$errorMsg = __('The transaction is not permitted.');
break;
case "CVC Declined":
$errorMsg = __('Declined due to the Card Security Code(CVC) being incorrect. Please check your CVC code!');
break;
case "Restricted Card":
$errorMsg = __('The card is restricted.');
break;
case "803 PaymentDetail not found":
$errorMsg = __('The payment is REFUSED because the saved card is removed. Please try an other payment method.');
break;
case "Expiry month not set":
$errorMsg = __('The expiry month is not set. Please check your expiry month!');
break;
default:
$errorMsg = __('The payment is REFUSED.');
break;
}
} else {
$errorMsg = __('The payment is REFUSED.');
}
// this will result the specific error
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break;
default:
$errorMsg = __('Error with payment method please select different payment method.');
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break;
}
} else {
$errorMsg = __('Error with payment method please select different payment method.');
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
}
return $this->createResult($isValid, $errorMessages);
}
}
\ 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\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
class RefundResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* GeneralResponseValidator constructor.
*
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
) {
$this->adyenLogger = $adyenLogger;
parent::__construct($resultFactory);
}
/**
* @param array $validationSubject
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function validate(array $validationSubject)
{
$responses = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
$isValid = true;
$errorMessages = [];
foreach ($responses as $response) {
if ($response['response'] != '[refund-received]') {
$errorMsg = __('Error with refund');
$this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg;
}
}
return $this->createResult($isValid, $errorMessages);
}
}
\ 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\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
/**
* Class SepaValidator
* @package Adyen\Payment\Gateway\Validator
*/
class SepaValidator extends AbstractValidator
{
/**
* @param array $validationSubject
* @return \Magento\Payment\Gateway\Validator\ResultInterface
*/
public function validate(array $validationSubject)
{
$isValid = true;
$fails = [];
$payment = $validationSubject['payment'];
$iban = $payment->getAdditionalInformation('iban');
if (empty($iban) || !$this->validateIban($iban)) {
$isValid = false;
$fails[] = __('Invalid Iban number.');
}
return $this->createResult($isValid, $fails);
}
/**
* @param $iban
* @return bool
*/
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;
}
}
}
\ No newline at end of file
......@@ -51,25 +51,51 @@ class Data extends AbstractHelper
*/
protected $_moduleList;
/**
* @var \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory
*/
protected $_billingAgreementCollectionFactory;
/**
* @var Repository
*/
protected $_assetRepo;
/**
* @var \Magento\Framework\View\Asset\Source
*/
protected $_assetSource;
/**
* Data constructor.
*
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Config\DataInterface $dataStorage
* @param \Magento\Directory\Model\Config\Source\Country $country
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Magento\Framework\Config\DataInterface $dataStorage,
\Magento\Directory\Model\Config\Source\Country $country,
\Magento\Framework\Module\ModuleListInterface $moduleList
\Magento\Framework\Module\ModuleListInterface $moduleList,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\Asset\Source $assetSource
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
$this->_dataStorage = $dataStorage;
$this->_country = $country;
$this->_moduleList = $moduleList;
$this->_billingAgreementCollectionFactory = $billingAgreementCollectionFactory;
$this->_assetRepo = $assetRepo;
$this->_assetSource = $assetSource;
}
/**
......@@ -164,7 +190,19 @@ class Data extends AbstractHelper
break;
}
return number_format($amount, $format, '', '');
return (int)number_format($amount, $format, '', '');
}
/**
* Tax Percentage needs to be in minor units for Adyen
*
* @param float $taxPercent
* @return int
*/
public function getMinorUnitTaxPercent($taxPercent)
{
$taxPercent = $taxPercent * 100;
return (int)$taxPercent;
}
/**
......@@ -386,6 +424,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 +645,168 @@ 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'),
],
];
}
/**
* @param $customerId
* @param $storeId
* @param $grandTotal
* @param $recurringType
* @return array
*/
public function getOneClickPaymentMethods($customerId, $storeId, $grandTotal, $recurringType)
{
$billingAgreements = [];
$baCollection = $this->_billingAgreementCollectionFactory->create();
$baCollection->addFieldToFilter('customer_id', $customerId);
$baCollection->addFieldToFilter('store_id', $storeId);
$baCollection->addFieldToFilter('method_code', 'adyen_oneclick');
$baCollection->addActiveFilter();
foreach ($baCollection as $billingAgreement) {
$agreementData = $billingAgreement->getAgreementData();
// no agreementData and contractType then ignore
if ((!is_array($agreementData)) || (!isset($agreementData['contractTypes']))) {
continue;
}
// check if contractType is supporting the selected contractType for OneClick payments
$allowedContractTypes = $agreementData['contractTypes'];
if (in_array($recurringType, $allowedContractTypes)) {
// check if AgreementLabel is set and if contract has an recurringType
if ($billingAgreement->getAgreementLabel()) {
// for Ideal use sepadirectdebit because it is
if ($agreementData['variant'] == 'ideal') {
$agreementData['variant'] = 'sepadirectdebit';
}
$data = ['reference_id' => $billingAgreement->getReferenceId(),
'agreement_label' => $billingAgreement->getAgreementLabel(),
'agreement_data' => $agreementData
];
if ($this->showLogos()) {
$logoName = $agreementData['variant'];
$asset = $this->createAsset(
'Adyen_Payment::images/logos/' . $logoName . '.png'
);
$icon = null;
$placeholder = $this->_assetSource->findSource($asset);
if ($placeholder) {
list($width, $height) = getimagesize($asset->getSourceFile());
$icon = [
'url' => $asset->getUrl(),
'width' => $width,
'height' => $height
];
}
$data['logo'] = $icon;
}
/**
* Check if there are installments for this creditcard type defined
*/
$data['number_of_installments'] = 0;
$ccType = $this->getMagentoCreditCartType($agreementData['variant']);
$installments = null;
$installmentsValue = $this->getAdyenCcConfigData('installments');
if ($installmentsValue) {
$installments = unserialize($installmentsValue);
}
if ($installments) {
$numberOfInstallments = null;
foreach ($installments as $ccTypeInstallment => $installment) {
if ($ccTypeInstallment == $ccType) {
foreach ($installment as $amount => $installments) {
if ($grandTotal <= $amount) {
$numberOfInstallments = $installments;
}
}
}
}
if ($numberOfInstallments) {
$data['number_of_installments'] = $numberOfInstallments;
}
}
$billingAgreements[] = $data;
}
}
}
return $billingAgreements;
}
/**
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodOpenInvoiceMethod($paymentMethod)
{
if (strlen($paymentMethod) >= 9 && substr($paymentMethod, 0, 9) == 'afterpay_') {
return true;
} else if($paymentMethod == 'klarna') {
return true;
} else {
return false;
}
}
/**
* @return bool
*/
public function showLogos()
{
$showLogos = $this->getAdyenAbstractConfigData('title_renderer');
if ($showLogos == \Adyen\Payment\Model\Config\Source\RenderMode::MODE_TITLE_IMAGE) {
return true;
}
return false;
}
/**
* Create a file asset that's subject of fallback system
*
* @param string $fileId
* @param array $params
* @return \Magento\Framework\View\Asset\File
*/
public function createAsset($fileId, array $params = [])
{
$params = array_merge(['_secure' => $this->_request->isSecure()], $params);
return $this->_assetRepo->createAsset($fileId, $params);
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -38,6 +38,9 @@ class AdyenError extends AdyenBase
*/
protected $loggerType = AdyenLogger::ERROR;
/**
* @var
*/
protected $level = AdyenLogger::ERROR;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "1.4.5",
"version": "2.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
......@@ -32,4 +32,4 @@
"Adyen\\Payment\\": ""
}
}
}
\ No newline at end of file
}
......@@ -37,12 +37,15 @@
<include path="Adyen_Payment::system/adyen_advanced_notifications.xml"/>
<include path="Adyen_Payment::system/adyen_billing_agreements.xml"/>
<include path="Adyen_Payment::system/adyen_checkout_experience.xml"/>
<include path="Adyen_Payment::system/adyen_manual_review.xml"/>
<include path="Adyen_Payment::system/adyen_split_payment.xml"/>
<include path="Adyen_Payment::system/adyen_cc.xml"/>
<include path="Adyen_Payment::system/adyen_oneclick.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_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>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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