diff --git a/src/Adyen/Service/Checkout.php b/src/Adyen/Service/Checkout.php index cf98b4755..3889d7834 100644 --- a/src/Adyen/Service/Checkout.php +++ b/src/Adyen/Service/Checkout.php @@ -69,6 +69,11 @@ class Checkout extends \Adyen\ApiKeyAuthenticatedService */ protected $reversals; + /** + * @var ResourceModel\Checkout\Captures + */ + protected $captures; + /** * Checkout constructor. * @@ -91,6 +96,7 @@ public function __construct(\Adyen\Client $client) $this->sessions = new \Adyen\Service\ResourceModel\Checkout\Sessions($this); $this->refunds = new \Adyen\Service\ResourceModel\Checkout\Refunds($this); $this->reversals = new \Adyen\Service\ResourceModel\Checkout\Reversals($this); + $this->captures = new \Adyen\Service\ResourceModel\Checkout\Captures($this); } /** @@ -237,4 +243,15 @@ public function reversals($params, $requestOptions = null) { return $this->reversals->request($params, $requestOptions); } + + /** + * @param array $params + * @param array|null $requestOptions + * @return mixed + * @throws \Adyen\AdyenException + */ + public function captures($params, $requestOptions = null) + { + return $this->captures->request($params, $requestOptions); + } } diff --git a/src/Adyen/Service/ResourceModel/Checkout/Captures.php b/src/Adyen/Service/ResourceModel/Checkout/Captures.php new file mode 100644 index 000000000..652404919 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Checkout/Captures.php @@ -0,0 +1,31 @@ +endpoint = $this->getCheckoutEndpoint($service) . + '/' . $service->getClient()->getApiCheckoutVersion() . '/payments/{paymentPspReference}/captures'; + parent::__construct($service, $this->endpoint, $this->allowApplicationInfo); + } +} diff --git a/tests/Integration/CheckoutTest.php b/tests/Integration/CheckoutTest.php index 4b25d5a33..21c3fab13 100644 --- a/tests/Integration/CheckoutTest.php +++ b/tests/Integration/CheckoutTest.php @@ -358,4 +358,28 @@ public function testReversals() $this->assertEquals('received', $result['status']); } + + public function testCaptures() + { + $this->testPaymentsSuccess(); + + // create Checkout client + $client = $this->createCheckoutAPIClient(); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array( + 'paymentPspReference' => $this->pspReference, + 'merchantAccount' => $this->merchantAccount, + 'amount' => [ + 'currency' => "EUR", + 'value' => 1000 + ] + ); + + $result = $service->captures($params); + + $this->assertEquals('received', $result['status']); + } }