We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday 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
{
$result = false;
$this->_adyenLogger->addAdyenResult('Updating the order');
if (!empty($response['authResult'])) {
$authResult = $response['authResult'];
} elseif (!empty($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']) : '';
$pspReference = isset($response['pspReference']) ? trim($response['pspReference']) : '';
......
......@@ -38,19 +38,27 @@ class VaultDetailsHandler implements HandlerInterface
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $_adyenLogger;
private $adyenLogger;
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* VaultDetailsHandler constructor.
*
* @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(
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;
}
......@@ -61,15 +69,17 @@ class VaultDetailsHandler implements HandlerInterface
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
/** @var OrderPaymentInterface $payment */
/** @var \Adyen\Payment\Api\Data\OrderPaymentInterface $payment */
$payment = $payment->getPayment();
// add vault payment token entity to extension attributes
$paymentToken = $this->getVaultPaymentToken($response);
if ($this->adyenHelper->isCreditCardVaultEnabled($payment->getOrder()->getStoreId())) {
// add vault payment token entity to extension attributes
$paymentToken = $this->getVaultPaymentToken($response);
if (null !== $paymentToken) {
$extensionAttributes = $this->getExtensionAttributes($payment);
$extensionAttributes->setVaultPaymentToken($paymentToken);
if (null !== $paymentToken) {
$extensionAttributes = $this->getExtensionAttributes($payment);
$extensionAttributes->setVaultPaymentToken($paymentToken);
}
}
}
......@@ -88,7 +98,7 @@ class VaultDetailsHandler implements HandlerInterface
if (empty($additionalData['recurring.recurringDetailReference'])) {
$this->_adyenLogger->error(
$this->adyenLogger->error(
'Missing Token in Result please enable in ' .
'Settings -> API URLs and Response menu in the Adyen Customer Area Recurring details setting'
);
......@@ -98,7 +108,7 @@ class VaultDetailsHandler implements HandlerInterface
if (empty($additionalData['cardSummary'])) {
$this->_adyenLogger->error(
$this->adyenLogger->error(
'Missing cardSummary in Result please login to the adyen portal ' .
'and go to Settings -> API URLs and Response and enable the Card summary property'
);
......@@ -107,7 +117,7 @@ class VaultDetailsHandler implements HandlerInterface
$cardSummary = $additionalData['cardSummary'];
if (empty($additionalData['expiryDate'])) {
$this->_adyenLogger->error(
$this->adyenLogger->error(
'Missing expiryDate in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Expiry date property'
);
......@@ -116,7 +126,7 @@ class VaultDetailsHandler implements HandlerInterface
$expirationDate = $additionalData['expiryDate'];
if (empty($additionalData['paymentMethod'])) {
$this->_adyenLogger->error(
$this->adyenLogger->error(
'Missing paymentMethod in Result please login to the adyen portal and go to ' .
'Settings -> API URLs and Response and enable the Variant property'
);
......@@ -141,7 +151,7 @@ class VaultDetailsHandler implements HandlerInterface
$paymentToken->setTokenDetails(json_encode($details));
} 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
// check if BA exists
if (!($billingAgreement && $billingAgreement->getAgreementId() > 0 && $billingAgreement->isValid())) {
// create new BA
$this->adyenLogger->addAdyenDebug("Creating new Billing Agreement");
$billingAgreement = $this->billingAgreementFactory->create();
$billingAgreement->setStoreId($order->getStoreId());
$billingAgreement->importOrderPayment($order->getPayment());
......@@ -1615,7 +1614,9 @@ class Data extends AbstractHelper
$storeOneClick = $order->getPayment()->getAdditionalInformation('store_cc');
$billingAgreement->setCcBillingAgreement($additionalData, $storeOneClick, $order->getStoreId());
if ($billingAgreement->isValid()) {
$billingAgreementErrors = $billingAgreement->getErrors();
if ($billingAgreement->isValid() && empty($billingAgreementErrors)) {
if (!$this->agreementResourceModel->getOrderRelation($billingAgreement->getAgreementId(),
$order->getId())) {
......@@ -1627,7 +1628,7 @@ class Data extends AbstractHelper
$order->addRelatedObject($billingAgreement);
} else {
$message = __('Failed to create billing agreement for this order. Reason(s): ') . join(', ',
$billingAgreement->getErrors());
$billingAgreementErrors);
throw new \Exception($message);
}
......@@ -1799,7 +1800,7 @@ class Data extends AbstractHelper
$localeCode = $this->config->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
$this->storeManager->getStore($storeId)->getCode()
);
return $localeCode;
......
......@@ -179,36 +179,41 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
->setMethodCode('adyen_oneclick')
->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
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 = $ccTypes[$ccType]['name'];
}
$ccType = $contractDetail['paymentMethod'];
$ccTypes = $this->adyenHelper->getCcTypesAltData();
if ($contractDetail['cardHolderName']) {
$label = __(
'%1, %2, **** %3',
$ccType,
$contractDetail['cardHolderName'],
$contractDetail['cardSummary']
);
} else {
$label = __(
'%1, **** %2',
$ccType,
$contractDetail['cardSummary']
);
}
if (isset($ccTypes[$ccType])) {
$ccType = $ccTypes[$ccType]['name'];
}
$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']);
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