Commit b8fc725c authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Improved logging to track payment and order flow at cc payments (#557)

parent 566c2b82
......@@ -27,6 +27,24 @@ use Magento\Payment\Gateway\Request\BuilderInterface;
class CcAuthorizationDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* CcAuthorizationDataBuilder constructor.
*
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
public function __construct(
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
)
{
$this->adyenLogger = $adyenLogger;
}
/**
* @param array $buildSubject
* @return array|mixed
......@@ -50,6 +68,8 @@ class CcAuthorizationDataBuilder implements BuilderInterface
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
}
$this->adyenLogger->addAdyenDebug("Place order started for order: " . $request['merchantReference']);
return $request;
}
}
......@@ -67,6 +67,11 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
*/
private $threeDS2ResponseValidator;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* AdyenPaymentProcess constructor.
*
......@@ -87,7 +92,8 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
\Adyen\Payment\Gateway\Http\TransferFactory $transferFactory,
\Adyen\Payment\Gateway\Http\Client\TransactionPayment $transactionPayment,
\Adyen\Payment\Gateway\Validator\CheckoutResponseValidator $checkoutResponseValidator,
\Adyen\Payment\Gateway\Validator\ThreeDS2ResponseValidator $threeDS2ResponseValidator
\Adyen\Payment\Gateway\Validator\ThreeDS2ResponseValidator $threeDS2ResponseValidator,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
)
{
$this->context = $context;
......@@ -98,6 +104,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
$this->transactionPayment = $transactionPayment;
$this->checkoutResponseValidator = $checkoutResponseValidator;
$this->threeDS2ResponseValidator = $threeDS2ResponseValidator;
$this->adyenLogger = $adyenLogger;
}
/**
......@@ -148,6 +155,9 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Setting the orderid to null, so that we generate a new one for each /payments call
$quote->setReservedOrderId(null);
$reference = $quote->reserveOrderId()->getReservedOrderId();
$this->adyenLogger->addAdyenDebug("CC payment started for order: " . $reference);
$requestBody = $this->adyenRequestHelper->buildPaymentData($requestBody, $amount, $currencyCode, $reference, $paymentMethod);
// Browser data builder
......@@ -204,6 +214,11 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// To actually save the additional info changes into the quote
$quote->save();
$this->adyenLogger->addAdyenDebug("CC payment finished for order: " . $quote->getReservedOrderId());
if (!empty($paymentsResponse['resultCode'])) {
$this->adyenLogger->addAdyenDebug('Result code: ' . $paymentsResponse['resultCode']);
}
// Original flow can continue, return to frontend and place the order
return $this->adyenHelper->buildThreeDS2ProcessResponseJson();
}
......
......@@ -37,6 +37,11 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
*/
private $adyenHelper;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
private $adyenLogger;
/**
* AdyenThreeDS2Process constructor.
*
......@@ -45,11 +50,13 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
*/
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Adyen\Payment\Helper\Data $adyenHelper
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
)
{
$this->checkoutSession = $checkoutSession;
$this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger;
}
/**
......@@ -123,6 +130,11 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
// To actually save the additional info changes into the quote
$quote->save();
$this->adyenLogger->addAdyenDebug("CC payment finished for order: " . $quote->getReservedOrderId());
if (!empty($result['resultCode'])) {
$this->adyenLogger->addAdyenDebug('Result code: ' . $result['resultCode']);
}
// 3DS2 flow is done, original place order flow can continue from frontend
return $this->adyenHelper->buildThreeDS2ProcessResponseJson();
}
......
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