定制 bozboz/checkout 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bozboz/checkout

最新稳定版本:v2.0.0

Composer 安装命令:

composer require bozboz/checkout

包简介

README 文档

README

Define a series of interconnecting screens that plug together as part of a continuous process.

For examples of implementation look at these repos:

  1. http://gitlab.lab/bozboz/finecut
  2. http://gitlab.lab/bozboz/drusillas
  3. http://gitlab.lab/bozboz/benton

Setup

  1. Require the package in Composer, by running composer require bozboz/checkout
  2. Add the service provider in app/config/app.php
    Bozboz\Ecommerce\Checkout\Providers\CheckoutServiceProvider::class,
  1. Add the Checkout facade to the aliases array in in app/config/app.php
    'Checkout' => Bozboz\Ecommerce\Checkout\Facades\Checkout::class,

Usage

  1. Register a new checkout process using the Checkout facade in app/Http/routes.php
  2. Set a repository on the facade with the using method. The repository must implement the Bozboz\Ecommerce\Checkout\CheckoutableRepository interface and its purpose is to fetch the checkoutable instance. The instance must implement the Checkoutable interface. (The orders package has a default implementation to fetch the order instance from the session, Bozboz\Ecommerce\Orders\OrderRepository).
  3. On the returned object, call add to add screens. The add method takes 4 parameters:
    1. The URL the screen will respond to
    2. The Screen class to use (resolved out the IoC container)
    3. An optional additional label to identify the screen, primarily used in the progress bar
    4. Route parameters (uses, as, before, etc.)

e.g.:

<?php
Checkout::using('App\Ecommerce\Orders\OrderRepository')->register(['prefix' => 'checkout'], function($checkout)
{
    $checkout->add('/', 'App\Screens\Start', 'Start');
    $checkout->add('customer', 'App\Screens\CustomerDetails', 'Personal Info');
    $checkout->add('address', 'App\Screens\AddressSelection', 'Addresses');
    $checkout->add('delivery', 'App\Screens\ShippingSelection', 'Delivery');
    $checkout->add('billing', 'App\Screens\IframeBilling', 'Payment');
    $checkout->add('complete', 'App\Screens\OrderCompleted', 'Complete');
});

The above example will register the following URLs:

GET  /checkout
POST /checkout
GET  /checkout/customer
POST /checkout/customer
GET  /checkout/address
POST /checkout/address
GET  /checkout/delivery
POST /checkout/delivery
GET  /checkout/billing
POST /checkout/billing
GET  /checkout/complete
POST /checkout/complete

Screens

Screens must extend Bozboz\Ecommerce\Checkout\Screen and must define a view() method.

Additionally, a canSkip method is supported, which must return a boolean. If this method returns true, the screen will be skipped in the process.

Processing the screen

To define a processing action (hit when the screen URL is POSTed to) the screen class must implement Bozboz\Ecommerce\Checkout\Processable. This interface requires a process() method be defined.

Providing this method does not throw an instance of Bozboz\Ecommerce\Checkout\ValidationException, the checkout process will progress to the next screen upon completion.

Troubleshooting

When using test payments, if you get a 500 Internal Server Error upon clicking 'Take my money', try excluding the checkout/billing route from csrf protection.
In App\Http\Middleware\VerifyCsrfToken, add

    protected $except = [
        'checkout/billing',
    ];

统计信息

  • 总下载量: 2.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2021-06-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固