Files
core/src/Payment/DataTransferObjects/PaymentInitiation.php
T

32 lines
1.2 KiB
PHP

<?php
namespace Modules\Core\Payment\DataTransferObjects;
use Modules\Core\Payment\Enums\PaymentInitiationMode;
/**
* Returned by InitiatesPayment::initiate() — the one thing a caller needs
* synchronously, in the same request, regardless of which provider is
* behind it. redirectUrl/clientSecret are mutually exclusive in practice
* (only the one matching $mode is ever set) but both nullable rather than
* split into per-mode subclasses — see PaymentInitiationMode for why.
*
* $reference is the gateway's own identifier for this payment attempt
* (an order/session/intent id) — the same value HandlesPaymentCallback's
* driver will later see again in the callback payload, and what
* PaymentSucceeded/PaymentFailed carry forward. A driver in Immediate
* mode still returns one, even though there's no callback to correlate
* against, since it's also what gets recorded as the Transaction's
* reference.
*/
class PaymentInitiation
{
public function __construct(
public readonly PaymentInitiationMode $mode,
public readonly string $reference,
public readonly ?string $redirectUrl = null,
public readonly ?string $clientSecret = null,
public readonly array $meta = [],
) {}
}