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 5dfbe4d2 authored by Attila Kiss's avatar Attila Kiss Committed by GitHub

[PW-2499] Fix codesniffer warnings and errors and prepare Release 6.1.2 (#737)

* Update phpcs to validate PSR2 rules

* Fix PSR2 phpcs errors with phpcbf

* Fix phpcs errors with phpcbf

* Fix PSR2 phpcs errors

* Reapply fix for boleto lastname key

* Fix Api folder

* Fix phpcs warning

* Fix phpcs warning

* Remove unused var

* Version bump 6.1.2

* Fix MagentoStandard phpcs warnings

* Part of fixing the code sniffer errors

* Part of fixing the code sniffer errors

* Fix Magento Marketplace codesniffing warnings

* Fix some code sniffer errors with phpcbf

* Autoformat PSR12

* Fix the path string with ::class

* Fix empty spaces warnings

* Fix Magento marketplace codesniffing warnings

* Fix Magento marketplace codesniffing warnings

* Set arguments defaults values at the end of the argument list

* Code sniffer fixes

* Fix Magento marketplace codesniffing warnings

* remove empty return statement

* Fix Static method cannot be intercepted error

* Fix eror: Possible useless method overriding detected

* Remove private const since it is only supported since php 7.1

* Fix wrong class paths

* Fix sonarcloud bugs

table th element should have scope attribute when possible

* Fix codesmells

* Fix unit test

* Remove ISSUE_TEMPLATE.md

* fix wrong function call for formatStreet()

* Add removed _prepareLayout() function back

* Update Model/Cron.php
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>

* Update Model/Cron.php
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>

* Fix request's paymentMethod field
Co-authored-by: default avataralexandros <alexandros.moraitis@adyen.com>
Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>
parent 82c98e03
......@@ -8,9 +8,9 @@ php:
- 7.3
install:
- echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
- composer install --prefer-dist
- echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
- composer install --prefer-dist
script:
- php vendor/bin/phpcs
- vendor/bin/phpunit -c Test/phpunit.xml
\ No newline at end of file
- php vendor/bin/phpcs
- vendor/bin/phpunit -c Test/phpunit.xml
\ No newline at end of file
......@@ -85,11 +85,10 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
*/
public function isDisplayed()
{
// Only execute the query the first time you access the Admin page
if ($this->authSession->isFirstPageAfterLogin() &&
!empty($this->adyenHelper->getWsUsername()) &&
empty($this->adyenHelper->getAPIKey())
if ($this->authSession->isFirstPageAfterLogin()
&& !empty($this->adyenHelper->getWsUsername())
&& empty($this->adyenHelper->getAPIKey())
) {
try {
$title = 'Adyen extension requires the API KEY!';
......@@ -109,7 +108,6 @@ class APIKeyMessage implements \Magento\Framework\Notification\MessageInterface
*/
$this->inboxFactory->create()->parse($messageData);
return true;
} catch (\Exception $e) {
return false;
}
......
......@@ -47,9 +47,6 @@ class CronMessage implements \Magento\Framework\Notification\MessageInterface
$this->backendHelper = $backendHelper;
}
/**
* Message identity
*/
const MESSAGE_IDENTITY = 'Adyen Cronjob system message';
/**
......@@ -93,7 +90,11 @@ class CronMessage implements \Magento\Framework\Notification\MessageInterface
public function getText()
{
$urlNotificationsOverview = $this->backendHelper->getUrl("adyen/notifications/overview");
$message = __('You have <a href="%1">%2 unprocessed notification(s)</a>. Please check your Cron', $urlNotificationsOverview, $this->_cronCheck);
$message = __(
'You have <a href="%1">%2 unprocessed notification(s)</a>. Please check your Cron',
$urlNotificationsOverview,
$this->_cronCheck
);
$urlMagento = "http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html";
$urlAdyen = "https://docs.adyen.com/developers/plugins/magento-2/set-up-the-plugin-in-magento#step2runcron";
$message .= __(
......
......@@ -40,9 +40,6 @@ class VersionMessage implements \Magento\Framework\Notification\MessageInterface
$this->_inboxFactory = $inboxFactory;
}
/**
* Message identity
*/
const MESSAGE_IDENTITY = 'Adyen Version Control message';
/**
......@@ -105,8 +102,13 @@ class VersionMessage implements \Magento\Framework\Notification\MessageInterface
{
$githubContent = $this->getSessionData("AdyenGithubVersion");
$message = __("A new Adyen extension version is now available: ");
$message .= __("<a href= \"" . $githubContent['html_url'] . "\" target='_blank'> " . $githubContent['tag_name'] . "!</a>");
$message .= __(" You are running the " . $this->_adyenHelper->getModuleVersion() . " version. We advise to update your extension.");
$message .= __(
"<a href= \"" . $githubContent['html_url'] . "\" target='_blank'> " . $githubContent['tag_name'] . "!</a>"
);
$message .= __(
" You are running the " . $this->_adyenHelper->getModuleVersion(
) . " version. We advise to update your extension."
);
return __($message);
}
......
......@@ -28,6 +28,7 @@ interface AdyenInitiateTerminalApiInterface
{
/**
* Trigger sync call on terminal
*
* @param string $payload
* @return mixed
*/
......
......@@ -24,11 +24,10 @@
namespace Adyen\Payment\Api;
interface AdyenOriginKeyInterface
{
/**
* @return string
*/
public function getOriginKey();
}
\ No newline at end of file
}
......@@ -25,18 +25,17 @@ namespace Adyen\Payment\Api;
/**
* Interface GuestAdyenPaymentMethodManagementInterface
*
* @api
* @package Adyen\Payment\Api
*/
interface AdyenPaymentMethodManagementInterface
{
/**
* Get payment information
*
* @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null);
......
......@@ -87,7 +87,7 @@ interface InvoiceInterface
public function getOriginalReference();
/**
* @param $originalReference
* @param $originalReference
* @return mixed
*/
public function setOriginalReference($originalReference);
......
......@@ -102,7 +102,6 @@ interface NotificationInterface
*/
const UPDATED_AT = 'updated_at';
/**
* Gets the ID for the notification.
*
......@@ -133,7 +132,6 @@ interface NotificationInterface
*/
public function setPspreference($pspreference);
/**
* Sets OriginalReference.
*
......
......@@ -126,7 +126,6 @@ interface OrderPaymentInterface
*/
public function setPaymentId($paymentId);
/**
* Gets the Paymentmethod for the payment.
*
......
......@@ -25,18 +25,16 @@ namespace Adyen\Payment\Api;
/**
* Interface GuestAdyenPaymentMethodManagementInterface
*
* @api
* @package Adyen\Payment\Api
*/
interface GuestAdyenPaymentMethodManagementInterface
{
/**
* Get payment information
*
* @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null);
......
......@@ -30,30 +30,31 @@ class Installment extends \Magento\Framework\View\Element\Html\Select
*
* @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',
'13' => '13x',
'14' => '14x',
'15' => '15x',
'16' => '16x',
'17' => '17x',
'18' => '18x',
'19' => '19x',
'20' => '20x',
'21' => '21x',
'22' => '22x',
'23' => '23x',
'24' => '24x'
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',
'13' => '13x',
'14' => '14x',
'15' => '15x',
'16' => '16x',
'17' => '17x',
'18' => '18x',
'19' => '19x',
'20' => '20x',
'21' => '21x',
'22' => '22x',
'23' => '23x',
'24' => '24x'
];
/**
......
......@@ -31,7 +31,6 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
*/
protected $_installmentRenderer = null;
/**
* @var \Adyen\Payment\Block\Adminhtml\System\Config\Field\Cctypes
*/
......@@ -47,7 +46,7 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
{
if (!$this->_installmentRenderer) {
$this->_installmentRenderer = $this->getLayout()->createBlock(
'\Adyen\Payment\Block\Adminhtml\System\Config\Field\Installment',
\Adyen\Payment\Block\Adminhtml\System\Config\Field\Installment::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
......@@ -65,7 +64,7 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
{
if (!$this->_ccTypesRenderer) {
$this->_ccTypesRenderer = $this->getLayout()->createBlock(
'\Adyen\Payment\Block\Adminhtml\System\Config\Field\Cctypes',
\Adyen\Payment\Block\Adminhtml\System\Config\Field\Cctypes::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
......@@ -75,6 +74,7 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender()
......@@ -82,22 +82,22 @@ class Installments extends \Magento\Config\Block\System\Config\Form\Field\FieldA
$this->addColumn(
'amount',
[
'label' => __('Amount Range'),
'renderer' => false,
'label' => __('Amount Range'),
'renderer' => false,
]
);
$this->addColumn(
'installments',
[
'label' => __('Number Of Installments'),
'renderer' => $this->getNumberOfInstallmentsRenderer(),
'label' => __('Number Of Installments'),
'renderer' => $this->getNumberOfInstallmentsRenderer(),
]
);
$this->addColumn(
'cc_types',
[
'label' => __('Allowed Credit Card Types'),
'renderer' => $this->getCcTypesRenderer(),
'renderer' => $this->getCcTypesRenderer(),
]
);
$this->_addAfter = false;
......
......@@ -41,7 +41,7 @@ class InstallmentsPosCloud extends \Magento\Config\Block\System\Config\Form\Fiel
{
if (!$this->_installmentRenderer) {
$this->_installmentRenderer = $this->getLayout()->createBlock(
'\Adyen\Payment\Block\Adminhtml\System\Config\Field\Installment',
\Adyen\Payment\Block\Adminhtml\System\Config\Field\Installment::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
......@@ -51,6 +51,7 @@ class InstallmentsPosCloud extends \Magento\Config\Block\System\Config\Form\Fiel
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender()
......@@ -58,15 +59,15 @@ class InstallmentsPosCloud extends \Magento\Config\Block\System\Config\Form\Fiel
$this->addColumn(
'amount',
[
'label' => __('Amount Range'),
'renderer' => false,
'label' => __('Amount Range'),
'renderer' => false,
]
);
$this->addColumn(
'installments',
[
'label' => __('Number Of Installments'),
'renderer' => $this->getNumberOfInstallmentsRenderer(),
'label' => __('Number Of Installments'),
'renderer' => $this->getNumberOfInstallmentsRenderer(),
]
);
......
......@@ -24,6 +24,7 @@
/**
* Field renderer for PayPal merchant country selector
*/
namespace Adyen\Payment\Block\Adminhtml\System\Config\Field;
class Version extends \Magento\Config\Block\System\Config\Form\Field
......@@ -33,8 +34,10 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* Version constructor.
*
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
......
......@@ -90,6 +90,7 @@ class Success extends \Magento\Framework\View\Element\Template
/**
* Detect if Boleto is used as payment method
*
* @return bool
*/
public function isBoletoPayment()
......@@ -150,8 +151,6 @@ class Success extends \Magento\Framework\View\Element\Template
return $result;
}
/**
* @return \Magento\Sales\Model\Order
*/
......
......@@ -97,4 +97,4 @@ class CardRenderer extends AbstractCardRenderer
{
return $this->adyenHelper->getVariantIcon($this->getTokenDetails()['type'])['width'];
}
}
\ No newline at end of file
}
......@@ -67,30 +67,30 @@ class Cc extends \Magento\Payment\Block\Form\Cc
$this->checkoutSession = $checkoutSession;
}
/**
* @return string
*/
/**
* @return string
*/
public function getCheckoutCardComponentJs()
{
return $this->adyenHelper->getCheckoutCardComponentJs($this->checkoutSession->getQuote()->getStore()->getId());
}
/**
* @return string
* @throws \Adyen\AdyenException
*/
public function getCheckoutOriginKeys()
{
return $this->adyenHelper->getOriginKeyForBaseUrl();
}
/**
* @return string
*/
public function getCheckoutEnvironment()
{
return $this->adyenHelper->getCheckoutEnvironment($this->checkoutSession->getQuote()->getStore()->getId());
}
{
return $this->adyenHelper->getCheckoutCardComponentJs($this->checkoutSession->getQuote()->getStore()->getId());
}
/**
* @return string
* @throws \Adyen\AdyenException
*/
public function getCheckoutOriginKeys()
{
return $this->adyenHelper->getOriginKeyForBaseUrl();
}
/**
* @return string
*/
public function getCheckoutEnvironment()
{
return $this->adyenHelper->getCheckoutEnvironment($this->checkoutSession->getQuote()->getStore()->getId());
}
/**
* Retrieve has verification configuration
......@@ -106,43 +106,43 @@ class Cc extends \Magento\Payment\Block\Form\Cc
return true;
}
/**
* @return string
*/
public function getLocale()
{
return $this->adyenHelper->getStoreLocale($this->checkoutSession->getQuote()->getStore()->getId());
}
/**
* Retrieve available credit card type codes by alt code
*
* @return array
*/
public function getCcAvailableTypesByAlt()
{
$types = [];
$ccTypes = $this->adyenHelper->getAdyenCcTypes();
$availableTypes = $this->adyenHelper->getAdyenCcConfigData('cctypes');
if ($availableTypes) {
$availableTypes = explode(',', $availableTypes);
foreach (array_keys($ccTypes) as $code) {
if (in_array($code, $availableTypes)) {
$types[$ccTypes[$code]['code_alt']] = $code;
}
}
}
return $types;
}
/**
* @return string
*/
public function getLocale()
{
return $this->adyenHelper->getStoreLocale($this->checkoutSession->getQuote()->getStore()->getId());
}
/**
* Retrieve available credit card type codes by alt code
*
* @return array
*/
public function getCcAvailableTypesByAlt()
{
$types = [];
$ccTypes = $this->adyenHelper->getAdyenCcTypes();
$availableTypes = $this->adyenHelper->getAdyenCcConfigData('cctypes');
if ($availableTypes) {
$availableTypes = explode(',', $availableTypes);
foreach (array_keys($ccTypes) as $code) {
if (in_array($code, $availableTypes)) {
$types[$ccTypes[$code]['code_alt']] = $code;
}
}
}
return $types;
}
/**
* Allow checkbox for MOTO payments to be saved as RECURRING
*
* @return bool
*/
public function allowRecurring()
public function allowRecurring()
{
if ($this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', null)) {
return true;
......@@ -157,5 +157,4 @@ class Cc extends \Magento\Payment\Block\Form\Cc
{
return $this->adyenHelper->isCreditCardVaultEnabled();
}
}
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Block\Form;
class PayByMail extends \Magento\Payment\Block\Form
{
/**
* @var string
*/
......
......@@ -27,7 +27,6 @@ use Magento\Framework\View\Element\Template;
class AbstractInfo extends \Magento\Payment\Block\Info
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -37,7 +36,7 @@ class AbstractInfo extends \Magento\Payment\Block\Info
* @var \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory
*/
protected $_adyenOrderPaymentCollectionFactory;
/**
* AbstractInfo constructor.
*
......
......@@ -40,7 +40,7 @@ class Boleto extends AbstractInfo
if (empty($paymentAction[$data])) {
return '';
}
return $paymentAction[$data];
}
}
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Block\Info;
class Cc extends AbstractInfo
{
/**
* @var string
*/
......
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Block\Info;
class Oneclick extends Cc
{
/**
* @var string
*/
......
......@@ -86,10 +86,10 @@ class PaymentLink extends AbstractInfo
public function _toHtml()
{
return strpos($this->getPayment()->getMethod(), 'adyen_') === 0
&& $this->_scopeConfig->getValue('payment/adyen_hpp/active')
&& $this->_scopeConfig->getValue('payment/adyen_pay_by_mail/active')
&& $this->getOrder()->getTotalDue() > 0
? parent::_toHtml()
: '';
&& $this->_scopeConfig->getValue('payment/adyen_hpp/active')
&& $this->_scopeConfig->getValue('payment/adyen_pay_by_mail/active')
&& $this->getOrder()->getTotalDue() > 0
? parent::_toHtml()
: '';
}
}
......@@ -28,7 +28,6 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class Redirect extends \Magento\Payment\Block\Form
{
/**
* @var \Magento\Sales\Model\OrderFactory
*/
......@@ -64,29 +63,29 @@ class Redirect extends \Magento\Payment\Block\Form
*/
protected $_taxConfig;
/**
* @var \Magento\Tax\Model\Calculation
*/
/**
* @var \Magento\Tax\Model\Calculation
*/
protected $_taxCalculation;
/**
* Request object
*/
protected $_request;
/**
* Redirect constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Locale\ResolverInterface $resolver
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Tax\Model\Config $taxConfig
* @param \Magento\Tax\Model\Calculation $taxCalculation
*/
/**
* Request object
*/
protected $_request;
/**
* Redirect constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Locale\ResolverInterface $resolver
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Tax\Model\Config $taxConfig
* @param \Magento\Tax\Model\Calculation $taxCalculation
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Sales\Model\OrderFactory $orderFactory,
......@@ -106,47 +105,48 @@ class Redirect extends \Magento\Payment\Block\Form
$this->_resolver = $resolver;
$this->_adyenLogger = $adyenLogger;
$this->_getOrder();
$this->_getOrder();
$this->_taxConfig = $taxConfig;
$this->_taxCalculation = $taxCalculation;
$this->_request = $context->getRequest();
$this->_request = $context->getRequest();
}
/**
* @return mixed|string[]
* @throws AdyenException
*/
/**
* @return mixed|string[]
* @throws AdyenException
*/
public function getRedirectMethod()
{
if ($redirectMethod = $this->getPayment()->getAdditionalInformation('redirectMethod')) {
return $redirectMethod;
}
throw new AdyenException("No redirect method is provided.");
}
/**
* Retrieves redirect url for the flow of checkout API
*
* @return string[]
* @throws AdyenException
*/
public function getRedirectUrl()
{
if ($redirectUrl = $this->getPayment()->getAdditionalInformation('redirectUrl')) {
return $redirectUrl;
}
throw new AdyenException("No redirect url is provided.");
}
{
if ($redirectMethod = $this->getPayment()->getAdditionalInformation('redirectMethod')) {
return $redirectMethod;
}
throw new AdyenException("No redirect method is provided.");
}
/**
* @return $this
* @return Redirect
*/
public function _prepareLayout()
{
return parent::_prepareLayout();
}
/**
* Retrieves redirect url for the flow of checkout API
*
* @return string[]
* @throws AdyenException
*/
public function getRedirectUrl()
{
if ($redirectUrl = $this->getPayment()->getAdditionalInformation('redirectUrl')) {
return $redirectUrl;
}
throw new AdyenException("No redirect url is provided.");
}
/**
* @return string
*/
......@@ -155,12 +155,11 @@ class Redirect extends \Magento\Payment\Block\Form
$url = "";
try {
if ($this->_order->getPayment()) {
switch ($this->_adyenHelper->isDemoMode()) {
case true:
if ($this->_adyenHelper->doesPaymentMethodSkipDetails(
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)
) {
$url = "https://test.adyen.com/hpp/skipDetails.shtml";
} else {
......@@ -169,8 +168,8 @@ class Redirect extends \Magento\Payment\Block\Form
break;
default:
if ($this->_adyenHelper->doesPaymentMethodSkipDetails(
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)
) {
$url = "https://live.adyen.com/hpp/skipDetails.shtml";
} else {
......@@ -187,13 +186,13 @@ class Redirect extends \Magento\Payment\Block\Form
return $url;
}
/**
* @return mixed
*/
private function getBrandCode()
{
return $this->getPayment()->getAdditionalInformation('brand_code');
}
/**
* @return mixed
*/
private function getBrandCode()
{
return $this->getPayment()->getAdditionalInformation('brand_code');
}
/**
* Set Billing Address data
......@@ -378,7 +377,8 @@ class Redirect extends \Magento\Payment\Block\Form
);
}
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference'];
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " .
$formFields['merchantReference'];
$formFields['openinvoicedata.numberOfLines'] = $count;
return $formFields;
......@@ -420,81 +420,84 @@ class Redirect extends \Magento\Payment\Block\Form
return $this->_checkoutSession;
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function _getRequest()
{
return $this->_request;
}
/**
* Get order object
*
* @return \Magento\Sales\Model\Order
*/
protected function _getOrder()
{
if (!$this->_order) {
$incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
}
return $this->_order;
}
/**
* @return mixed
*/
public function getPaReq()
{
if ($paReq = $this->getPayment()->getAdditionalInformation('paRequest')) {
return $paReq;
}
throw new AdyenException("No paRequest is provided.");
}
/**
* @return string[]
* @throws AdyenException
*/
public function getMd()
{
if ($md = $this->getPayment()->getAdditionalInformation('md')) {
return $md;
}
throw new AdyenException("No MD is provided.");
}
/**
* @return string
*/
public function getTermUrl()
{
return $this->getUrl('adyen/process/redirect',
['_secure' => $this->_getRequest()->isSecure()]);
}
/**
* Retrieve payment object if available
*
* @return \Magento\Framework\DataObject|\Magento\Sales\Api\Data\OrderPaymentInterface|mixed|null
* @throws AdyenException
*/
private function getPayment() {
try {
$paymentObject = $this->_order->getPayment();
if (!empty($paymentObject)) {
return $paymentObject;
}
} catch (Exception $e) {
// do nothing for now
throw($e);
}
throw new AdyenException("No payment object is found.");
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function _getRequest()
{
return $this->_request;
}
/**
* Get order object
*
* @return \Magento\Sales\Model\Order
*/
protected function _getOrder()
{
if (!$this->_order) {
$incrementId = $this->_getCheckout()->getLastRealOrderId();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
}
return $this->_order;
}
/**
* @return mixed
*/
public function getPaReq()
{
if ($paReq = $this->getPayment()->getAdditionalInformation('paRequest')) {
return $paReq;
}
throw new AdyenException("No paRequest is provided.");
}
/**
* @return string[]
* @throws AdyenException
*/
public function getMd()
{
if ($md = $this->getPayment()->getAdditionalInformation('md')) {
return $md;
}
throw new AdyenException("No MD is provided.");
}
/**
* @return string
*/
public function getTermUrl()
{
return $this->getUrl(
'adyen/process/redirect',
['_secure' => $this->_getRequest()->isSecure()]
);
}
/**
* Retrieve payment object if available
*
* @return \Magento\Framework\DataObject|\Magento\Sales\Api\Data\OrderPaymentInterface|mixed|null
* @throws AdyenException
*/
private function getPayment()
{
try {
$paymentObject = $this->_order->getPayment();
if (!empty($paymentObject)) {
return $paymentObject;
}
} catch (Exception $e) {
// do nothing for now
throw($e);
}
throw new AdyenException("No payment object is found.");
}
}
......@@ -36,6 +36,5 @@ class Overview extends \Magento\Backend\App\Action
$resultPage->setActiveMenu('Adyen_Payment::notifications_overview')
->getConfig()->getTitle()->prepend(__('Adyen Notifications Overview'));
return $resultPage;
}
}
\ No newline at end of file
}
......@@ -27,8 +27,7 @@ use Symfony\Component\Config\Definition\Exception\Exception;
use Magento\Framework\App\Request\Http as Http;
/**
* Class Json
* @package Adyen\Payment\Controller\Process
* Class Json extends Action
*/
class Json extends \Magento\Framework\App\Action\Action
{
......@@ -77,9 +76,9 @@ class Json extends \Magento\Framework\App\Action\Action
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->serializer = $serializer;
// Fix for Magento2.3 adding isAjax to the request params
if(interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
if (interface_exists(\Magento\Framework\App\CsrfAwareActionInterface::class)) {
$request = $this->getRequest();
if ($request instanceof Http && $request->isPost()) {
$request->setParam('isAjax', true);
......@@ -110,7 +109,6 @@ class Json extends \Magento\Framework\App\Action\Action
$notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : "";
if ($notificationMode !== "" && $this->_validateNotificationMode($notificationMode)) {
foreach ($notificationItems['notificationItems'] as $notificationItem) {
$status = $this->_processNotification(
$notificationItem['NotificationRequestItem'],
......@@ -126,7 +124,8 @@ class Json extends \Magento\Framework\App\Action\Action
}
$cronCheckTest = $notificationItems['notificationItems'][0]['NotificationRequestItem']['pspReference'];
// Run the query for checking unprocessed notifications, do this only for test notifications coming from the Adyen Customer Area
// Run the query for checking unprocessed notifications, do this only for test notifications coming
// from the Adyen Customer Area
if ($this->_isTestNotification($cronCheckTest)) {
$unprocessedNotifications = $this->_adyenHelper->getUnprocessedNotifications();
if ($unprocessedNotifications > 0) {
......@@ -164,7 +163,8 @@ class Json extends \Magento\Framework\App\Action\Action
$mode = $this->_adyenHelper->getAdyenAbstractConfigData('demo_mode');
// Notification mode can be a string or a boolean
if (($mode == '1' && ($notificationMode == "false" || $notificationMode == false)) || ($mode == '0' && ($notificationMode == 'true' || $notificationMode == true))) {
if (($mode == '1' && ($notificationMode == "false" || !$notificationMode))
|| ($mode == '0' && ($notificationMode == 'true' || $notificationMode))) {
return true;
}
return false;
......@@ -182,7 +182,6 @@ class Json extends \Magento\Framework\App\Action\Action
{
// validate the notification
if ($this->authorised($response)) {
// log the notification
$this->_adyenLogger->addAdyenNotification(
"The content of the notification item is: " . print_r($response, 1)
......@@ -191,7 +190,7 @@ class Json extends \Magento\Framework\App\Action\Action
// check if notification already exists
if (!$this->_isDuplicate($response)) {
try {
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
$notification = $this->_objectManager->create(\Adyen\Payment\Model\Notification::class);
if (isset($response['pspReference'])) {
$notification->setPspreference($response['pspReference']);
......@@ -289,11 +288,9 @@ class Json extends \Magento\Framework\App\Action\Action
// If notification is test check if fields are correct if not return error
if ($this->_isTestNotification($response['pspReference'])) {
if ($usernameCmp != 0 || $passwordCmp != 0) {
$this->_returnResult(
'username (PHP_AUTH_USER) and\or password (PHP_AUTH_PW) are not the same as Magento settings'
);
}
$this->_returnResult(
'username (PHP_AUTH_USER) and\or password (PHP_AUTH_PW) are not the same as Magento settings'
);
}
return false;
}
......@@ -313,7 +310,7 @@ class Json extends \Magento\Framework\App\Action\Action
if (isset($response['originalReference'])) {
$originalReference = trim($response['originalReference']);
}
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
$notification = $this->_objectManager->create(\Adyen\Payment\Model\Notification::class);
return $notification->isDuplicate($pspReference, $eventCode, $success, $originalReference);
}
......@@ -328,19 +325,29 @@ class Json extends \Magento\Framework\App\Action\Action
} elseif (isset($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']) &&
$_SERVER['REDIRECT_REMOTE_AUTHORIZATION'] != ''
) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
list(
$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']
) =
explode(':', base64_decode($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']), 2);
} elseif (!empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
list(
$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']
) =
explode(':', base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)), 2);
} elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
list(
$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']
) =
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)), 2);
} elseif (!empty($_SERVER['REMOTE_USER'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
list(
$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']
) =
explode(':', base64_decode(substr($_SERVER['REMOTE_USER'], 6)), 2);
} elseif (!empty($_SERVER['REDIRECT_REMOTE_USER'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
list(
$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']
) =
explode(':', base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)), 2);
}
}
......@@ -381,6 +388,5 @@ class Json extends \Magento\Framework\App\Action\Action
->clearHeader('Content-Type')
->setHeader('Content-Type', 'text/html')
->setBody($message);
return;
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Controller\Process;
class ResultPos extends \Magento\Framework\App\Action\Action
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -194,7 +193,7 @@ class ResultPos extends \Magento\Framework\App\Action\Action
$amountChecksum = 0;
$amountLength = strlen($amount);
for ($i=0; $i<$amountLength; $i++) {
for ($i = 0; $i < $amountLength; $i++) {
// ASCII value use ord
$checksumCalc = ord($amount[$i]) - 48;
$amountChecksum += $checksumCalc;
......@@ -202,21 +201,21 @@ class ResultPos extends \Magento\Framework\App\Action\Action
$currencyChecksum = 0;
$currencyLength = strlen($currency);
for ($i=0; $i<$currencyLength; $i++) {
for ($i = 0; $i < $currencyLength; $i++) {
$checksumCalc = ord($currency[$i]) - 64;
$currencyChecksum += $checksumCalc;
}
$resultChecksum = 0;
$resultLength = strlen($result);
for ($i=0; $i<$resultLength; $i++) {
for ($i = 0; $i < $resultLength; $i++) {
$checksumCalc = ord($result[$i]) - 64;
$resultChecksum += $checksumCalc;
}
$sessionIdChecksum = 0;
$sessionIdLength = strlen($sessionId);
for ($i=0; $i<$sessionIdLength; $i++) {
for ($i = 0; $i < $sessionIdLength; $i++) {
$checksumCalc = $this->_getAscii2Int($sessionId[$i]);
$sessionIdChecksum += $checksumCalc;
}
......
......@@ -28,7 +28,6 @@ use Magento\Payment\Gateway\CommandInterface;
class PayByMailCommand implements CommandInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -61,7 +60,7 @@ class PayByMailCommand implements CommandInterface
public function execute(array $commandSubject)
{
$stateObject = \Magento\Payment\Gateway\Helper\SubjectReader::readStateObject($commandSubject);
$payment =\Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
$payment = $payment->getPayment();
// do not let magento set status to processing
......@@ -74,7 +73,7 @@ class PayByMailCommand implements CommandInterface
$stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
$stateObject->setStatus($this->_adyenHelper->getAdyenAbstractConfigData('order_status'));
$stateObject->setIsNotified(false);
return $this;
}
......@@ -118,7 +117,6 @@ class PayByMailCommand implements CommandInterface
return $url;
}
/**
* @param \Magento\Sales\Model\Order\Payment $payment
* @param float|bool $paymentAmount
......@@ -128,31 +126,34 @@ class PayByMailCommand implements CommandInterface
{
$order = $payment->getOrder();
$realOrderId = $order->getRealOrderId();
$realOrderId = $order->getRealOrderId();
$orderCurrencyCode = $order->getOrderCurrencyCode();
$storeId = $order->getStore()->getId();
// check if paybymail has it's own skin
$skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code'));
$skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code'));
if ($skinCode == "") {
// use HPP skin and HMAC
$skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code');
$hmacKey = $this->_adyenHelper->getHmac();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale', $storeId));
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code', $storeId));
$hmacKey = $this->_adyenHelper->getHmac();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale', $storeId));
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code', $storeId));
} else {
// use pay_by_mail skin and hmac
$hmacKey = $this->_adyenHelper->getHmacPayByMail();
}
$amount = $this->_adyenHelper->formatAmount($paymentAmount ?: $order->getGrandTotal(), $orderCurrencyCode);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId));
$shopperEmail = $order->getCustomerEmail();
$customerId = $order->getCustomerId();
$amount = $this->_adyenHelper->formatAmount(
$paymentAmount ?: $order->getGrandTotal(),
$orderCurrencyCode
);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId));
$shopperEmail = $order->getCustomerEmail();
$customerId = $order->getCustomerId();
// get locale from store
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_adyenHelper->getStoreLocale($storeId);
$countryCode = (!empty($countryCode)) ? $countryCode : false;
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_adyenHelper->getStoreLocale($storeId);
$countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode
if ($countryCode == false) {
......@@ -163,44 +164,44 @@ class PayByMailCommand implements CommandInterface
}
}
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days', $storeId);
$deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5;
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days', $storeId);
$deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5;
$formFields = [];
$formFields['merchantAccount'] = $merchantAccount;
$formFields['merchantAccount'] = $merchantAccount;
$formFields['merchantReference'] = $realOrderId;
$formFields['paymentAmount'] = (int)$amount;
$formFields['currencyCode'] = $orderCurrencyCode;
$formFields['shipBeforeDate'] = date(
$formFields['paymentAmount'] = (int)$amount;
$formFields['currencyCode'] = $orderCurrencyCode;
$formFields['shipBeforeDate'] = date(
"Y-m-d",
mktime(date("H"), date("i"), date("s"), date("m"), date("j") + $deliveryDays, date("Y"))
);
$formFields['skinCode'] = $skinCode;
$formFields['shopperLocale'] = $shopperLocale;
$formFields['skinCode'] = $skinCode;
$formFields['shopperLocale'] = $shopperLocale;
if ($countryCode != "") {
$formFields['countryCode'] = $countryCode;
$formFields['countryCode'] = $countryCode;
}
$formFields['shopperEmail'] = $shopperEmail;
$formFields['shopperEmail'] = $shopperEmail;
// recurring
$recurringType = $this->_adyenHelper->getRecurringTypeFromOneclickRecurringSetting($storeId);
$recurringType = $this->_adyenHelper->getRecurringTypeFromOneclickRecurringSetting($storeId);
$sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity', $storeId);
if ($sessionValidity == "") {
$sessionValidity = 3;
}
$formFields['sessionValidity'] = date("c", strtotime("+". $sessionValidity. " days"));
$formFields['sessionValidity'] = date("c", strtotime("+" . $sessionValidity . " days"));
if ($customerId > 0) {
$formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = $customerId;
$formFields['shopperReference'] = $customerId;
}
// Sign request using secret key
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $formFields);
$formFields['merchantSig'] = $merchantSig;
$formFields['merchantSig'] = $merchantSig;
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
......
......@@ -26,9 +26,6 @@ namespace Adyen\Payment\Gateway\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
use Adyen\Payment\Model\ApplicationInfo;
/**
* Class TransactionAuthorization
*/
class TransactionAuthorization implements ClientInterface
{
......
......@@ -26,9 +26,6 @@ namespace Adyen\Payment\Gateway\Http\Client;
use Magento\Payment\Gateway\Http\ClientInterface;
use Adyen\Payment\Model\ApplicationInfo;
/**
* Class TransactionPayment
*/
class TransactionPayment implements ClientInterface
{
......
......@@ -144,7 +144,8 @@ class TransactionPosCloudSync implements ClientInterface
$errorMsg = __('In Progress');
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
} else {
$paymentResponse = $statusResponse['RepeatedMessageResponse']['RepeatedResponseMessageBody']['PaymentResponse'];
$paymentResponse = $statusResponse['RepeatedMessageResponse']['RepeatedResponseMessageBody']
['PaymentResponse'];
}
} else {
// probably SaleToPOIRequest, that means terminal unreachable, log the response as error
......
......@@ -40,7 +40,6 @@ class TransactionRefund implements ClientInterface
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper;
......@@ -63,7 +62,7 @@ class TransactionRefund implements ClientInterface
try {
$responses[] = $service->refund($request);
} catch (\Adyen\AdyenException $e) {
$responses[] = array('error' => $e->getMessage());
$responses[] = ['error' => $e->getMessage()];
}
}
return $responses;
......
......@@ -29,7 +29,6 @@ use Magento\Payment\Gateway\Http\TransferInterface;
class TransferFactory implements TransferFactoryInterface
{
/**
* @var TransferBuilder
*/
......
......@@ -25,9 +25,6 @@ namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
/**
* Class AddressDataBuilder
*/
class AddressDataBuilder implements BuilderInterface
{
/**
......@@ -42,8 +39,7 @@ class AddressDataBuilder implements BuilderInterface
*/
public function __construct(
\Adyen\Payment\Helper\Requests $adyenRequestsHelper
)
{
) {
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
......@@ -58,11 +54,11 @@ class AddressDataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getOrder();
$billingAddress = $order->getBillingAddress();
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
$request['body'] = $this->adyenRequestsHelper->buildAddressData([], $billingAddress, $shippingAddress);
$request['body'] = $this->adyenRequestsHelper->buildAddressData($billingAddress, $shippingAddress, []);
return $request;
return $request;
}
}
......@@ -20,6 +20,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
......@@ -41,8 +42,7 @@ class BrowserInfoDataBuilder implements BuilderInterface
*/
public function __construct(
\Adyen\Payment\Helper\Requests $adyenRequestsHelper
)
{
) {
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
......
......@@ -30,7 +30,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
*/
class CancelDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -64,7 +63,7 @@ class CancelDataBuilder implements BuilderInterface
"reference" => $order->getOrderIncrementId(),
"originalReference" => $pspReference
];
$request['clientConfig'] = ["storeId" => $order->getStoreId()];
return $request;
}
......
......@@ -30,7 +30,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
*/
class CaptureDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -54,7 +53,6 @@ class CaptureDataBuilder implements BuilderInterface
*/
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);
......
......@@ -28,7 +28,6 @@ use Adyen\Payment\Observer\AdyenCcDataAssignObserver;
class CcAuthorizationDataBuilder implements BuilderInterface
{
/**
* @param array $buildSubject
* @return mixed
......@@ -64,7 +63,9 @@ class CcAuthorizationDataBuilder implements BuilderInterface
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::HOLDER_NAME);
// if installments is set and card type is credit card add it into the request
$numberOfInstallments = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) ?: 0;
$numberOfInstallments = $payment->getAdditionalInformation(
AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS
) ?: 0;
$comboCardType = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::COMBO_CARD_TYPE) ?: 'credit';
if ($numberOfInstallments > 0) {
$requestBody['installments']['value'] = $numberOfInstallments;
......@@ -96,4 +97,4 @@ class CcAuthorizationDataBuilder implements BuilderInterface
}
return null;
}
}
\ No newline at end of file
}
......@@ -95,7 +95,9 @@ class CcBackendAuthorizationDataBuilder implements BuilderInterface
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) &&
$payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0
) {
$requestBody['installments']['value'] = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS);
$requestBody['installments']['value'] = $payment->getAdditionalInformation(
AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS
);
}
// Flow for Billing agreements, for Vault check VaultDataBuilder
......
This diff is collapsed.
......@@ -20,13 +20,11 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
/**
* Class CustomerDataBuilder
*/
class CustomerDataBuilder implements BuilderInterface
{
/**
......@@ -39,14 +37,13 @@ class CustomerDataBuilder implements BuilderInterface
*
* @param \Adyen\Payment\Helper\Requests $adyenRequestsHelper
*/
public function __construct(
public function __construct(
\Adyen\Payment\Helper\Requests $adyenRequestsHelper
)
{
) {
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
}
/**
/**
* Add shopper data into request
*
* @param array $buildSubject
......@@ -62,7 +59,14 @@ class CustomerDataBuilder implements BuilderInterface
$billingAddress = $order->getBillingAddress();
$storeId = $order->getStoreId();
$additionalInformation = $payment->getAdditionalInformation();
$request['body'] = $this->adyenRequestsHelper->buildCustomerData([], $customerId, $billingAddress, $storeId, $payment, $additionalInformation);
$request['body'] = $this->adyenRequestsHelper->buildCustomerData(
$billingAddress,
$storeId,
$customerId,
$payment,
$additionalInformation,
[]
);
return $request;
}
}
......@@ -20,6 +20,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
......@@ -40,8 +41,8 @@ class CustomerIpDataBuilder implements BuilderInterface
* @param \Adyen\Payment\Helper\Requests $adyenRequestsHelper
*/
public function __construct(
\Adyen\Payment\Helper\Requests $adyenRequestsHelper)
{
\Adyen\Payment\Helper\Requests $adyenRequestsHelper
) {
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
......@@ -54,13 +55,13 @@ class CustomerIpDataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$order = $paymentDataObject->getPayment()->getOrder();
$shopperIp = $order-> getRemoteIp();
$shopperIp = $order->getRemoteIp();
if (empty($shopperIp)) {
$shopperIp = $order-> getXForwardedFor();
$shopperIp = $order->getXForwardedFor();
}
$request['body'] = $this->adyenRequestsHelper->buildCustomerIpData([], $shopperIp);
$request['body'] = $this->adyenRequestsHelper->buildCustomerIpData($shopperIp, []);
return $request;
}
......
......@@ -56,7 +56,7 @@ class MerchantAccountDataBuilder implements BuilderInterface
$storeId = $order->getStoreId();
$method = $payment->getMethod();
$request['body'] = $this->adyenRequestsHelper->buildMerchantAccountData([], $method, $storeId);
$request['body'] = $this->adyenRequestsHelper->buildMerchantAccountData($method, $storeId, []);
return $request;
}
......
......@@ -61,7 +61,9 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface
$requestBody['paymentMethod']['type'] = $variant;
}
if ($securityCode = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::ENCRYPTED_SECURITY_CODE)) {
if ($securityCode = $payment->getAdditionalInformation(
AdyenOneclickDataAssignObserver::ENCRYPTED_SECURITY_CODE
)) {
$requestBody['paymentMethod']['encryptedSecurityCode'] = $securityCode;
}
......@@ -74,7 +76,9 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface
}
$requestBody['shopperInteraction'] = $shopperInteraction;
$requestBody['paymentMethod']['recurringDetailReference'] = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE);
$requestBody['paymentMethod']['recurringDetailReference'] = $payment->getAdditionalInformation(
AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE
);
// if it is a sepadirectdebit set selectedBrand to sepadirectdebit in the case of oneclick
if ($payment->getCcType() == "sepadirectdebit") {
......@@ -93,7 +97,9 @@ class OneclickAuthorizationDataBuilder implements BuilderInterface
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0) {
$requestBody['installments']['value'] = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS);
$requestBody['installments']['value'] = $payment->getAdditionalInformation(
AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS
);
}
$request['body'] = $requestBody;
......
......@@ -20,13 +20,11 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface;
/**
* Payment Data Builder
*/
class PaymentDataBuilder implements BuilderInterface
{
/**
......@@ -43,7 +41,7 @@ class PaymentDataBuilder implements BuilderInterface
{
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
/**
* @param array $buildSubject
* @return array
......@@ -62,8 +60,14 @@ class PaymentDataBuilder implements BuilderInterface
$reference = $order->getOrderIncrementId();
$paymentMethod = $payment->getMethod();
$request['body'] = $this->adyenRequestsHelper->buildPaymentData([], $amount, $currencyCode, $reference, $paymentMethod);
$request['body'] = $this->adyenRequestsHelper->buildPaymentData(
$amount,
$currencyCode,
$reference,
$paymentMethod,
[]
);
return $request;
}
}
......@@ -51,7 +51,6 @@ class RecurringDataBuilder implements BuilderInterface
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
/**
* @param array $buildSubject
* @return array
......@@ -65,7 +64,12 @@ class RecurringDataBuilder implements BuilderInterface
$storeId = $payment->getOrder()->getStoreId();
$areaCode = $this->appState->getAreaCode();
$additionalInformation = $payment->getAdditionalInformation();
$request['body'] = $this->adyenRequestsHelper->buildRecurringData([], $areaCode, $storeId, $additionalInformation);
$request['body'] = $this->adyenRequestsHelper->buildRecurringData(
$areaCode,
$storeId,
$additionalInformation,
[]
);
return $request;
}
}
......@@ -30,7 +30,6 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
*/
class RefundDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -48,6 +47,7 @@ class RefundDataBuilder implements BuilderInterface
/**
* RefundDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $orderPaymentCollectionFactory
*/
......@@ -80,7 +80,6 @@ class RefundDataBuilder implements BuilderInterface
$merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($method, $storeId);
$grandTotal = $payment->getOrder()->getGrandTotal();
// check if it contains a split payment
$orderPaymentCollection = $this->orderPaymentCollectionFactory
->create()
......
......@@ -51,7 +51,6 @@ class ThreeDS2DataBuilder implements BuilderInterface
$this->adyenRequestsHelper = $adyenRequestsHelper;
}
/**
* @param array $buildSubject
* @return array
......@@ -64,7 +63,11 @@ class ThreeDS2DataBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment();
$order = $paymentDataObject->getOrder();
$additionalInformation = $payment->getAdditionalInformation();
$request['body'] = $this->adyenRequestsHelper->buildThreeDS2Data([], $additionalInformation, $order->getStoreId());
$request['body'] = $this->adyenRequestsHelper->buildThreeDS2Data(
$additionalInformation,
$order->getStoreId(),
[]
);
return $request;
}
}
......@@ -54,7 +54,7 @@ class VaultDataBuilder implements BuilderInterface
$payment = $paymentDataObject->getPayment();
$additionalInformation = $payment->getAdditionalInformation();
$request['body'] = $this->adyenRequestsHelper->buildVaultData([], $additionalInformation);
$request['body'] = $this->adyenRequestsHelper->buildVaultData($additionalInformation, []);
return $request;
}
......
......@@ -27,7 +27,6 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class CheckoutPaymentCommentHistoryHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
......@@ -40,7 +39,7 @@ class CheckoutPaymentCommentHistoryHandler implements HandlerInterface
/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
$comment = __("Adyen Result response:");
$comment = __("Adyen Result response:");
if (isset($response['resultCode'])) {
$responseCode = $response['resultCode'];
......@@ -60,12 +59,12 @@ class CheckoutPaymentCommentHistoryHandler implements HandlerInterface
}
if ($responseCode) {
$comment .= '<br /> ' . __('authResult:') . ' ' . $responseCode;
$comment .= '<br /> ' . __('authResult:') . ' ' . $responseCode;
$payment->getOrder()->setAdyenResulturlEventCode($responseCode);
}
if ($pspReference) {
$comment .= '<br /> ' . __('pspReference:') . ' ' . $pspReference;
$comment .= '<br /> ' . __('pspReference:') . ' ' . $pspReference;
}
$payment->getOrder()->addStatusHistoryComment($comment);
......
......@@ -27,13 +27,11 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class CheckoutPaymentsDetailsHandler implements HandlerInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $adyenHelper;
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
......
......@@ -27,7 +27,6 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentCommentHistoryHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
......
......@@ -27,7 +27,6 @@ use Magento\Payment\Gateway\Response\HandlerInterface;
class PaymentCommentHistoryRefundHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
......
......@@ -91,7 +91,8 @@ class PaymentPosCloudHandler implements HandlerInterface
!empty($paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData'])
) {
$maskedPan = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['MaskedPan'];
$expiryDate = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['SensitiveCardData']['ExpiryDate']; // 1225
$expiryDate = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']
['SensitiveCardData']['ExpiryDate']; // 1225
$expiryDate = substr($expiryDate, 0, 2) . '/' . substr($expiryDate, 2, 2);
$brand = $paymentResponse['PaymentResult']['PaymentInstrumentData']['CardData']['PaymentBrand'];
......@@ -113,8 +114,10 @@ class PaymentPosCloudHandler implements HandlerInterface
}
// set transaction(status)
if (!empty($paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'])) {
$pspReference = $paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID'];
if (!empty($paymentResponse['PaymentResult']['PaymentAcquirerData']['AcquirerTransactionID']['TransactionID']))
{
$pspReference = $paymentResponse['PaymentResult']['PaymentAcquirerData']
['AcquirerTransactionID']['TransactionID'];
$payment->setTransactionId($pspReference);
// set transaction(payment)
} else {
......
......@@ -34,12 +34,11 @@ use Magento\Vault\Api\PaymentTokenRepositoryInterface;
class VaultDetailsHandler implements HandlerInterface
{
const RECURRING_DETAIL_REFERENCE = 'recurring.recurringDetailReference';
const CARD_SUMMARY = 'cardSummary';
const EXPIRY_DATE = 'expiryDate';
const PAYMENT_METHOD = 'paymentMethod';
const ADDITIONAL_DATA_ERRORS = array(
const ADDITIONAL_DATA_ERRORS = [
self::RECURRING_DETAIL_REFERENCE => 'Missing Token in Result please enable in ' .
'Settings -> API URLs and Response menu in the Adyen Customer Area Recurring details setting',
self::CARD_SUMMARY => 'Missing cardSummary in Result please login to the adyen portal ' .
......@@ -48,7 +47,7 @@ class VaultDetailsHandler implements HandlerInterface
'Settings -> API URLs and Response and enable the Expiry date property',
self::PAYMENT_METHOD => 'Missing paymentMethod in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Variant property'
);
];
/**
* @var PaymentTokenFactoryInterface
......@@ -117,8 +116,10 @@ class VaultDetailsHandler implements HandlerInterface
$extensionAttributes->setVaultPaymentToken($paymentToken);
} else {
$this->adyenLogger->error(
sprintf('Failure trying to save credit card token in vault for order %s',
$payment->getOrder()->getIncrementId())
sprintf(
'Failure trying to save credit card token in vault for order %s',
$payment->getOrder()->getIncrementId()
)
);
}
}
......@@ -133,7 +134,6 @@ class VaultDetailsHandler implements HandlerInterface
*/
private function getVaultPaymentToken(array $response, $payment)
{
if (empty($response['additionalData'])) {
return null;
}
......@@ -150,15 +150,17 @@ class VaultDetailsHandler implements HandlerInterface
}
try {
// Check if paymentToken exists already
$paymentToken = $this->paymentTokenManagement->getByGatewayToken($additionalData[self::RECURRING_DETAIL_REFERENCE],
$payment->getMethodInstance()->getCode(), $payment->getOrder()->getCustomerId());
$paymentToken = $this->paymentTokenManagement->getByGatewayToken(
$additionalData[self::RECURRING_DETAIL_REFERENCE],
$payment->getMethodInstance()->getCode(),
$payment->getOrder()->getCustomerId()
);
$paymentTokenSaveRequired = false;
// In case the payment token does not exist, create it based on the additionalData
if (is_null($paymentToken)) {
if ($paymentToken === null) {
/** @var PaymentTokenInterface $paymentToken */
$paymentToken = $this->paymentTokenFactory->create(
PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD
......@@ -226,6 +228,7 @@ class VaultDetailsHandler implements HandlerInterface
/**
* Get payment extension attributes
*
* @param InfoInterface $payment
* @return OrderPaymentExtensionInterface
*/
......@@ -238,4 +241,4 @@ class VaultDetailsHandler implements HandlerInterface
}
return $extensionAttributes;
}
}
\ No newline at end of file
}
......@@ -27,7 +27,6 @@ use Magento\Payment\Gateway\Validator\AbstractValidator;
class CancelResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
......
......@@ -27,7 +27,6 @@ use Magento\Payment\Gateway\Validator\AbstractValidator;
class CaptureResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
......
......@@ -35,7 +35,7 @@ class CheckoutResponseValidator extends AbstractValidator
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
private $adyenHelper;
/**
* GeneralResponseValidator constructor.
......@@ -71,12 +71,18 @@ class CheckoutResponseValidator extends AbstractValidator
switch ($response['resultCode']) {
case "IdentifyShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.fingerprintToken']);
$payment->setAdditionalInformation(
'threeDS2Token',
$response['authentication']['threeds2.fingerprintToken']
);
$payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']);
break;
case "ChallengeShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.challengeToken']);
$payment->setAdditionalInformation(
'threeDS2Token',
$response['authentication']['threeds2.challengeToken']
);
$payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']);
break;
case "Authorised":
......@@ -89,7 +95,8 @@ class CheckoutResponseValidator extends AbstractValidator
}
}
} elseif (!empty($response['additionalData']['comprafacil.entity'])) {
//Multibanco resultCode has changed after checkout v49 and comprafacil.entity is not received anymore
//Multibanco resultCode has changed after checkout v49 and
// comprafacil.entity is not received anymore
foreach ($response['additionalData'] as $key => $value) {
if (strpos($key, 'comprafacil') === 0) {
$payment->setAdditionalInformation($key, $value);
......@@ -99,7 +106,9 @@ class CheckoutResponseValidator extends AbstractValidator
// Save cc_type if available in the response
if (!empty($response['additionalData']['paymentMethod'])) {
$ccType = $this->adyenHelper->getMagentoCreditCartType($response['additionalData']['paymentMethod']);
$ccType = $this->adyenHelper->getMagentoCreditCartType(
$response['additionalData']['paymentMethod']
);
$payment->setAdditionalInformation('cc_type', $ccType);
$payment->setCcType($ccType);
}
......@@ -114,7 +123,6 @@ class CheckoutResponseValidator extends AbstractValidator
}
break;
case "RedirectShopper":
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$redirectUrl = null;
......@@ -134,7 +142,6 @@ class CheckoutResponseValidator extends AbstractValidator
// If the redirect data is there then the payment is a card payment with 3d secure
if (isset($response['redirect']['data']['PaReq']) && isset($response['redirect']['data']['MD'])) {
$paReq = null;
$md = null;
......@@ -160,7 +167,8 @@ class CheckoutResponseValidator extends AbstractValidator
$this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg;
}
// otherwise it is an alternative payment method which only requires the redirect url to be present
// otherwise it is an alternative payment method which only requires the
// redirect url to be present
} else {
// Flag to show we are in the checkoutAPM flow
$payment->setAdditionalInformation('checkoutAPM', true);
......@@ -175,11 +183,10 @@ class CheckoutResponseValidator extends AbstractValidator
} else {
$isValid = false;
$errorMsg = __('Payment method is not valid.');
$this->adyenLogger->error($errorMsg);;
$this->adyenLogger->error($errorMsg);
$errorMessages[] = $errorMsg;
}
}
break;
case "Refused":
$errorMsg = __('The payment is REFUSED.');
......
......@@ -75,7 +75,9 @@ class GeneralResponseValidator extends AbstractValidator
// Save cc_type if available in the response
if (!empty($response['additionalData']['paymentMethod'])) {
$ccType = $this->adyenHelper->getMagentoCreditCartType($response['additionalData']['paymentMethod']);
$ccType = $this->adyenHelper->getMagentoCreditCartType(
$response['additionalData']['paymentMethod']
);
$payment->setAdditionalInformation('cc_type', $ccType);
$payment->setCcType($ccType);
}
......
......@@ -51,6 +51,7 @@ class InstallmentValidator extends AbstractValidator
/**
* InstallmentValidator constructor.
*
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
......@@ -63,7 +64,6 @@ class InstallmentValidator extends AbstractValidator
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Quote\Model\QuoteRepository $quoteRepository
) {
$this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
......@@ -72,7 +72,6 @@ class InstallmentValidator extends AbstractValidator
parent::__construct($resultFactory);
}
public function validate(array $validationSubject)
{
$isValid = true;
......
......@@ -27,7 +27,6 @@ use Magento\Payment\Gateway\Validator\AbstractValidator;
class RefundResponseValidator extends AbstractValidator
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
......
......@@ -20,7 +20,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
// phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
namespace Adyen\Payment\Gateway\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
......@@ -62,13 +62,19 @@ class ThreeDS2ResponseValidator extends AbstractValidator
!empty($response['authentication']['threeds2.fingerprintToken'])
) {
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.fingerprintToken']);
$payment->setAdditionalInformation(
'threeDS2Token',
$response['authentication']['threeds2.fingerprintToken']
);
$payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']);
} elseif ($response['resultCode'] == "ChallengeShopper" &&
!empty($response['authentication']['threeds2.challengeToken'])
) {
$payment->setAdditionalInformation('threeDSType', $response['resultCode']);
$payment->setAdditionalInformation('threeDS2Token', $response['authentication']['threeds2.challengeToken']);
$payment->setAdditionalInformation(
'threeDS2Token',
$response['authentication']['threeds2.challengeToken']
);
$payment->setAdditionalInformation('threeDS2PaymentData', $response['paymentData']);
} else {
$errorMsg = __('Error with payment method please select different payment method.');
......
......@@ -27,7 +27,6 @@ use Magento\Framework\App\Config\ScopeConfigInterface;
class Config
{
const XML_PAYMENT_PREFIX = "payment";
const XML_ADYEN_ABSTRACT_PREFIX = "adyen_abstract";
const XML_NOTIFICATIONS_CAN_CANCEL_FIELD = "notifications_can_cancel";
......@@ -39,6 +38,7 @@ class Config
/**
* Config constructor.
*
* @param Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*/
public function __construct(
......
......@@ -144,6 +144,7 @@ class Data extends AbstractHelper
/**
* Data constructor.
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Config\DataInterface $dataStorage
......@@ -216,6 +217,7 @@ class Data extends AbstractHelper
/**
* return recurring types for configuration setting
*
* @return array
*/
public function getRecurringTypes()
......@@ -229,6 +231,7 @@ class Data extends AbstractHelper
/**
* return recurring types for configuration setting
*
* @return array
*/
public function getModes()
......@@ -241,6 +244,7 @@ class Data extends AbstractHelper
/**
* return recurring types for configuration setting
*
* @return array
*/
public function getCaptureModes()
......@@ -253,6 +257,7 @@ class Data extends AbstractHelper
/**
* return recurring types for configuration setting
*
* @return array
*/
public function getPaymentRoutines()
......@@ -265,6 +270,7 @@ class Data extends AbstractHelper
/**
* Return the number of decimals for the specified currency
*
* @param $currency
* @return int
*/
......@@ -305,6 +311,7 @@ class Data extends AbstractHelper
/**
* Return the formatted amount. Adyen accepts the currency in multiple formats.
*
* @param $amount
* @param $currency
* @return int
......@@ -314,7 +321,6 @@ class Data extends AbstractHelper
return (int)number_format($amount, $this->decimalNumbers($currency), '', '');
}
/**
* Tax Percentage needs to be in minor units for Adyen
*
......@@ -376,6 +382,7 @@ class Data extends AbstractHelper
/**
* Street format
*
* @param type $address
* @return array
*/
......@@ -385,7 +392,7 @@ class Data extends AbstractHelper
return false;
}
$street = self::formatStreet($address->getStreet());
$street = $this->formatStreet($address->getStreet());
$streetName = $street['0'];
unset($street['0']);
$streetNr = implode(' ', $street);
......@@ -394,12 +401,13 @@ class Data extends AbstractHelper
/**
* Street format
*
* @param string $streetLine
* @return array
*/
public function getStreetFromString($streetLine)
{
$street = self::formatStreet([$streetLine]);
$street = $this->formatStreet([$streetLine]);
$streetName = $street['0'];
unset($street['0']);
$streetNr = implode(' ', $street);
......@@ -408,11 +416,12 @@ class Data extends AbstractHelper
/**
* Fix this one string street + number
* @example street + number
*
* @param array $street
* @return array $street
* @example street + number
*/
public static function formatStreet($street)
public function formatStreet($street)
{
if (count($street) != 1) {
return $street;
......@@ -430,7 +439,6 @@ class Data extends AbstractHelper
return $street;
}
/**
* gives back global configuration values
*
......@@ -741,15 +749,23 @@ class Data extends AbstractHelper
public function getAPIKey($storeId = null)
{
if ($this->isDemoMode($storeId)) {
$apiKey = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData(
'api_key_test',
$storeId
)));
$apiKey = $this->_encryptor->decrypt(
trim(
$this->getAdyenAbstractConfigData(
'api_key_test',
$storeId
)
)
);
} else {
$apiKey = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData(
'api_key_live',
$storeId
)));
$apiKey = $this->_encryptor->decrypt(
trim(
$this->getAdyenAbstractConfigData(
'api_key_live',
$storeId
)
)
);
}
return $apiKey;
}
......@@ -809,6 +825,7 @@ class Data extends AbstractHelper
/**
* Creditcard type that is selected is different from creditcard type that we get back from the request this
* function get the magento creditcard type this is needed for getting settings like installments
*
* @param $ccType
* @return mixed
*/
......@@ -882,8 +899,10 @@ class Data extends AbstractHelper
*/
public function getModuleVersion()
{
$moduleDir = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Adyen_Payment');
$moduleDir = $this->componentRegistrar->getPath(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Adyen_Payment'
);
$composerJson = file_get_contents($moduleDir . '/composer.json');
$composerJson = json_decode($composerJson, true);
......@@ -1154,6 +1173,7 @@ class Data extends AbstractHelper
/**
* Format Magento locale codes with undersocre to ISO locale codes with dash
*
* @param $localeCode
*/
public function formatLocaleCode($localeCode)
......@@ -1357,9 +1377,11 @@ class Data extends AbstractHelper
$formFields['openinvoicedata.' . $linename . '.itemVatPercentage'] = $itemVatPercentage;
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems;
if ($this->isVatCategoryHigh($payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
))
if ($this->isVatCategoryHigh(
$payment->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE
)
)
) {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
} else {
......@@ -1438,7 +1460,8 @@ class Data extends AbstractHelper
$formattedHtml .= "<td class='terminal-api-receipt-name'>&nbsp;</td>";
}
if (!empty($textParts['value'])) {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>" . $textParts['value'] . "</td>";
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>"
. $textParts['value'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>";
}
......@@ -1512,7 +1535,7 @@ class Data extends AbstractHelper
public function getOrigin()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('Magento\Framework\App\State');
$state = $objectManager->get(\Magento\Framework\App\State::class);
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
if ('adminhtml' === $state->getAreaCode()) {
$baseUrl = $this->helperBackend->getHomePageUrl();
......@@ -1644,7 +1667,6 @@ class Data extends AbstractHelper
$additionalData['recurring.recurringDetailReference']
);
} else {
$billingAgreement->setIsObjectChanged(true);
$message = __(
'Updated billing agreement #%1.',
......@@ -1659,12 +1681,10 @@ class Data extends AbstractHelper
$billingAgreementErrors = $billingAgreement->getErrors();
if ($billingAgreement->isValid() && empty($billingAgreementErrors)) {
if (!$this->agreementResourceModel->getOrderRelation(
$billingAgreement->getAgreementId(),
$order->getId()
)) {
// save into sales_billing_agreement_order
$billingAgreement->addOrderRelation($order);
}
......@@ -1677,7 +1697,6 @@ class Data extends AbstractHelper
);
throw new \Exception($message);
}
} catch (\Exception $exception) {
$message = $exception->getMessage();
$this->adyenLogger->error("exception: " . $message);
......@@ -1691,6 +1710,7 @@ class Data extends AbstractHelper
/**
* Method can be used by interceptors to provide the customer ID in a different way.
*
* @param \Magento\Sales\Model\Order $order
* @return int|null
*/
......@@ -1863,7 +1883,6 @@ class Data extends AbstractHelper
*/
public function getPspReferenceSearchUrl($pspReference, $liveEnvironment)
{
if ($liveEnvironment === "true") {
$checkoutEnvironment = "live";
} else {
......@@ -1874,6 +1893,5 @@ class Data extends AbstractHelper
$checkoutEnvironment,
$pspReference
);
}
}
......@@ -50,10 +50,10 @@ class PaymentMethods extends AbstractHelper
*/
protected $session;
/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
protected $localeResolver;
/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
protected $localeResolver;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
......@@ -97,7 +97,7 @@ class PaymentMethods extends AbstractHelper
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param Data $adyenHelper
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\App\RequestInterface $request
......@@ -110,7 +110,7 @@ class PaymentMethods extends AbstractHelper
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $session,
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\App\RequestInterface $request,
......@@ -122,7 +122,7 @@ class PaymentMethods extends AbstractHelper
$this->config = $config;
$this->adyenHelper = $adyenHelper;
$this->session = $session;
$this->localeResolver = $localeResolver;
$this->localeResolver = $localeResolver;
$this->adyenLogger = $adyenLogger;
$this->assetRepo = $assetRepo;
$this->request = $request;
......@@ -195,7 +195,6 @@ class PaymentMethods extends AbstractHelper
$paymentMethods = [];
if (isset($responseData['paymentMethods'])) {
foreach ($responseData['paymentMethods'] as $paymentMethod) {
$paymentMethodCode = $paymentMethod['type'];
$paymentMethod = $this->fieldMapPaymentMethod($paymentMethod);
......@@ -218,14 +217,20 @@ class PaymentMethods extends AbstractHelper
}
$params = [];
$params = array_merge([
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'_secure' => $this->request->isSecure(),
'theme' => $themeCode
], $params);
$asset = $this->assetRepo->createAsset('Adyen_Payment::images/logos/' .
$paymentMethodCode . '.png', $params);
$params = array_merge(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'_secure' => $this->request->isSecure(),
'theme' => $themeCode
],
$params
);
$asset = $this->assetRepo->createAsset(
'Adyen_Payment::images/logos/' .
$paymentMethodCode . '.png',
$params
);
$placeholder = $this->assetSource->findSource($asset);
......@@ -258,7 +263,6 @@ class PaymentMethods extends AbstractHelper
return 10;
}
/**
* @param $store
* @return mixed
......@@ -332,7 +336,6 @@ class PaymentMethods extends AbstractHelper
*/
protected function getPaymentMethodsResponse($requestParams, $store)
{
// initialize the adyen client
$client = $this->adyenHelper->initializeAdyenClient($store->getId());
......@@ -382,7 +385,6 @@ class PaymentMethods extends AbstractHelper
*/
public function getConnectedTerminals()
{
$storeId = $this->getQuote()->getStoreId();
// initialize the adyen client
......
......@@ -55,7 +55,7 @@ class Requests extends AbstractHelper
* @param $storeId
* @return mixed
*/
public function buildMerchantAccountData($request = [], $paymentMethod, $storeId)
public function buildMerchantAccountData($paymentMethod, $storeId, $request = [])
{
// Retrieve merchant account
$merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($paymentMethod, $storeId);
......@@ -67,16 +67,22 @@ class Requests extends AbstractHelper
}
/**
* @param array $request
* @param int $customerId
* @param $billingAddress
* @param $storeId
* @param null $payment
* @param null $additionalData
* @return array
* @param array $request
*/
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null, $additionalData = null)
{
public function buildCustomerData(
$billingAddress,
$storeId,
$customerId = 0,
$payment = null,
$additionalData = null,
$request = []
) {
if ($customerId > 0) {
$request['shopperReference'] = $customerId;
}
......@@ -150,7 +156,7 @@ class Requests extends AbstractHelper
* @param $ipAddress
* @return mixed
*/
public function buildCustomerIpData($request = [], $ipAddress)
public function buildCustomerIpData($ipAddress, $request = [])
{
$request['shopperIP'] = $ipAddress;
......@@ -163,10 +169,9 @@ class Requests extends AbstractHelper
* @param $shippingAddress
* @return mixed
*/
public function buildAddressData($request = [], $billingAddress, $shippingAddress)
public function buildAddressData($billingAddress, $shippingAddress, $request = [])
{
if ($billingAddress) {
// Billing address defaults
$requestBillingDefaults = [
"street" => "N/A",
......@@ -212,7 +217,6 @@ class Requests extends AbstractHelper
}
if ($shippingAddress) {
// Delivery address defaults
$requestDeliveryDefaults = [
"street" => "N/A",
......@@ -269,7 +273,7 @@ class Requests extends AbstractHelper
* @param $paymentMethod
* @return array
*/
public function buildPaymentData($request = [], $amount, $currencyCode, $reference, $paymentMethod)
public function buildPaymentData($amount, $currencyCode, $reference, $paymentMethod, $request = [])
{
$request['amount'] = [
'currency' => $currencyCode,
......@@ -305,7 +309,7 @@ class Requests extends AbstractHelper
* @param $storeId
* @return array
*/
public function buildThreeDS2Data($request = [], $additionalData, $storeId)
public function buildThreeDS2Data($additionalData, $storeId, $request = [])
{
if ($this->adyenHelper->isCreditCardThreeDS2Enabled($storeId)) {
$request['additionalData']['allow3DS2'] = true;
......@@ -337,11 +341,10 @@ class Requests extends AbstractHelper
* @param $storeId
* @param $payment
*/
public function buildRecurringData($request = [], $areaCode, int $storeId, $additionalData)
public function buildRecurringData($areaCode, int $storeId, $additionalData, $request = [])
{
// If the vault feature is on this logic is handled in the VaultDataBuilder
if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
if ($areaCode !== \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$storeId = null;
}
......@@ -376,7 +379,7 @@ class Requests extends AbstractHelper
* @param $storeIdbuildCCData
* @return mixed
*/
public function buildCCData($request = [], $payload, $storeId, $areaCode)
public function buildCCData($payload, $storeId, $areaCode, $request = [])
{
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail
......@@ -388,33 +391,44 @@ class Requests extends AbstractHelper
$request['paymentMethod']['type'] = 'scheme';
}
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER]) &&
$cardNumber = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER]) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER]) &&
$cardNumber = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER]) {
$request['paymentMethod']['encryptedCardNumber'] = $cardNumber;
}
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH]) &&
$expiryMonth = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH]) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH]) &&
$expiryMonth = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH]) {
$request['paymentMethod']['encryptedExpiryMonth'] = $expiryMonth;
}
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR]) &&
$expiryYear = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR]) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR]) &&
$expiryYear = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR]) {
$request['paymentMethod']['encryptedExpiryYear'] = $expiryYear;
}
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::HOLDER_NAME]) && $holderName =
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::HOLDER_NAME]) && $holderName =
$payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::HOLDER_NAME]) {
$request['paymentMethod']['holderName'] = $holderName;
}
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE]) &&
$securityCode = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE]) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE]) &&
$securityCode = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE]) {
$request['paymentMethod']['encryptedSecurityCode'] = $securityCode;
}
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE]) &&
$recurringDetailReference = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE]
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE]) &&
$recurringDetailReference = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE]
) {
$request['paymentMethod']['recurringDetailReference'] = $recurringDetailReference;
}
......@@ -439,8 +453,10 @@ class Requests extends AbstractHelper
}
// if installments is set add it into the request
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS])) {
if (($numberOfInstallment = $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS]) > 0) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS])) {
if (($numberOfInstallment = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
[AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS]) > 0) {
$request['installments']['value'] = $numberOfInstallment;
}
}
......@@ -454,7 +470,7 @@ class Requests extends AbstractHelper
* @param $additionalInformation
* @return mixed
*/
public function buildVaultData($request = [], $payload)
public function buildVaultData($payload, $request = [])
{
if ($this->adyenHelper->isCreditCardVaultEnabled()) {
if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE]) &&
......@@ -488,12 +504,16 @@ class Requests extends AbstractHelper
$address = $this->adyenHelper->getStreetFromString($address->getStreetFull());
} else {
$address = $this->adyenHelper->getStreetFromString(
implode(' ', [
$address->getStreetLine1(),
$address->getStreetLine2(),
$address->getStreetLine3(),
$address->getStreetLine4()
]));
implode(
' ',
[
$address->getStreetLine1(),
$address->getStreetLine2(),
$address->getStreetLine3(),
$address->getStreetLine4()
]
)
);
}
return $address;
......
......@@ -27,7 +27,6 @@ use Monolog\Logger;
class AdyenLogger extends Logger
{
/**
* Detailed debug information
*/
......@@ -62,8 +61,8 @@ class AdyenLogger extends Logger
*
* This method allows for compatibility with common interfaces.
*
* @param string $message The log message
* @param array $context The log context
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addAdyenNotification($message, array $context = [])
......@@ -89,9 +88,9 @@ class AdyenLogger extends Logger
/**
* Adds a log record.
*
* @param integer $level The logging level
* @param string $message The log message
* @param array $context The log context
* @param integer $level The logging level
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addRecord($level, $message, array $context = [])
......@@ -105,8 +104,8 @@ class AdyenLogger extends Logger
*
* This method allows for compatibility with common interfaces.
*
* @param string $message The log message
* @param array $context The log context
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addNotificationLog($message, array $context = [])
......
......@@ -60,9 +60,9 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
*/
protected $productMetadata;
/**
* AdyenInitiateTerminalApi constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Checkout\Model\Session $checkoutSession
......@@ -100,6 +100,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
/**
* Trigger sync call on terminal
*
* @return mixed
* @throws \Exception
*/
......@@ -110,7 +111,9 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
// Validate JSON that has just been parsed if it was in a valid format
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Magento\Framework\Exception\LocalizedException(__('Terminal API initiate request was not a valid JSON'));
throw new \Magento\Framework\Exception\LocalizedException(
__('Terminal API initiate request was not a valid JSON')
);
}
if (empty($payload['terminal_id'])) {
......@@ -186,7 +189,6 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$request['SaleToPOIRequest']['PaymentData'] = [
'PaymentType' => $transactionType,
];
}
$request = $this->addSaleToAcquirerData($request, $quote);
......@@ -240,6 +242,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
/**
* Add SaleToAcquirerData for storing for recurring transactions and able to track platform and version
* When upgrading to new version of library we can use the client methods
*
* @param $request
* @param $quote
* @return mixed
......@@ -262,10 +265,18 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
}
}
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION][ApplicationInfo::VERSION] = $this->adyenHelper->getModuleVersion();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION][ApplicationInfo::NAME] = $this->adyenHelper->getModuleName();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM][ApplicationInfo::VERSION] = $this->productMetadata->getVersion();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM][ApplicationInfo::NAME] = $this->productMetadata->getName();
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION]
[ApplicationInfo::VERSION] = $this->adyenHelper->getModuleVersion(
);
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::MERCHANT_APPLICATION]
[ApplicationInfo::NAME] = $this->adyenHelper->getModuleName(
);
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM]
[ApplicationInfo::VERSION] = $this->productMetadata->getVersion(
);
$saleToAcquirerData[ApplicationInfo::APPLICATION_INFO][ApplicationInfo::EXTERNAL_PLATFORM]
[ApplicationInfo::NAME] = $this->productMetadata->getName(
);
$saleToAcquirerDataBase64 = base64_encode(json_encode($saleToAcquirerData));
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = $saleToAcquirerDataBase64;
return $request;
......
......@@ -24,7 +24,6 @@
namespace Adyen\Payment\Model;
use Adyen\AdyenException;
use Adyen\Payment\Helper\Data as AdyenHelper;
use Magento\Framework\Exception\NoSuchEntityException as MagentoNoSuchEntityException;
......@@ -50,4 +49,4 @@ class AdyenOriginKey implements \Adyen\Payment\Api\AdyenOriginKeyInterface
{
return $this->helper->getOriginKeyForBaseUrl();
}
}
\ No newline at end of file
}
......@@ -45,6 +45,7 @@ class AdyenRequestMerchantSession implements AdyenRequestMerchantSessionInterfac
/**
* AdyenRequestMerchantSession constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
......@@ -57,7 +58,6 @@ class AdyenRequestMerchantSession implements AdyenRequestMerchantSessionInterfac
$this->_storeManager = $storeManager;
}
/**
* Get the merchant Session from Apple to start Apple Pay transaction
*
......@@ -65,14 +65,17 @@ class AdyenRequestMerchantSession implements AdyenRequestMerchantSessionInterfac
*/
public function getMerchantSession()
{
// Works for test and live. Maybe we need to switch for validationUrl from callback event waiting for apple to respond
// Works for test and live. Maybe we need to switch for validationUrl
// from callback event waiting for apple to respond
$validationUrl = "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession";
// create a new cURL resource
$ch = curl_init();
$merchantIdentifier = $this->_adyenHelper->getAdyenApplePayMerchantIdentifier();
$domainName = parse_url($this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB))['host'];
$domainName = parse_url(
$this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB)
)['host'];
$displayName = $this->_storeManager->getStore()->getName();
$data = '{
......@@ -92,10 +95,14 @@ class AdyenRequestMerchantSession implements AdyenRequestMerchantSessionInterfac
curl_setopt($ch, CURLOPT_SSLCERT, $fullPathLocationPEMFile);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
[
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
]);
]
);
$result = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
......@@ -105,7 +112,9 @@ class AdyenRequestMerchantSession implements AdyenRequestMerchantSessionInterfac
// result not 200 throw error
if ($httpStatus != 200 && $result) {
$this->_adyenLogger->addAdyenDebug("Error Apple, API HTTP Status is: " . $httpStatus . " result is:" . $result);
$this->_adyenLogger->addAdyenDebug(
"Error Apple, API HTTP Status is: " . $httpStatus . " result is:" . $result
);
} elseif (!$result) {
$errno = curl_errno($ch);
$message = curl_error($ch);
......
......@@ -60,8 +60,7 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
)
{
) {
$this->checkoutSession = $checkoutSession;
$this->adyenHelper = $adyenHelper;
$this->orderFactory = $orderFactory;
......@@ -69,9 +68,9 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
}
/**
* @api
* @param string $payload
* @return string
* @api
*/
public function initiate($payload)
{
......@@ -80,13 +79,16 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
// Validate JSON that has just been parsed if it was in a valid format
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure 2.0 failed because the request was not a valid JSON'));
throw new \Magento\Framework\Exception\LocalizedException(
__('3D secure 2.0 failed because the request was not a valid JSON')
);
}
if (empty($payload['orderId'])) {
$order = $this->getOrder();
// In the next major release remove support for retrieving order from session and throw exception instead
//throw new \Magento\Framework\Exception\LocalizedException(__('3D secure 2.0 failed because of a missing order id'));
//throw new \Magento\Framework\Exception\LocalizedException
//(__('3D secure 2.0 failed because of a missing order id'));
} else {
// Create order by order id
$order = $this->orderFactory->create()->load($payload['orderId']);
......@@ -107,7 +109,9 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
$payment->unsAdditionalInformation("threeDS2PaymentData");
} else {
$this->adyenLogger->error("3D secure 2.0 failed, payment data not found");
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure 2.0 failed, payment data not found'));
throw new \Magento\Framework\Exception\LocalizedException(
__('3D secure 2.0 failed, payment data not found')
);
}
// Depends on the component's response we send a fingerprint or the challenge result
......@@ -133,7 +137,10 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
$result['resultCode'] === 'ChallengeShopper' &&
!empty($result['authentication']['threeds2.challengeToken'])
) {
return $this->adyenHelper->buildThreeDS2ProcessResponseJson($result['resultCode'], $result['authentication']['threeds2.challengeToken']);
return $this->adyenHelper->buildThreeDS2ProcessResponseJson(
$result['resultCode'],
$result['authentication']['threeds2.challengeToken']
);
}
// Save the payments response because we are going to need it during the place order flow
......@@ -144,7 +151,7 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
$response = [];
if($result['resultCode'] != 'Authorised') {
if ($result['resultCode'] != 'Authorised') {
$this->checkoutSession->restoreQuote();
// Always cancel the order if the paymenth has failed
......
......@@ -27,7 +27,6 @@ use Magento\Framework\DataObject;
class PaymentRequest extends DataObject
{
/**
* @var \Magento\Framework\Encryption\EncryptorInterface
*/
......@@ -103,9 +102,9 @@ class PaymentRequest extends DataObject
$paResponse = $payment->getAdditionalInformation('paResponse');
$paymentData = $payment->getAdditionalInformation('paymentData');
$payment->unsAdditionalInformation('paymentData');
$payment->unsAdditionalInformation('paRequest');
$payment->unsAdditionalInformation('md');
$payment->unsAdditionalInformation('paymentData');
$payment->unsAdditionalInformation('paRequest');
$payment->unsAdditionalInformation('md');
$request = [
"paymentData" => $paymentData,
......@@ -218,8 +217,8 @@ class PaymentRequest extends DataObject
];
// call lib
$client = $this->_adyenHelper->initializeAdyenClient($storeId);
$service = $this->_adyenHelper->createAdyenRecurringService($client);
$client = $this->_adyenHelper->initializeAdyenClient($storeId);
$service = $this->_adyenHelper->createAdyenRecurringService($client);
try {
$result = $service->disable($request);
......
......@@ -38,6 +38,7 @@ class ApplicationInfo
/**
* ApplicationInfo constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
......@@ -57,7 +58,8 @@ class ApplicationInfo
{
// add applicationInfo into request
$request[self::APPLICATION_INFO][self::MERCHANT_APPLICATION][self::NAME] = $this->adyenHelper->getModuleName();
$request[self::APPLICATION_INFO][self::MERCHANT_APPLICATION][self::VERSION] = $this->adyenHelper->getModuleVersion();
$request[self::APPLICATION_INFO][self::MERCHANT_APPLICATION][self::VERSION] =
$this->adyenHelper->getModuleVersion();
return $request;
}
}
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Model\Billing;
class Agreement extends \Magento\Paypal\Model\Billing\Agreement
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -97,11 +96,13 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
//Billing agreement SEPA
if (isset($data['bank']['iban'])) {
$this->setAgreementLabel(__(
'%1, %2',
$data['bank']['iban'],
$data['bank']['ownerName']
));
$this->setAgreementLabel(
__(
'%1, %2',
$data['bank']['iban'],
$data['bank']['ownerName']
)
);
}
// Billing agreement is CC
......@@ -188,7 +189,11 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
!isset($contractDetail['expiryDate']) ||
!isset($contractDetail['paymentMethod'])
) {
$this->_errors[] = __('"In the Additional data in API response section, select: Card bin, Card summary, Expiry Date, Cardholder name, Recurring details and Variant to create billing agreements immediately after the payment is authorized."');
$this->_errors[] = __(
'"In the Additional data in API response section, select: Card bin,
Card summary, Expiry Date, Cardholder name, Recurring details and Variant
to create billing agreements immediately after the payment is authorized."'
);
return $this;
}
// Billing agreement is CC
......@@ -262,7 +267,8 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
return $this;
}
public function getErrors() {
public function getErrors()
{
return $this->_errors;
}
}
......@@ -36,4 +36,4 @@ class ApiKeyEnding implements CommentInterface
}
return "Key stored ending in <strong>$apiKeyEnding</strong>";
}
}
\ No newline at end of file
}
......@@ -106,7 +106,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
protected function _afterLoad()
{
$value = $this->getValue();
if(!empty($value)) {
if (!empty($value)) {
$value = $this->serializer->unserialize($value);
if (is_array($value)) {
$value = $this->encodeArrayFieldValue($value);
......
......@@ -20,9 +20,11 @@
*
* Author: Adyen <magento@adyen.com>
*/
/**
* Payment Config Converter
*/
namespace Adyen\Payment\Model\Config;
class Converter implements \Magento\Framework\Config\ConverterInterface
......
......@@ -20,9 +20,11 @@
*
* Author: Adyen <magento@adyen.com>
*/
/**
* Loads catalog attributes configuration from multiple XML files by merging them together
*/
namespace Adyen\Payment\Model\Config;
class Reader extends \Magento\Framework\Config\Reader\Filesystem
......
......@@ -20,9 +20,11 @@
*
* Author: Adyen <magento@adyen.com>
*/
/**
* Locator for payment config XSD schemas.
*/
namespace Adyen\Payment\Model\Config;
use Magento\Framework\Module\Dir;
......
......@@ -23,13 +23,8 @@
namespace Adyen\Payment\Model\Config\Source;
/**
* Class BoletoType
* @package Adyen\Payment\Model\Config\Source
*/
class BoletoType implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......
......@@ -25,13 +25,11 @@ namespace Adyen\Payment\Model\Config\Source;
class CaptureMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
protected $_adyenHelper;
/**
* CaptureMode constructor.
*
......
......@@ -24,12 +24,10 @@
namespace Adyen\Payment\Model\Config\Source;
/**
* Class CcType
* @codeCoverageIgnore
*/
class CcType extends \Magento\Payment\Model\Source\Cctype
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......@@ -56,7 +54,7 @@ class CcType extends \Magento\Payment\Model\Source\Cctype
*/
public function getAllowedTypes()
{
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN', 'BCMC', 'HIPERCARD','ELO', 'TROY', 'DANKORT'];
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN', 'BCMC', 'HIPERCARD', 'ELO', 'TROY', 'DANKORT'];
}
/**
......
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Model\Config\Source;
class DemoMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
......
......@@ -26,7 +26,7 @@ namespace Adyen\Payment\Model\Config\Source;
class RecurringType implements \Magento\Framework\Option\ArrayInterface
{
const UNDEFINED_OPTION_LABEL = 'NONE';
/**
* @var \Adyen\Payment\Helper\Data
*/
......
......@@ -36,7 +36,7 @@ class SplitPaymentRefundStrategy implements \Magento\Framework\Option\ArrayInter
{
return $this->getSplitPaymentRefundStrategies();
}
/**
* @return array
*/
......
This diff is collapsed.
......@@ -33,7 +33,7 @@ class Gender
/**
* @return array
*/
public static function getGenderTypes()
public function getGenderTypes()
{
return [
self::MALE_VALUE => __('Male'),
......@@ -47,7 +47,7 @@ class Gender
* @param string $genderValue
* @return null|string
*/
public static function getMagentoGenderFromAdyenGender($genderValue)
public function getMagentoGenderFromAdyenGender($genderValue)
{
$gender = null;
if ($genderValue == self::MALE_VALUE) {
......@@ -62,7 +62,7 @@ class Gender
* @param string $genderValue
* @return null|string
*/
public static function getAdyenGenderFromMagentoGender($genderValue)
public function getAdyenGenderFromMagentoGender($genderValue)
{
$gender = null;
if ($genderValue == self::MALE) {
......
......@@ -21,6 +21,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\InstantPurchase\CreditCard;
use Magento\InstantPurchase\PaymentMethodIntegration\AvailabilityCheckerInterface;
......@@ -30,7 +31,6 @@ use Magento\InstantPurchase\PaymentMethodIntegration\AvailabilityCheckerInterfac
*/
class AvailabilityChecker implements AvailabilityCheckerInterface
{
/**
* @inheritdoc
*/
......
......@@ -21,6 +21,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\InstantPurchase\CreditCard;
use Magento\InstantPurchase\PaymentMethodIntegration\PaymentTokenFormatterInterface;
......@@ -33,6 +34,7 @@ class TokenFormatter implements PaymentTokenFormatterInterface
{
/**
* Most used credit card types
*
* @var array
*/
public static $baseCardTypes = [
......
......@@ -21,7 +21,7 @@
*
* Author: Adyen <magento@adyen.com>
*/
// phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found
namespace Adyen\Payment\Model;
use Adyen\Payment\Api\Data\InvoiceInterface;
......@@ -54,7 +54,7 @@ class Invoice extends \Magento\Framework\Model\AbstractModel implements InvoiceI
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\ResourceModel\Invoice');
$this->_init(\Adyen\Payment\Model\ResourceModel\Invoice::class);
}
/**
......@@ -80,6 +80,7 @@ class Invoice extends \Magento\Framework\Model\AbstractModel implements InvoiceI
/**
* Gets the Pspreference of the original Payment
*
* @return mixed
*/
public function getOriginalReference()
......@@ -97,6 +98,7 @@ class Invoice extends \Magento\Framework\Model\AbstractModel implements InvoiceI
{
return $this->setData(self::ORIGINAL_REFERENCE, $originalReference);
}
/**
* Gets the AcquirerReference for the invoice.
*
......
......@@ -39,9 +39,9 @@ class Adapter extends Method\Adapter
*/
protected $_paymentRequest;
/**
* Adapter constructor.
*
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param ManagerInterface $eventManager
* @param ValueHandlerPoolInterface $valueHandlerPool
......
......@@ -20,18 +20,17 @@
*
* Author: Adyen <magento@adyen.com>
*/
// phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found
namespace Adyen\Payment\Model;
use Adyen\Payment\Api\Data\NotificationInterface;
class Notification extends \Magento\Framework\Model\AbstractModel implements NotificationInterface
{
const AUTHORISATION = 'AUTHORISATION';
const PENDING = 'PENDING';
const AUTHORISED = 'AUTHORISED';
const RECEIVED = 'RECEIVED';
const RECEIVED = 'RECEIVED';
const CANCELLED = 'CANCELLED';
const REFUSED = 'REFUSED';
const ERROR = 'ERROR';
......@@ -77,7 +76,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel implements Not
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\ResourceModel\Notification');
$this->_init(\Adyen\Payment\Model\ResourceModel\Notification::class);
}
/**
......@@ -214,7 +213,6 @@ class Notification extends \Magento\Framework\Model\AbstractModel implements Not
return $this->setData(self::SUCCESS, $success);
}
/**
* Gets the Paymentmethod for the notification.
*
......
......@@ -21,13 +21,13 @@
* Author: Adyen <magento@adyen.com>
*/
// phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found
namespace Adyen\Payment\Model\Order;
use Adyen\Payment\Api\Data\OrderPaymentInterface;
class Payment extends \Magento\Framework\Model\AbstractModel implements OrderPaymentInterface
{
/**
* Notification constructor.
*
......@@ -54,7 +54,7 @@ class Payment extends \Magento\Framework\Model\AbstractModel implements OrderPay
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\ResourceModel\Order\Payment');
$this->_init(\Adyen\Payment\Model\ResourceModel\Order\Payment::class);
}
/**
......
......@@ -25,7 +25,6 @@ namespace Adyen\Payment\Model;
class RecurringType
{
const NONE = '';
const ONECLICK = 'ONECLICK';
const ONECLICK_RECURRING = 'ONECLICK,RECURRING';
......
......@@ -28,14 +28,13 @@ namespace Adyen\Payment\Model\ResourceModel\Billing;
*/
class Agreement extends \Magento\Paypal\Model\ResourceModel\Billing\Agreement
{
public function getOrderRelation($agreementId, $orderId)
{
$select = $this->getConnection()->select()
->from(['billingagreement_order' => $this->getTable('paypal_billing_agreement_order')])
->where('billingagreement_order.agreement_id=?', $agreementId)
->where('billingagreement_order.order_id=?', $orderId);
return $this->getConnection()->fetchAll($select);
}
}
......@@ -28,7 +28,6 @@ namespace Adyen\Payment\Model\ResourceModel\Billing\Agreement;
*/
class Collection extends \Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection
{
/**
* Collection initialization
*
......@@ -36,7 +35,7 @@ class Collection extends \Magento\Paypal\Model\ResourceModel\Billing\Agreement\C
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\Billing\Agreement', 'Magento\Paypal\Model\ResourceModel\Billing\Agreement');
$this->_init(\Adyen\Payment\Model\Billing\Agreement::class, \Magento\Paypal\Model\ResourceModel\Billing\Agreement::class);
}
/**
......
......@@ -31,6 +31,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/
public function _construct()
{
$this->_init('Adyen\Payment\Model\Invoice', 'Adyen\Payment\Model\ResourceModel\Invoice');
$this->_init(\Adyen\Payment\Model\Invoice::class, \Adyen\Payment\Model\ResourceModel\Invoice::class);
}
}
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.
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