64robots/checkout

结账包。

2.0 2022-01-11 17:20 UTC

README

Build Status MIT License

结账

此包提供了购物车、结账、订单和优惠券的API端点和常用功能。您可以与自己的UI一起使用它,或者使用与该API无缝工作的Checkout Vue包。

安装

您可以通过composer安装此包。

composer require 64robots/checkout

安装完成后,此包将自动注册其服务提供者。

您可以使用以下命令发布包迁移:

php artisan vendor:publish --provider="R64\Checkout\CheckoutServiceProvider" --tag="migrations"

发布迁移后,您可以使用以下命令创建包表:

php artisan migrate

运行迁移后,将创建以下表格:

  • customers
  • products
  • cart
  • cart_items
  • orders
  • order_items
  • coupons
  • order_purchases

您还可以使用以下命令发布包配置:

php artisan vendor:publish --provider="R64\Checkout\CheckoutServiceProvider" --tag="config"

配置发布后,您可以在config/checkout.php中找到其内容。

return [

    /*
     * Required parameters when submitting an order to /api/orders endpoint
     */
    'required' => [
        'customer_email',
        'shipping_first_name',
        'shipping_last_name',
        'shipping_address_line1',
        // 'shipping_address_line2',
        'shipping_address_city',
        'shipping_address_region',
        'shipping_address_zipcode',
        'shipping_address_phone',
        'billing_first_name',
        'billing_last_name',
        'billing_address_line1',
         // 'billing_address_line2',
        'billing_address_city',
        'billing_address_region',
        'billing_address_zipcode',
        'billing_address_phone',
    ],

    /*
     * Terms and conditions url used usually in the checkout UI
     */
    'toc_url' => '#',

    /*
     * Currency code that will be saved with every order and symbol
     * that is usually used in the Cart, Checkout and Order UI
     */
    'currency' => [
        'code' => env('CHECKOUT_CURRENCY_CODE', 'USD'),
        'symbol' => env('CHECKOUT_CURRENCY_SYMBOL', '$')
    ],

    /*
     * Percentage of Cart total and fixed fee will be stored for every
     * order purchase (transaction)
     */
    'stripe' => [
        'percentage_fee' => env('CHECKOUT_STRIPE_PERCENTAGE_FEE', 29 / 1000),
        'fixed_fee' => env('CHECKOUT_STRIPE_FIXED_FEE', 30)
    ],

    /*
     * Shipping city and state is automatically resolved from zip code
     * using GeoNames service http://www.geonames.org/
     *
     * Country code constraints the search results
     * to specific country
     */
    'geo_names' => [
        'username' => env('CHECKOUT_GEO_NAMES_USERNAME', 'demo'),
        'country_code' => env('CHECKOUT_GEO_NAMES_COUNTRY_CODE', 'US')
    ],

    /*
     * Class names can be replaced and extended with your own logic
     */
    'product_model' => R64\Checkout\Models\Product::class,
    'customer_model' => R64\Checkout\Models\Customer::class,
    'cart_model' => R64\Checkout\Models\Cart::class,
    'cart_item_model' => R64\Checkout\Models\CartItem::class,
    'coupon_model' => R64\Checkout\Models\Coupon::class,
    'order_model' => R64\Checkout\Models\Order::class,
    'order_item_model' => R64\Checkout\Models\OrderItem::class,
    'product_resource' => R64\Checkout\Http\Resources\ProductResource::class,
    'payment' => R64\Checkout\StripePaymentHandler::class
];

Nova

您可以使用以下命令发布nova资源:

php artisan vendor:publish --provider="R64\Checkout\CheckoutServiceProvider" --tag="nova"

可用的API端点

安装包并运行迁移后,这些API端点将在您的应用程序中可用。

API文档

许可证

Checkout是开源软件,采用MIT许可证授权。