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

[PW-1737] Add idempotency key (#531)

* [PW-1737] Add idempotency key

* Add constraint to only work with php library version 4.1 and higher (4.1 we will release today)
parent 6ae985c7
......@@ -69,12 +69,14 @@ class TransactionAuthorization implements ClientInterface
public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject)
{
$request = $transferObject->getBody();
$requestOptions['idempotencyKey'] = $request['reference'];
// call lib
$service = new \Adyen\Service\Payment($this->_client);
try {
$response = $service->authorise($request);
$response = $service->authorise($request, $requestOptions);
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
......
......@@ -65,9 +65,10 @@ class TransactionPayment implements ClientInterface
$client = $this->adyenHelper->initializeAdyenClient();
$service = new \Adyen\Service\Checkout($client);
$requestOptions['idempotencyKey'] = $request['reference'];
try {
$response = $service->payments($request);
$response = $service->payments($request, $requestOptions);
} catch (\Adyen\AdyenException $e) {
$response['error'] = $e->getMessage();
}
......
......@@ -97,6 +97,8 @@ class AdyenThreeDS2Process implements AdyenThreeDS2ProcessInterface
try {
$client = $this->adyenHelper->initializeAdyenClient($quote->getStoreId());
$service = $this->adyenHelper->createAdyenCheckoutService($client);
$requestOptions['idempotencyKey'] = $quote->reserveOrderId()->getReservedOrderId();
$result = $service->paymentsDetails($request);
} catch (\Adyen\AdyenException $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure 2.0 failed'));
......
......@@ -118,7 +118,8 @@ class PaymentRequest extends DataObject
try {
$client = $this->_adyenHelper->initializeAdyenClient($storeId);
$service = $this->_adyenHelper->createAdyenCheckoutService($client);
$result = $service->paymentsDetails($request);
$requestOptions['idempotencyKey'] = $order->getIncrementId();
$result = $service->paymentsDetails($request, $requestOptions);
} catch (\Adyen\AdyenException $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure failed'));
}
......
......@@ -14,7 +14,7 @@
}
],
"require": {
"adyen/php-api-library": "~2.1",
"adyen/php-api-library": "~4.1",
"magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*"
},
......
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