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

Unable to install Laravel's 5 cashier/stripe packages

I have put the "laravel/cashier": "~5.0" line in my composer.json file, updated it; Next, I have put the line 'Laravel\Cashier\CashierServiceProvider' into $providers array in, app.php Then, in cmd when I try to migrate table, php artisan…
sk4yb3n
  • 244
  • 1
  • 4
  • 9
2
votes
0 answers

Laravel cashier subscription per user role

I have a question. my user has 2 roles (creator, sponsor) and i have a user_profile to distinguish per user role. is it possible that a user has a different subscription per role? if so, then should I use the Billable trait on the UserProfile…
draw134
  • 1,053
  • 4
  • 35
  • 84
2
votes
0 answers

Laravel cashier append and update migration

I am using laravel cashier and stripe for checkout and subscription. I utilized the stripe's redirectToBillingPortal() method that lets me redirect to their site to manage my subscription, payment methods and other stuff. The problem is when I do a…
draw134
  • 1,053
  • 4
  • 35
  • 84
2
votes
0 answers

Laravel Cashier - determining default payment method without bloat

I would like to loop through all the payment methods and determine which is the default. Getting all can be done using $_paymentMethods = $user->paymentMethods(); But there is no key showing which is default. Not sure if I'm missing something. I…
good_afternoon
  • 1,529
  • 1
  • 12
  • 41
2
votes
2 answers

Laravel Cashier - Class "App\Models\User" not found

When trying to cancel a subscription with Laravel Cashier, it returns the error: Class "App\Models\User" not found Code: public function cancel(Request $request) { $subscription = Auth::user()->subscription('default'); …
Felix
  • 2,532
  • 5
  • 37
  • 75
2
votes
2 answers

Incorrect price in 3D Secure on Stripe using Laravel Cashier

I created a website with a subscription. I don't know why i don't have the good price in my 3D Secure confirmation. The confirmation display: 0$ and when you pay. You are charged successfully of 20$. Here is my controller : public function…
F. Vandroy
  • 122
  • 2
  • 15
2
votes
1 answer

How to pass quantity in the swapAndInvoice Laravel Cashier's method?

I'm trying to make the below work: $company->subscription('default')->swapAndInvoice($price_id,['quantity'=>$quantity]); But I'm getting the following message: Received both items and quantity parameters. Please pass in only one. I've also tried…
Inigo EC
  • 2,178
  • 3
  • 22
  • 31
2
votes
2 answers

stripe payment method is returning null when I submit form

when I try to create a new subscription I get this error (This customer has no attached payment source or default payment method. ) so I checked the PaymentController with dd($paymentMethod) which returned null so I don't know why the variable…
2
votes
2 answers

Laravel Cashier Multiple Plans

anyone used Laravel Cashier and has an answer to my below question. I want to cancel a subscription and in the docs it's written like that $user->subscription('default')->cancelNow(); In my case the user owns a place and i added an extra table to…
Steve
  • 548
  • 1
  • 10
  • 21
2
votes
1 answer

Cashier Laravel error on create new Subscription

I'm trying to implements laravel cashier in my project. I have laravel 5.5 and cashier 7.2.2. I have a problem when I try to createNewSubscription. In my controller I have: $user = User::find(3); $subscription = $user->newSubscription('Base',…
LorenzoBerti
  • 6,704
  • 8
  • 47
  • 89
2
votes
2 answers

How to update ends_at field of laravel cashier

I want to update ends_at column of subscriptions table. When i use Carbon::now() It update perfectly but when is use Carbon::now()->addCenturies(5); I am face error SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value:…
2
votes
0 answers

Getting error when try to make payment with new card in stripe subscriptions

I am using Laravel Cashier and while working on creating a stripe subscription and when I try to pay using failed test card number 4000008260003178 then it is going in my catch() but creating a subscription with Incomplete payment and Invoice is…
2
votes
2 answers

Laravel Cashier - publish migration results in "cannot declare class CreateCustomersColumns"

I have a fresh Laravel installation and I've added Cashier to my project. Since the Users model on my app won't have a stripe connection, but rather an Accounts model, I need to alter their migration to add columns to Accounts instead of Users The…
good_afternoon
  • 1,529
  • 1
  • 12
  • 41
2
votes
0 answers

Using cashier capabilities without stripe?

Stripe and Braintree are not available in my location, so I've to use Paypal. I'm trying to figure out the technicalities and best practices , since it's my first time integrating payments. I'm also trying to figure how to smoothly go from a…
nscode
  • 147
  • 1
  • 9