Download the PHP package tmyers273/laravel-stripe-billing without Composer
On this page you can find all versions of the php package tmyers273/laravel-stripe-billing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-stripe-billing
Laravel Stripe Billing
Versions
- 1.x - Laravel 5.1 -> 5.7
- 2.x - Laravel 5.8+
Installation
Via composer:
composer require tmyers273/laravel-stripe-billing
After package is installed via composer, run the following command:
php artisan vendor:publish
and then pick Provider: TMyers\StripeBilling\StripeBillingServiceProvider
from the displayed list.
This will copy migrations files and config into your app.
Afterwards run the migrations:
Usage
Add Billable
trait to the User model.
Stripe Secret
In order to use this package you must posses a Stripe Secret Key.
It must be stored as an environment variable STRIPE_SECRET
and/or set in config/services.php
under stripe.secret
Models
- Product (this is the parent product used to control access rights - e.g. Pro, Gold, Basic, Team etc.)
- Price (this defines price and trial period e.g. pro_monthly_10, gold_yearly_9999 etc.)
- Subscription
- Card
Product model represents product access/privileges parameters Price model optionally belongs to Product model and represents price parameters
Public API
StripeBilling static helper
Stripe customer
Subscriptions
By default users can have multiple subscriptions.
But this can be changed by setting unique_active_subscription
to true
in config/stripe-billing.php
Check subscription
Retrieve subscriptions and chain methods
Create products and subscriptions
List subscriptions
Cancel subscriptions
Resuming subscription
Resuming subscription is possible only as long as it is on grace period
Extend trial
Extending the trial is done in two ways.
This will default prorate to false
Changing plan
Subscription scopes
Charges and credit cards
Default card
Add card from token
This will create a stripe customer if user does not have one assigned yet. The default source of the new Stripe customer will be used to create the default credit card for the user, which will be used by default for future transactions.
If Stripe customer already exists for the user and the user already has a default card, the new card will be added as a new source for the users's Stripe Customer and a new Card record will be created in the local database.
Set another card as default
That method by default takes \TMyers\StripeBilling\Models\Card::class
as an argument and makes the card
the default card for that user. User's corresponding Stripe Customer's default source also gets updated.
Check if user already has a default card assigned
Or you can pass an instance of \TMyers\StripeBilling\Models\Card::class
to verify
if that particular card is the default one for the user:
Remove card
Card helper methods
Single charges
When user already has a default card assigned:
Charge by token
Charge via non-default card
Coupons
Coupon can be either a Stripe/Coupon or a string coupon ID of an existing coupon
Middleware
Register in HTTP Kernel.php
The middleware can take parameters like so: subscription:basic,pro
- that means that
users with any of these subscriptions can pass the middleware. When used without parameters it will
just look for any active including onTrial
or OnGracePeriod
subscriptions
Blade directives
subscribed directive determines if user is logged in and subscribed
unless_subscribed directive determines if user is logged in and not subscribed
Config
All versions of laravel-stripe-billing with dependencies
illuminate/console Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0|~7.0
illuminate/database Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0|~7.0
illuminate/events Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0|~7.0
illuminate/support Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0|~7.0
stripe/stripe-php Version ^7.0