Questions tagged [laravel-cashier]

Laravel Cashier provides an expressive, fluent interface to Stripe's and Braintree's subscription billing services.

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier can handle coupons, swapping subscription, subscription "quantities", cancellation grace periods, and even generate invoice PDFs.

Configuration

Composer

First, add the Cashier package to your composer.json file and run the composer update command:

"laravel/cashier": "~5.0" (For Stripe SDK ~2.0, and Stripe APIs on 2015-02-18 version and later)
"laravel/cashier": "~4.0" (For Stripe APIs on 2015-02-18 version and later)
"laravel/cashier": "~3.0" (For Stripe APIs up to and including 2015-02-16 version)

Service Provider

Next, register the Laravel\Cashier\CashierServiceProvider service provider in your app configuration file.

Migration

Before using Cashier, we'll need to add several columns to your database. Don't worry, you can use the cashier:table Artisan command to create a migration to add the necessary column. For example, to add the column to the users table run the command: php artisan cashier:table users.

Model Setup

Next, add the BillableTrait and appropriate date mutators to your model definition:

use Laravel\Cashier\Billable;
use Laravel\Cashier\Contracts\Billable as BillableContract;

class User extends Eloquent implements BillableContract {

    use Billable;

    protected $dates = ['trial_ends_at', 'subscription_ends_at'];

}

Adding the columns to your model's $dates property will instruct Eloquent to return the columns as Carbon / DateTime instances instead of raw strings.

Stripe Key

Finally, set your Stripe key in your services.php configuration file:

'stripe' => [
    'model'  => 'User',
    'secret' => env('STRIPE_API_SECRET'),
],

Reference

458 questions
2
votes
1 answer

Laravel Cashier Call to Undefined Method onGracePeriod()

So I recently upgraded from Laravel 5.1 -> 5.4 and Cashier from 5.0 -> 7.0. In my blade I am using this check to see if a user is in their grace period onGracePeriod()): ?> However now this code throws an…
CMOS
  • 2,727
  • 8
  • 47
  • 83
2
votes
1 answer

Laravel 5.3, Cashier - Braintree - Single Charges

I followed the Laravel docs to implement the Cashier but I can't get it to work. In short: made and migrated migrations added Billable to my User.php model added keys to my .env, referred to them in my config/services.php and added the SDK calls to…
dbr
  • 1,037
  • 14
  • 34
2
votes
1 answer

Laravel - Cashier | swap() and cancelNow() on null

Basically I have this problem which keeps occuring. Once a user subscribes, it all works fine. He can cancel/change subscription no problem. However, once they have changed their subscription once, I cant call swap or cancel without it throwing an…
e4stwood
  • 109
  • 1
  • 2
  • 8
2
votes
0 answers

laravel cashier stripe - How charge customer immediately when changing subscription with the same interval

I implemented laravel 5.2 with cashier (stripe). I have three plan: Basic - monthly Pro - monthly Agency - monthly Now if I have customer that subscribe to Basic plan and he decided to subscribe to Pro plan. How can I charge him immediately with…
Dani Banai
  • 1,080
  • 4
  • 14
  • 33
2
votes
1 answer

laravel cashier - save creditcard last 4 number and expire date

I'm using laravel 5.2 with cashier package this is the form that i'm using in order to get the client creditcard token: