asorasoft/bill
Composer 安装命令:
composer require asorasoft/bill
包简介
The subscription plan billing for Laravel
README 文档
README
The subscription plan billing for Laravel
Installation
You can install the package via composer:
composer require asorasoft/bill
Register BillServiceProvider class in config/app.php
<?php 'providers' => [ Asorasoft\Bill\BillServiceProvider::class ]
You need to publish the configuration file, it will create bill.php file
php artisan vendor:publish --provider="Asorasoft\Bill\BillServiceProvider"
Copy bill key configuration to .env file
BILL_SECRET_KEY= BILL_API_URL= BILL_VERIFY_SSL=
Usage
Create or update customer
public function createOrUpdateCustomer() { Customer::updateOrCreate([ 'customer_id' => $customer_id, 'name' => 'Name', 'phone' => '019000000', 'email' => 'customer@gmail.com' ]); }
Get customer and plans
public function getCustomerAndPlans() { $get_customer_and_plans = Subscription::getCustomerAndPlans($customer_id); return json_encode($get_customer_and_plans); }
Subscribe a plan
public function subscribe() { Subscription::subscribe($customer_id, $plan_id); }
Change plan request
public function changePlanRequest() { $this->validate($request, [ 'from_plan_id' => 'required', 'to_plan_id' => 'required', 'price' => 'required', 'duration' => 'required', 'document' => 'required', ]); $response = ChangePlanRequest::create([ ['name' => 'customer_id', 'contents' => $customer_id], ['name' => 'from_plan_id', 'contents' => $request->from_plan_id], ['name' => 'to_plan_id', 'contents' => $request->to_plan_id], ['name' => 'duration', 'contents' => $request->duration], ['name' => 'price', 'contents' => $request->price], [ 'name' => 'document', 'contents' => fopen($request->document->path(), 'r'), 'filename' => $request->document->getClientOriginalName(), 'Mime-Type' => $request->document->getClientMimeType() ], ]); return json_encode($response); }
Renewal Plan Request
public function renewalPlanRequest() { $this->validate($request, [ 'price' => 'required', 'duration' => 'required', 'document' => 'required', ]); $response = RenewalPlanRequest::create([ ['name' => 'customer_id', 'contents' => $customer_id], ['name' => 'duration', 'contents' => $request->duration], ['name' => 'price', 'contents' => $request->price], [ 'name' => 'document', 'contents' => fopen($request->document->path(), 'r'), 'filename' => $request->document->getClientOriginalName(), 'Mime-Type' => $request->document->getClientMimeType() ], ]); return json_encode($response); }
Get invoices list
public function invoices() { $response = Invoice::list($customer_id); return json_encode($response); }
Downloading an invoice
public function download() { return Invoice::download($invoice_uuid); }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email mab@asorasoft.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-16