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
38
votes
0 answers

Laravel Cashier Incomplete Exception Handling for 3D Secure / SCA

I'm currently trying to use Laravel Cashier to handle Billing inside a React application. When using a test card that requires 3D secure (pulled directly from Stripes Documentation) (4000000000003220), I get an IncompletePayment exception…
Squiggs.
  • 4,299
  • 6
  • 49
  • 89
22
votes
1 answer

Updating and Invoicing Stripe Subscription Quantity with Invoice description laravel cashier

Good Day, I'm working on a project involving Laravel Cashier. I want to give user's the ability to update their subscription quantity and get charged immediately (which I have been able to achieve, using the code below) $user =…
17
votes
3 answers

Get next billing date from Laravel Cashier

I have subscribed a user to a subscription plan through Laravel's Cashier package. I now want to display the date the user will next be billed, however this doesn't appear to be an available through the Billable trait. How do I get the next billing…
John1984
  • 917
  • 2
  • 13
  • 23
11
votes
2 answers

Create plan on stripe through laravel

I want to create a plan from my application on stripe. The scenario is that users are charged with different prices as recurring payments. So, that is why I want to create plan for each user. I am using laravel 5 and using "laravel/cashier": "~5.0"
Jamal Abdul Nasir
  • 2,557
  • 5
  • 28
  • 47
9
votes
2 answers

Laravel Cashier Events

I'm using Laravel cashier 7.0, and I'd like to fire some methods after a subscription is successful. I hoped there would be some events I could listen for, but that doesn't seem to be the case (unless I missed them). Stripe's the payment provider…
Daniel Dewhurst
  • 2,533
  • 2
  • 21
  • 39
9
votes
3 answers

Laravel Cashier Webhook: Get current user

I'm using the following to override the default handleCustomerSubscriptionDeleted method by placing the following in app/Http/Controllers/WebHookController.php:
Zach
  • 1,185
  • 3
  • 24
  • 60
8
votes
3 answers

Laravel: Cannot declare class App\Models\Customer, because the name is already in use

I'm a bit perplexed. I have a simple method on my User (actually "Customer") model to return a user's subscription renewal date: public function subscriptionRenewalDate() : string { $subscription =…
Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
8
votes
2 answers

If I cancel user's subscription manually in Stripe dashboard, should a webhook endpoint I set up on my web server be notified of that?

I am currently in test mode with Stripe. I cancelled a users subscription is Stripe dashboard, but the webhook I set up on my site's web server (which uses Laravel Cashier) does not fire i.e. the subscription data is unaffected on my site's web…
Mladen
  • 516
  • 1
  • 9
  • 20
8
votes
1 answer

Laravel 5 and Cashier on Company table

I am new to laravel and have been working with cashier for a web app I am developing. In my app a user creates their account and company and they are allowed to use the app. Because a company can have many users, I need cashier to check if the…
Derek
  • 4,747
  • 7
  • 44
  • 79
8
votes
2 answers

Laravel Cashier - Create New Subscription With Existing Customer Object

I'm using Laravel Cashier along with Stripe to manage subscriptions. The user will supply their credit card information when signing up, but they won't be subscribed in a specific plan at this point. So I can successfully use Stripe Checkout to…
JasonJensenDev
  • 2,377
  • 21
  • 30
7
votes
0 answers

Managing subscription changes with Laravel Cashier & Stripe

I'm currently integrating Laravel Cashier (using Stripe) into a small application that has the following three tiers of account; Free Basic (e.g. £1.99/month) Premium (e.g. £4.99/month) The current process is that, when a user confirms their email…
James Crinkley
  • 1,398
  • 1
  • 13
  • 33
6
votes
4 answers

Stripe error "The resource ID cannot be null or whitespace"

I am trying to create a subscription but get the error "The resource ID cannot be null or whitespace". I have stripe and cashier installed and migrated.
Matthew Foster
  • 167
  • 1
  • 10
6
votes
1 answer

Getting error while run migrate command in laravel 8

I'm using Laravel Cashier package. I've added below line AppServiceProvider.php > boot method Cashier::ignoreMigrations(); I've create my own migration i.e: create_subscriptions_table and create_subscription_items_table When I run php artisan…
Milan
  • 631
  • 1
  • 5
  • 21
6
votes
3 answers

Uncaught IntegrationError: Please call Stripe() with your publishable key. You used an empty string

Stripe was working fine with my Laravel application, and suddenly it started giving me this error in the console: Uncaught IntegrationError: Please call Stripe() with your publishable key. You used an empty…
Jake Scervino
  • 581
  • 4
  • 9
  • 26
6
votes
2 answers

Laravel Cashier - where does $stripeToken come from?

The documentation on Laravel Cashier is quite vague and misses some very important details like what the $stripeToken is and where does it come from? So to create a new subscription we do this: $user->newSubscription('main',…
user3574492
  • 6,225
  • 9
  • 52
  • 105
1
2 3
30 31