ptuchik / billing
Billing package for Laravel 5.5 supporting packages, plans, coupons, addons, payments and subscriptions
Installs: 19 853
Dependents: 0
Suggesters: 0
Security: 0
Stars: 28
Watchers: 2
Forks: 13
Open Issues: 1
Requires
- illuminate/support: ^5.5|^5.6|^5.7|^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- league/omnipay: ^3.0
- ptuchik/braintree: 1.1.6
- ptuchik/core-utilities: ^1.0
- torann/currency: ^1.0
- ucraft-com/detection: ^1.2
- dev-master
- 1.9.7
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.9
- 1.8.8
- 1.8.7
- 1.8.6
- 1.8.5
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.9
- 1.7.8
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-develop
- dev-hotfix/1.0_subscription_autorenew_cancel_reason
- dev-1x-develop
- dev-paymentMethodsImplementation
This package is auto-updated.
Last update: 2024-12-22 08:51:00 UTC
README
WARNING!!! If you are already using v1.x version, please stay on it, v2.x may have some backward incompatibilities...
Sell anything for everything...
Billing package for Laravel 5.5+ supporting packages, plans, coupons, addons, payments and subscriptions with multi currencies
Structure:
The structure is the following:
- Billable - Model that will pay for everything
- Hostable - Model for which can be purchased everything
- Package - Model that can be purchased
- Plan - Model that will sell the Package
- Reference - Can be any model, that will be purchased with Package
- Coupon - Discount, which can be applied on Plan purchase
Concept
The concept is the following:
To be able to use this package, firstly you need to add Billable
trait to your billable model and implement Billable
interface (usually it is User model).
Hostable models have to implement Hostable
interface and use Hostable
trait, which will add Purchases relation to model.
All packages have to be extended from PackageModel abstract class.
That's it!
P. S. Everything is overridable from configuration, provided by package
Installation
composer require ptuchik/billing
After composer installation, just run php artisan migrate
as usual, to have the additional tables added to your database and publish configurations by executing:
php artisan vendor:publish --provider="Torann\Currency\CurrencyServiceProvider" --tag=config
php artisan vendor:publish --provider="Ptuchik\Billing\Providers\BillingServiceProvider" --tag=config
php artisan vendor:publish --provider="Ptuchik\CoreUtilities\Providers\CoreUtilitiesServiceProvider" --tag=config
IMPORTANT! Your billable model has to have the following attributes:
balance
- cast: numericpaymentGateway
- cast: stringpaymentProfiles
- cast: arraycurrency
- cast: stringparams
- cast: array
and isTester()
method, which will indicate if your billable model is tester or customer, to set the correct mode of payment gateway environment. If you don't need testers, you can just create the following method in your billable model:
public function isTester() { return false; }
Usage
To get the plan details, with trial days calculation and summary (all coupons and available balance discounts applied) for current user on current host, just call:
$plan->prepare($hostable); // Will return plan with all calculations applied for logged in user
To purchase the plan, just call:
$plan->purchase($hostable); // It will do the rest automagically
Documentation
Coming soon...
Special thanks to
- Taylor Otwell for the best framework - Laravel
- Daniel Stainback aka Torann for Currencies
- Spatie for Translatable package
- The League of Extraordinary Packages for Omnipay - multi-gateway payment processing library