asorasoft / bill
The subscription plan billing for Laravel
1.0.2
2021-12-15 15:31 UTC
Requires
- php: ^7.1
- ext-json: *
- guzzlehttp/guzzle: ^5.3 || ^6.5 || ^7.3
- illuminate/support: ^5.0 || ^6.0 || ^7.0 || ^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-15 21:44:13 UTC
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.