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