From ee27162144f73bfeafeafa205c961a2c568d1085 Mon Sep 17 00:00:00 2001 From: Michael Dekker Date: Mon, 1 Dec 2025 03:45:44 +0100 Subject: [PATCH 1/2] Add `capture` property to OrderRequest --- src/Api/Transactions/OrderRequest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Api/Transactions/OrderRequest.php b/src/Api/Transactions/OrderRequest.php index aaffe53..a801daa 100644 --- a/src/Api/Transactions/OrderRequest.php +++ b/src/Api/Transactions/OrderRequest.php @@ -166,6 +166,11 @@ class OrderRequest extends RequestBody implements OrderRequestInterface */ private $currency; + /** + * @var string + */ + private $capture; + /** * @var ?OrderRequest\Arguments\Affiliate */ @@ -588,6 +593,16 @@ public function addAffiliate(?OrderRequest\Arguments\Affiliate $affiliate): Orde return $this; } + /** + * @param string $capture + * @return OrderRequest + */ + public function addCapture(string $capture = 'manual'): OrderRequest + { + $this->capture = $capture; + return $this; + } + /** * @return Affiliate|null */ @@ -627,6 +642,7 @@ public function getData(): array 'var1' => $this->getVar1(), 'var2' => $this->getVar2(), 'var3' => $this->getVar3(), + 'capture' => $this->capture ?? null, 'affiliate' => $this->affiliate ? $this->affiliate->getData() : null, ]; From dae2d828a8cf86c06550d65cf03648736e5f04af Mon Sep 17 00:00:00 2001 From: Michael Dekker Date: Mon, 1 Dec 2025 04:00:08 +0100 Subject: [PATCH 2/2] Add unit tests for the `capture` property of an OrderRequest --- .../Api/Transactions/OrderRequestTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/Unit/Api/Transactions/OrderRequestTest.php b/tests/Unit/Api/Transactions/OrderRequestTest.php index f472176..ba7415c 100644 --- a/tests/Unit/Api/Transactions/OrderRequestTest.php +++ b/tests/Unit/Api/Transactions/OrderRequestTest.php @@ -229,4 +229,59 @@ public function testOrderWithAffiliate() $this->assertArrayHasKey('affiliate', $data); $this->assertArrayHasKey('split_payments', $data['affiliate']); } + + /** + * Test if we can get the manual capture flag, with an expliticly set correct value + * @throws InvalidArgumentException + * @throws InvalidTotalAmountException + */ + public function testOrderWithManualCapture() + { + $orderRequest = $this->createOrderIdealDirectRequestFixture(); + $orderRequest->addCapture('manual'); + $data = $orderRequest->getData(); + + $this->assertEquals('manual', $data['capture'] ?? ''); + } + + /** + * Test if we can get the manual capture flag, with an explicitly set value + * @throws InvalidArgumentException + * @throws InvalidTotalAmountException + */ + public function testOrderWithFreestyleManualCapture() + { + $orderRequest = $this->createOrderIdealDirectRequestFixture(); + $orderRequest->addCapture('example'); + $data = $orderRequest->getData(); + + $this->assertEquals('example', $data['capture'] ?? ''); + } + + /** + * Test if we can set the manual capture flag by using the default + * @throws InvalidArgumentException + * @throws InvalidTotalAmountException + */ + public function testOrderWithDefaultManualCapture() + { + $orderRequest = $this->createOrderIdealDirectRequestFixture(); + $orderRequest->addCapture(); + $data = $orderRequest->getData(); + + $this->assertEquals('manual', $data['capture'] ?? ''); + } + + /** + * Test if the capture flag is truly missing when the order is created without setting it + * @throws InvalidArgumentException + * @throws InvalidTotalAmountException + */ + public function testOrderWithoutManualCapture() + { + $orderRequest = $this->createOrderIdealDirectRequestFixture(); + $data = $orderRequest->getData(); + + $this->assertArrayNotHasKey('capture', $data); + } }