The subscription plan billing for Laravel
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=
public function createOrUpdateCustomer()
{
Customer::updateOrCreate([
'customer_id' => $customer_id,
'name' => 'Name',
'phone' => '019000000',
'email' => 'customer@gmail.com'
]);
}
public function getCustomerAndPlans()
{
$get_customer_and_plans = Subscription::getCustomerAndPlans($customer_id);
return json_encode($get_customer_and_plans);
}
public function subscribe()
{
Subscription::subscribe($customer_id, $plan_id);
}
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);
}
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);
}
public function invoices()
{
$response = Invoice::list($customer_id);
return json_encode($response);
}
public function download()
{
return Invoice::download($invoice_uuid);
}
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email mab@asorasoft.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.