Feat: Updates to Payments, Checkout Services, Payment Events

This commit is contained in:
2026-09-02 16:14:52 +03:00
parent 3497553b41
commit 8cb54e065e
18 changed files with 553 additions and 84 deletions
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace Modules\Core\Payment\Events;
use Illuminate\Foundation\Events\Dispatchable;
/**
* Dispatched by a PaymentDriver once it has independently decided (by
* whatever mechanism is native to its gateway) that a payment succeeded.
* Deliberately carries nothing but what a payment fundamentally is —
* $type, $reference, $amount — plus $context, an opaque bag the driver
* received from whoever called confirm() and hands back unchanged here.
*
* Payment has no concept of a cart, an order, or a checkout fingerprint —
* those are Checkout's concepts, and Checkout is only one possible
* consumer of a successful payment (a future Subscriptions module renewing
* on a recurring charge is another). $context is how a caller like
* CheckoutService::confirmPayment() smuggles what it needs to react
* (cart_id, fingerprint) through Payment without Payment ever reading or
* caring what's inside — each listener interprets $context on its own
* terms, or ignores the event entirely if the keys it needs aren't there.
*/
class PaymentSucceeded
{
use Dispatchable;
/**
* $amount is in the currency's minor unit, same convention as
* Lunar\Base\Casts\Price.
*
* @param array<string, mixed> $context
*/
public function __construct(
public readonly string $type,
public readonly string $reference,
public readonly int $amount,
public readonly array $context = [],
) {}
}