Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Latest commit

 

History

History
42 lines (32 loc) · 1.31 KB

checkout.md

File metadata and controls

42 lines (32 loc) · 1.31 KB
posttype title description icon github order
doc
Checkout
The checkout service.
/icons/checkout.svg
4

Generic Overview

The checkout service is no more than a helper class that manages and chains the various steps like updating addresses, creating the order, calculating shipping cost, taxes and discounts.

use Bazar\Modesl\Order;
use Bazar\Support\Facades\Cart;
use Illuminate\Support\Facades\Response;

class CheckoutController extends Controller
{
    public function process(Request $request)
    {
        Cart::updateItems($request->input('items'));
        Cart::updateBilling($request->input('billing'));
        Cart::updateShipping($request->input('shipping.address'), $request->input('shipping.diver'));

        $order = Cart::checkout($request->input('gateway-driver'));

        // Handle the freshly created order
    }
}

Events

The following events may be triggered when using the checkout service:

  • The Bazar\Events\CheckoutProcessing: before the checkout processed.
  • The Bazar\Events\CheckoutProcessed: after the checkout processed.
  • The Bazar\Events\CheckoutFailed: after the checkout failed.

When writing a custom gateway driver, make sure, you dispatch the CheckoutProcessed event manually.