FleetCart/Modules/Checkout/Http/Controllers/PaymentCanceledController.php
2023-06-11 13:14:03 +01:00

40 lines
1.0 KiB
PHP

<?php
namespace Modules\Checkout\Http\Controllers;
use Illuminate\Http\Request;
use Modules\Cart\Facades\Cart;
use Modules\Order\Entities\Order;
class PaymentCanceledController
{
/**
* Store a newly created resource in storage.
*
* @param int $orderId
* @param string $paymentMethod
* @param \Modules\Checkout\Services\OrderService $orderService
* @return \Illuminate\Http\Response
*/
public function store(Request $request, $orderId)
{
Order::where('id', $orderId)->forceDelete();
Cart::restoreStock();
if ($request->ajax()) {
return response()->json(
[
'success' => true,
'message' => trans('payment::messages.payment_cancelled'),
],
200,
);
}
return redirect()
->route('checkout.create')
->with('error', trans('payment::messages.payment_cancelled'));
}
}