2026-09-02 16:14:52 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Modules\Core\Payment\Contracts;
|
|
|
|
|
|
2026-09-03 17:00:24 +03:00
|
|
|
use Lunar\DataTypes\Price;
|
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
|
|
|
* Reverses settled funds — independent of SupportsCaptures/SupportsVoids:
|
|
|
|
|
* a driver that only ever settles via SupportsPay::pay() (no separate
|
|
|
|
|
* authorize step) can still implement this, since a refund targets money
|
|
|
|
|
* already taken regardless of how it got taken. A driver implements this
|
|
|
|
|
* whenever its gateway exposes any refund capability at all, whether or
|
|
|
|
|
* not it also supports authorize-then-capture.
|
|
|
|
|
*
|
|
|
|
|
* Dispatches Modules\Core\Payment\Events\PaymentRefunded or
|
|
|
|
|
* PaymentRefundFailed.
|
2026-09-02 16:14:52 +03:00
|
|
|
*/
|
|
|
|
|
interface SupportsRefunds
|
|
|
|
|
{
|
|
|
|
|
/**
|
2026-09-03 16:01:33 +03:00
|
|
|
* $reference is the identifier the original SupportsPay::pay() or
|
|
|
|
|
* SupportsCaptures::capture() call returned for the settled funds
|
|
|
|
|
* being refunded.
|
|
|
|
|
*
|
2026-09-03 17:00:24 +03:00
|
|
|
* $amount is Lunar's own Price (never a gateway's own minor-unit
|
|
|
|
|
* scale — see PaymentResult's docblock), allowing a partial refund; a
|
|
|
|
|
* gateway may allow multiple partial refunds against one settlement,
|
|
|
|
|
* up to its own total. Required explicitly, same reasoning as
|
|
|
|
|
* SupportsCaptures::capture()'s own $amount.
|
2026-09-03 16:01:33 +03:00
|
|
|
*
|
|
|
|
|
* @param array<string, mixed> $context
|
2026-09-02 16:14:52 +03:00
|
|
|
*/
|
2026-09-03 17:00:24 +03:00
|
|
|
public function refund(string $reference, Price $amount, array $context = []): PaymentResult;
|
2026-09-02 16:14:52 +03:00
|
|
|
}
|