Feature: Abstraction on Payments based on their operations
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Payment\Events;
|
||||
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Modules\Core\Payment\DTOs\PaymentResult;
|
||||
|
||||
/**
|
||||
* Dispatched by a driver's SupportsAuthorization::authorize() (or, for an
|
||||
* async gateway, HandlesPaymentCallback::handleCallback() resolving that
|
||||
* same authorize() call later) once a hold has been placed — no funds have
|
||||
* moved yet, see SupportsCaptures/SupportsVoids for what happens next.
|
||||
*
|
||||
* Carries $result (the full PaymentResult, not just a reference) plus
|
||||
* $type and $context — same reasoning throughout Payment's events: Payment
|
||||
* has no concept of a cart, an order, or a checkout fingerprint, so
|
||||
* whatever a listener needs to react travels through $context untouched,
|
||||
* opaque to Payment itself.
|
||||
*/
|
||||
class PaymentAuthorized
|
||||
{
|
||||
use Dispatchable;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $context
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $type,
|
||||
public readonly PaymentResult $result,
|
||||
public readonly array $context = [],
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user