feat(sale): implement confirm and cancel functionality for sales in AdminApp; update routes and tests
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Domains\Purchase\Services\Checkout\EditCheckoutService;
|
||||
use App\Domains\Purchase\Services\Checkout\ReleaseCheckoutService;
|
||||
use App\Domains\Purchase\Services\Checkout\StartCheckoutService;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Stable checkout API used by controllers, commands and integrations.
|
||||
@@ -64,11 +65,26 @@ class CheckoutService
|
||||
$this->completer->confirm($purchase);
|
||||
}
|
||||
|
||||
public function confirmPaidPurchase(Purchase $purchase): Purchase
|
||||
{
|
||||
return DB::transaction(function () use ($purchase): Purchase {
|
||||
$this->completer->confirm($purchase);
|
||||
$purchase->markAsPaid();
|
||||
|
||||
return $purchase->refresh()->load(['items.imageAttachment']);
|
||||
});
|
||||
}
|
||||
|
||||
public function cancelPurchase(Purchase $purchase): Purchase
|
||||
{
|
||||
return $this->releaser->cancel($purchase);
|
||||
}
|
||||
|
||||
public function cancelPurchaseWithoutRestoringCart(Purchase $purchase): Purchase
|
||||
{
|
||||
return $this->releaser->cancelWithoutRestoringCart($purchase);
|
||||
}
|
||||
|
||||
public function expirePurchase(Purchase $purchase): Purchase
|
||||
{
|
||||
return $this->releaser->expire($purchase);
|
||||
|
||||
Reference in New Issue
Block a user