Skip to content

Commit

Permalink
Merge pull request #1 from smartbnb/feature/add-support-for-checkout-…
Browse files Browse the repository at this point in the history
…capture

add support for checkout captures endpoint
  • Loading branch information
soarecostin authored Apr 5, 2022
2 parents 71e910d + a31311b commit 8fdd11d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Adyen/Service/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class Checkout extends \Adyen\ApiKeyAuthenticatedService
*/
protected $reversals;

/**
* @var ResourceModel\Checkout\Captures
*/
protected $captures;

/**
* Checkout constructor.
*
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
}
31 changes: 31 additions & 0 deletions src/Adyen/Service/ResourceModel/Checkout/Captures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Adyen\Service\ResourceModel\Checkout;

class Captures extends \Adyen\Service\AbstractCheckoutResource
{
/**
* @var string
*/
protected $endpoint;

/**
* Include applicationInfo key in the request parameters
*
* @var bool
*/
protected $allowApplicationInfo = false;

/**
* Payments constructor.
*
* @param \Adyen\Service $service
* @throws \Adyen\AdyenException
*/
public function __construct($service)
{
$this->endpoint = $this->getCheckoutEndpoint($service) .
'/' . $service->getClient()->getApiCheckoutVersion() . '/payments/{paymentPspReference}/captures';
parent::__construct($service, $this->endpoint, $this->allowApplicationInfo);
}
}
24 changes: 24 additions & 0 deletions tests/Integration/CheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

0 comments on commit 8fdd11d

Please sign in to comment.