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
-1
votes
1 answer

Create or get Stripe customer in two different Stripe accounts

I have two Stripe accounts: # Stripe API Keys STRIPE_KEY=pk_test_abc STRIPE_SECRET=sk_test_abc STRIPE_KEY_MAPPING=pk_test_opr STRIPE_SECRET_MAPPING_MASTER=sk_test_opr I put both in an array: $stripe_accounts = [ env('STRIPE_SECRET'), …
GPiter
  • 779
  • 1
  • 11
  • 24
-1
votes
1 answer

issue installing Laravel cashier package on Laravel 7.0

install Laravel cashier package but not install getting error and used PHP version: 7.4.8 Using version ^13.4 for laravel/cashier ./composer.json has been updated Running composer update laravel/cashier Loading composer repositories with package…
-1
votes
1 answer

How to Change Type of Column in Subscription Table

I am using Cashier 10.7 and Stripe 7 and Laravel 5.8. I have integrated Cashier into my application and now I want to change type of 'ends_at' column. However, subscription table migration, migrate auto, and migration folder does not contain…
-1
votes
2 answers

Laravel Spark 9.0 undefined currency label

I have upgraded Laravel to 6.0, Laravel Spark to 9.0 and Cashier to 10.0 In the Spark Subscription settings I am seeing undefined as the currency instead of $. I tried adding CASHIER_CURRENCY=usd to .env but no difference. Here is what I…
Andy
  • 333
  • 4
  • 10
-1
votes
1 answer

creating subscription with laravel cashier

Documentation lists this example: $user = User::find(1); $user->newSubscription('main', 'monthly')->create($creditCardToken); The create method will begin the subscription as well as update your database with the customer ID and other relevant…
niko craft
  • 2,893
  • 5
  • 38
  • 67
-2
votes
1 answer

Using Laravel Auth Registration to create a Stripe Subscription

The title is pretty self-explanatory. I was able to set up a button that takes an existing user and registers them for a subscription in Stripe - but I can't figure out how to create a new user & register them for a subscription in the same step. I…
-3
votes
1 answer

How can I get the users subscribed to a plan?

I need a query or scope that can retrieve all the users subscribed to a named plan by Laravel Cashier.
Allfarid Morales García
  • 1,455
  • 2
  • 17
  • 27
-3
votes
1 answer

Stripe Recurring Payments but every 3 or 6 months

I'm new to Stripe PHP Laravel. Are recurring payments in Laravel Stripe possible for billing cycles that are not 1 month but 3 months or 6 months? Can anyone send me to the right documentation because I'm not familiar with the term? I have checked…
James Arnold
  • 698
  • 3
  • 9
  • 22
1 2 3
30
31