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 57a004f4 authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Merge pull request #453 from Adyen/PW-1273-PW-1349

PW-1273 Undefined index check in cc payment response PW-1349 getCurrentLocaleCode fallback bug
parents 296f8de9 cfe59586
...@@ -214,13 +214,18 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -214,13 +214,18 @@ class Result extends \Magento\Framework\App\Action\Action
{ {
$result = false; $result = false;
$this->_adyenLogger->addAdyenResult('Updating the order');
if (!empty($response['authResult'])) { if (!empty($response['authResult'])) {
$authResult = $response['authResult']; $authResult = $response['authResult'];
} elseif (!empty($response['resultCode'])) { } elseif (!empty($response['resultCode'])) {
$authResult = $response['resultCode']; $authResult = $response['resultCode'];
} } else {
// In case the result is unknown we log the request and don't update the history
$this->_adyenLogger->addError("Unexpected result query parameter. Response: " . json_encode($response));
return $result;
}
$this->_adyenLogger->addAdyenResult('Updating the order');
$paymentMethod = isset($response['paymentMethod']) ? trim($response['paymentMethod']) : ''; $paymentMethod = isset($response['paymentMethod']) ? trim($response['paymentMethod']) : '';
$pspReference = isset($response['pspReference']) ? trim($response['pspReference']) : ''; $pspReference = isset($response['pspReference']) ? trim($response['pspReference']) : '';
......
...@@ -38,19 +38,27 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -38,19 +38,27 @@ class VaultDetailsHandler implements HandlerInterface
/** /**
* @var \Adyen\Payment\Logger\AdyenLogger * @var \Adyen\Payment\Logger\AdyenLogger
*/ */
private $_adyenLogger; private $adyenLogger;
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/** /**
* VaultDetailsHandler constructor. * VaultDetailsHandler constructor.
* *
* @param PaymentTokenFactoryInterface $paymentTokenFactory * @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/ */
public function __construct( public function __construct(
PaymentTokenFactoryInterface $paymentTokenFactory, PaymentTokenFactoryInterface $paymentTokenFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper
) { ) {
$this->_adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
$this->paymentTokenFactory = $paymentTokenFactory; $this->paymentTokenFactory = $paymentTokenFactory;
} }
...@@ -61,15 +69,17 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -61,15 +69,17 @@ class VaultDetailsHandler implements HandlerInterface
{ {
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */ /** @var \Adyen\Payment\Api\Data\OrderPaymentInterface $payment */
$payment = $payment->getPayment(); $payment = $payment->getPayment();
// add vault payment token entity to extension attributes if ($this->adyenHelper->isCreditCardVaultEnabled($payment->getOrder()->getStoreId())) {
$paymentToken = $this->getVaultPaymentToken($response); // add vault payment token entity to extension attributes
$paymentToken = $this->getVaultPaymentToken($response);
if (null !== $paymentToken) { if (null !== $paymentToken) {
$extensionAttributes = $this->getExtensionAttributes($payment); $extensionAttributes = $this->getExtensionAttributes($payment);
$extensionAttributes->setVaultPaymentToken($paymentToken); $extensionAttributes->setVaultPaymentToken($paymentToken);
}
} }
} }
...@@ -88,7 +98,7 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -88,7 +98,7 @@ class VaultDetailsHandler implements HandlerInterface
if (empty($additionalData['recurring.recurringDetailReference'])) { if (empty($additionalData['recurring.recurringDetailReference'])) {
$this->_adyenLogger->error( $this->adyenLogger->error(
'Missing Token in Result please enable in ' . 'Missing Token in Result please enable in ' .
'Settings -> API URLs and Response menu in the Adyen Customer Area Recurring details setting' 'Settings -> API URLs and Response menu in the Adyen Customer Area Recurring details setting'
); );
...@@ -98,7 +108,7 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -98,7 +108,7 @@ class VaultDetailsHandler implements HandlerInterface
if (empty($additionalData['cardSummary'])) { if (empty($additionalData['cardSummary'])) {
$this->_adyenLogger->error( $this->adyenLogger->error(
'Missing cardSummary in Result please login to the adyen portal ' . 'Missing cardSummary in Result please login to the adyen portal ' .
'and go to Settings -> API URLs and Response and enable the Card summary property' 'and go to Settings -> API URLs and Response and enable the Card summary property'
); );
...@@ -107,7 +117,7 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -107,7 +117,7 @@ class VaultDetailsHandler implements HandlerInterface
$cardSummary = $additionalData['cardSummary']; $cardSummary = $additionalData['cardSummary'];
if (empty($additionalData['expiryDate'])) { if (empty($additionalData['expiryDate'])) {
$this->_adyenLogger->error( $this->adyenLogger->error(
'Missing expiryDate in Result please login to the adyen portal and go to ' . 'Missing expiryDate in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Expiry date property' 'Settings -> API URLs and Response and enable the Expiry date property'
); );
...@@ -116,7 +126,7 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -116,7 +126,7 @@ class VaultDetailsHandler implements HandlerInterface
$expirationDate = $additionalData['expiryDate']; $expirationDate = $additionalData['expiryDate'];
if (empty($additionalData['paymentMethod'])) { if (empty($additionalData['paymentMethod'])) {
$this->_adyenLogger->error( $this->adyenLogger->error(
'Missing paymentMethod in Result please login to the adyen portal and go to ' . 'Missing paymentMethod in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Variant property' 'Settings -> API URLs and Response and enable the Variant property'
); );
...@@ -141,7 +151,7 @@ class VaultDetailsHandler implements HandlerInterface ...@@ -141,7 +151,7 @@ class VaultDetailsHandler implements HandlerInterface
$paymentToken->setTokenDetails(json_encode($details)); $paymentToken->setTokenDetails(json_encode($details));
} catch (\Exception $e) { } catch (\Exception $e) {
$this->_adyenLogger->error(print_r($e, true)); $this->adyenLogger->error(print_r($e, true));
} }
} }
......
...@@ -1595,7 +1595,6 @@ class Data extends AbstractHelper ...@@ -1595,7 +1595,6 @@ class Data extends AbstractHelper
// check if BA exists // check if BA exists
if (!($billingAgreement && $billingAgreement->getAgreementId() > 0 && $billingAgreement->isValid())) { if (!($billingAgreement && $billingAgreement->getAgreementId() > 0 && $billingAgreement->isValid())) {
// create new BA // create new BA
$this->adyenLogger->addAdyenDebug("Creating new Billing Agreement");
$billingAgreement = $this->billingAgreementFactory->create(); $billingAgreement = $this->billingAgreementFactory->create();
$billingAgreement->setStoreId($order->getStoreId()); $billingAgreement->setStoreId($order->getStoreId());
$billingAgreement->importOrderPayment($order->getPayment()); $billingAgreement->importOrderPayment($order->getPayment());
...@@ -1615,7 +1614,9 @@ class Data extends AbstractHelper ...@@ -1615,7 +1614,9 @@ class Data extends AbstractHelper
$storeOneClick = $order->getPayment()->getAdditionalInformation('store_cc'); $storeOneClick = $order->getPayment()->getAdditionalInformation('store_cc');
$billingAgreement->setCcBillingAgreement($additionalData, $storeOneClick, $order->getStoreId()); $billingAgreement->setCcBillingAgreement($additionalData, $storeOneClick, $order->getStoreId());
if ($billingAgreement->isValid()) { $billingAgreementErrors = $billingAgreement->getErrors();
if ($billingAgreement->isValid() && empty($billingAgreementErrors)) {
if (!$this->agreementResourceModel->getOrderRelation($billingAgreement->getAgreementId(), if (!$this->agreementResourceModel->getOrderRelation($billingAgreement->getAgreementId(),
$order->getId())) { $order->getId())) {
...@@ -1627,7 +1628,7 @@ class Data extends AbstractHelper ...@@ -1627,7 +1628,7 @@ class Data extends AbstractHelper
$order->addRelatedObject($billingAgreement); $order->addRelatedObject($billingAgreement);
} else { } else {
$message = __('Failed to create billing agreement for this order. Reason(s): ') . join(', ', $message = __('Failed to create billing agreement for this order. Reason(s): ') . join(', ',
$billingAgreement->getErrors()); $billingAgreementErrors);
throw new \Exception($message); throw new \Exception($message);
} }
...@@ -1799,7 +1800,7 @@ class Data extends AbstractHelper ...@@ -1799,7 +1800,7 @@ class Data extends AbstractHelper
$localeCode = $this->config->getValue( $localeCode = $this->config->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE, \Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES, \Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode() $this->storeManager->getStore($storeId)->getCode()
); );
return $localeCode; return $localeCode;
......
...@@ -179,36 +179,41 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -179,36 +179,41 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
->setMethodCode('adyen_oneclick') ->setMethodCode('adyen_oneclick')
->setReferenceId($contractDetail['recurring.recurringDetailReference']); ->setReferenceId($contractDetail['recurring.recurringDetailReference']);
if (!isset($contractDetail['cardBin']) ||
!isset($contractDetail['cardHolderName']) ||
!isset($contractDetail['cardSummary']) ||
!isset($contractDetail['expiryDate']) ||
!isset($contractDetail['paymentMethod'])
) {
$this->_errors[] = __('"In the Additional data in API response section, select: 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 // Billing agreement is CC
if (isset($contractDetail['cardBin']) &&
isset($contractDetail['cardHolderName']) &&
isset($contractDetail['cardSummary']) &&
isset($contractDetail['expiryDate']) &&
isset($contractDetail['paymentMethod'])) {
$ccType = $contractDetail['paymentMethod'];
$ccTypes = $this->adyenHelper->getCcTypesAltData();
if (isset($ccTypes[$ccType])) { $ccType = $contractDetail['paymentMethod'];
$ccType = $ccTypes[$ccType]['name']; $ccTypes = $this->adyenHelper->getCcTypesAltData();
}
if ($contractDetail['cardHolderName']) { if (isset($ccTypes[$ccType])) {
$label = __( $ccType = $ccTypes[$ccType]['name'];
'%1, %2, **** %3', }
$ccType,
$contractDetail['cardHolderName'],
$contractDetail['cardSummary']
);
} else {
$label = __(
'%1, **** %2',
$ccType,
$contractDetail['cardSummary']
);
}
$this->setAgreementLabel($label); if ($contractDetail['cardHolderName']) {
$label = __(
'%1, %2, **** %3',
$ccType,
$contractDetail['cardHolderName'],
$contractDetail['cardSummary']
);
} else {
$label = __(
'%1, **** %2',
$ccType,
$contractDetail['cardSummary']
);
} }
$this->setAgreementLabel($label);
$expiryDate = explode('/', $contractDetail['expiryDate']); $expiryDate = explode('/', $contractDetail['expiryDate']);
if (!empty($contractDetail['pos_payment'])) { if (!empty($contractDetail['pos_payment'])) {
......
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