2026-09-02 16:14:52 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Modules\Core\Payment\Contracts;
|
|
|
|
|
|
2026-09-03 16:01:33 +03:00
|
|
|
use Modules\Core\Payment\DTOs\PaymentResult;
|
2026-09-02 16:14:52 +03:00
|
|
|
|
|
|
|
|
/**
|
2026-09-03 16:01:33 +03:00
|
|
|
* Settles a PRIOR SupportsAuthorization::authorize() hold — only ever
|
|
|
|
|
* valid against a reference that call (or a HandlesPaymentCallback
|
|
|
|
|
* resolving it) produced, never called standalone. A driver with no
|
|
|
|
|
* authorize-then-settle model at all (most redirect/wallet gateways, any
|
|
|
|
|
* offline driver) never implements this — it settles everything through
|
|
|
|
|
* SupportsPay::pay() in one step instead.
|
|
|
|
|
*
|
|
|
|
|
* Dispatches Modules\Core\Payment\Events\PaymentCaptured or
|
|
|
|
|
* PaymentCaptureFailed — the same terminal events SupportsPay::pay()
|
|
|
|
|
* produces, since "money has been captured" is the same business fact
|
|
|
|
|
* regardless of which path reached it.
|
2026-09-02 16:14:52 +03:00
|
|
|
*/
|
|
|
|
|
interface SupportsCaptures
|
|
|
|
|
{
|
|
|
|
|
/**
|
2026-09-03 16:01:33 +03:00
|
|
|
* $reference is the identifier SupportsAuthorization::authorize()
|
|
|
|
|
* returned (PaymentResult::$reference) for the hold being settled.
|
|
|
|
|
*
|
|
|
|
|
* $amount lets a driver capture less than the full authorized amount
|
|
|
|
|
* (e.g. shipping less than ordered) — up to the driver/gateway
|
|
|
|
|
* whether a partial capture also releases the remainder or leaves it
|
|
|
|
|
* capturable again later (multicapture-style gateways).
|
|
|
|
|
*
|
|
|
|
|
* @param array<string, mixed> $context
|
2026-09-02 16:14:52 +03:00
|
|
|
*/
|
2026-09-03 16:01:33 +03:00
|
|
|
public function capture(string $reference, int $amount, array $context = []): PaymentResult;
|
|
|
|
|
}
|