Skip to content

Commit 93093be

Browse files
Merge pull request #57 from shiuh-yaw-cko/master
Update idempotency for PaymentController capture, void, refund
2 parents 837f962 + 865b552 commit 93093be

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "checkout/checkout-sdk-php",
33
"description": "Checkout.com SDK for PHP",
44
"homepage": "https://github.com/checkout/checkout-sdk-php",
5-
"version": "1.0.10",
5+
"version": "1.0.11",
66
"type": "library",
77
"license": "MIT",
88
"keywords": ["checkout.com","payment","gateway","checkout","checkoutcom","GW3","CKO", "Reboot", "SDK", "Library", "PHP", "API"],

src/CheckoutApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class CheckoutApi
4747
*
4848
* @var string
4949
*/
50-
const VERSION = '1.0.10';
50+
const VERSION = '1.0.11';
5151

5252
/**
5353
* Channel section.

src/Controllers/PaymentController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class PaymentController extends Controller
8282
public function refund(Refund $refund, $mode = HttpHandler::MODE_EXECUTE)
8383
{
8484
$response = $this->requestAPI($refund->getEndpoint())
85-
->setBody($refund->getValues());
85+
->setBody($refund->getValues())
86+
->setIdempotencyKey($payment->getIdempotencyKey());
8687

8788
return $this->response($response, Refund::QUALIFIED_NAME, $mode, $refund->id);
8889
}
@@ -127,7 +128,8 @@ public function actions($id, $mode = HttpHandler::MODE_EXECUTE)
127128
public function void(Voids $void, $mode = HttpHandler::MODE_EXECUTE)
128129
{
129130
$response = $this->requestAPI($void->getEndpoint())
130-
->setBody($void->getValues());
131+
->setBody($void->getValues())
132+
->setIdempotencyKey($payment->getIdempotencyKey());
131133

132134
return $this->response($response, Voids::QUALIFIED_NAME, $mode, $void->id);
133135
}
@@ -142,7 +144,8 @@ public function void(Voids $void, $mode = HttpHandler::MODE_EXECUTE)
142144
public function capture(Capture $capture, $mode = HttpHandler::MODE_EXECUTE)
143145
{
144146
$response = $this->requestAPI($capture->getEndpoint())
145-
->setBody($capture->getValues());
147+
->setBody($capture->getValues())
148+
->setIdempotencyKey($payment->getIdempotencyKey());
146149

147150
return $this->response($response, Capture::QUALIFIED_NAME, $mode, $capture->id);
148151
}

src/Library/HttpHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ protected function setUpCurl($curl)
345345
}
346346

347347
// Set Body
348-
if ($this->method === static::METHOD_POST || $this->method === static::METHOD_PUT || $this->method === static::METHOD_PATCH) {
348+
if (in_array($this->method, array(static::METHOD_POST, static::METHOD_PUT, static::METHOD_PATCH))) {
349349
curl_setopt($curl, CURLOPT_POSTFIELDS, $this->body);
350350
}
351351
}

0 commit comments

Comments
 (0)