Fixes for cart and payment/paypal processing
This commit is contained in:
@@ -42,27 +42,53 @@ class CheckoutController extends Controller
|
||||
->with('success','Checkout saved');
|
||||
}
|
||||
|
||||
public function cart_invoice(Request $request,Invoice $o=NULL)
|
||||
/**
|
||||
* Add an invoice to the cart
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Invoice $o
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Foundation\Application
|
||||
* @note The route validates that the user can see the invoice
|
||||
*/
|
||||
public function cart_invoice(Request $request,Invoice $o)
|
||||
{
|
||||
if ($o) {
|
||||
$request->session()->put('invoice.cart.'.$o->id,$o->id);
|
||||
$request->session()->put('invoice.cart.'.$o->id,$o->id);
|
||||
|
||||
return view('theme.backend.adminlte.checkout.cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cart
|
||||
*
|
||||
* @param Request $request
|
||||
* @return string
|
||||
*/
|
||||
public function cart_remove(Request $request): string
|
||||
{
|
||||
if ($id=$request->post('id')) {
|
||||
$cart = $request->session()->pull('invoice.cart');
|
||||
unset($cart[$id]);
|
||||
|
||||
$request->session()->put('invoice.cart',$cart);
|
||||
}
|
||||
|
||||
if (! $request->session()->get('invoice.cart'))
|
||||
return redirect()
|
||||
->to('u/home');
|
||||
|
||||
return view('theme.backend.adminlte.u.invoice.cart')
|
||||
->with('invoices',Invoice::find(array_values($request->session()->get('invoice.cart'))));
|
||||
return '';
|
||||
}
|
||||
|
||||
public function fee(Request $request,Checkout $o): float
|
||||
public function fee(Request $request): float
|
||||
{
|
||||
return $o->fee($request->post('total',0));
|
||||
if ((! $request->post('checkout_id') || (! $request->post('total'))))
|
||||
return 0;
|
||||
|
||||
$co = Checkout::findOrFail($request->post('checkout_id'));
|
||||
|
||||
return $co->fee($request->post('total'));
|
||||
}
|
||||
|
||||
public function pay(Request $request,Checkout $o)
|
||||
public function pay()
|
||||
{
|
||||
return redirect('pay/paypal/authorise');
|
||||
// @todo Currently sending all payments to paypal
|
||||
return redirect()
|
||||
->action([PaypalController::class,'authorise']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user