Fix: Updates to OrderFullfilmentServices and box now clients, order views and checkout services
This commit is contained in:
@@ -8,6 +8,7 @@ use Modules\Core\Payment\Contracts\Configurable;
|
||||
use Modules\Core\Payment\Contracts\SupportsPay;
|
||||
use Modules\Core\Payment\DTOs\PaymentResult;
|
||||
use Modules\Core\Payment\Enums\PaymentResultStatus;
|
||||
use Modules\Core\Payment\Events\PaymentDeferred;
|
||||
|
||||
/**
|
||||
* Cash-on-delivery/cash-on-pickup — the shopper pays staff in person, at
|
||||
@@ -31,6 +32,17 @@ use Modules\Core\Payment\Enums\PaymentResultStatus;
|
||||
* marking it received (Modules\Core\Order\Services\
|
||||
* OrderFulfillmentService::markPaid()), offered by the single "Update
|
||||
* Status" action at any time, independent of status.
|
||||
*
|
||||
* Despite returning Pending, this order IS fully placed the moment pay()
|
||||
* returns — unlike a Stripe 3-D Secure Pending, nothing will ever resolve
|
||||
* this into a later PaymentCaptured/PaymentAuthorized (COD has no gateway
|
||||
* callback at all). Without PaymentDeferred, no listener ever set
|
||||
* Order::placed_at for a COD order: invisible in customer order history,
|
||||
* no stock decrement (Modules\Core\Order\Listeners\
|
||||
* DecrementStockOnOrderPlaced only reacts to Checkout\Events\OrderPlaced),
|
||||
* and the storefront's own post-checkout confirmation could never find it
|
||||
* — a real bug, not a hypothetical, caught and fixed after the fact. See
|
||||
* PaymentDeferred's own docblock for the full reasoning.
|
||||
*/
|
||||
class CashOnDeliveryPaymentDriver implements Configurable, SupportsPay
|
||||
{
|
||||
@@ -41,10 +53,14 @@ class CashOnDeliveryPaymentDriver implements Configurable, SupportsPay
|
||||
|
||||
public function pay(string $type, Price $amount, array $data = [], array $context = []): PaymentResult
|
||||
{
|
||||
return new PaymentResult(
|
||||
$result = new PaymentResult(
|
||||
status: PaymentResultStatus::Pending,
|
||||
reference: 'cod-'.Str::uuid(),
|
||||
amount: $amount,
|
||||
);
|
||||
|
||||
PaymentDeferred::dispatch($type, $result, $context);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user