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

Stripe Upcoming Invoice API while in trial period

I'd like to show a customer a preview (or a quote) of what their subscription charges will be if they make changes to their subscription. For this, I'm using the "upcoming invoice" API endpoint: https://stripe.com/docs/api/invoices/upcoming From…
karel
  • 468
  • 5
  • 14
2
votes
2 answers

Laravel cashier (Stripe) - How to create subscription for metered usage?

I'm having some trouble trying to implement Cashier (Stripe) into my Laravel application. What I'm trying to do is create a new subscription on an already existing customer (company). But when I do so I get the following error: You cannot set the…
Nissen
  • 287
  • 3
  • 17
2
votes
1 answer

Dynamically set currency on Laravel Cashier 10 (Laravel 6.x)

I have an application where admin can change the currency from the backend panel. As now cashier 10 has no useCurrency() method like older versions. What could be the way to set currency other than configuring the .env file?
Munna Khan
  • 1,902
  • 1
  • 18
  • 24
2
votes
4 answers

Laravel Cashier paymentMethods() return always empty object result

Cashier Version: ^10.5 Laravel Version: ^6.0 PHP Version: 7.3.5 Database Driver & Version: Description: paymentMethods() retrieve always array with empty object. public function userAllPaymentMethods(Request $request) { $user =…
Hiren Ghodasara
  • 336
  • 1
  • 9
2
votes
6 answers

Laravel Cashier - Cancel a subscription using the stripe id

I'm using Laravel Cashier with stripe payment. One user can have multiple subscriptions. User should able to cancel particular subscription. Is there anyway to cancel subscription by stripe id or plan id?
Shankar S Bavan
  • 922
  • 1
  • 12
  • 32
2
votes
2 answers

one-time payment with Laravel Cashier without subscription

I'm Planning to use Laravel Cashier for one-time payments with Stripe. It says in the documentation: If you're only performing "one-off" charges and do not offer subscriptions, you should not use Cashier. However, I was able to charge the user…
Firouziam
  • 777
  • 1
  • 9
  • 31
2
votes
2 answers

Select card from saved cards, if not create a new card Before Payment in Laravel Cashier

Select card from saved cards, if not create a new card Before Payment in Laravel Cashier. Note: Just Charging the $N amount, N can be different for next time checkout. Step 1: List of Saved Cards, if not create a new one. Step 2: Choose Card Step 3:…
2
votes
1 answer

Laravel cashier with stripe : no such plan error?

I have created a Plans table with some data. When I am trying to subscribe the plans, Laravel-Cashier says : No Such Plan. What I am missing? I also created a plan through Stripe dashboard, but nothing changed. How can I overcome this issue? Here…
Techno
  • 55
  • 11
2
votes
0 answers

Upgrade plan on the next billing cycle - Laravel Cashier

I have a functionality where I need to upgrade a plan for a subscription but only on the next billing cycle. Default behaviour, when using swap() method, is that the prorate is calculated and then Cashier figures out how much to charge. In my case…
Nermin Sehic
  • 594
  • 6
  • 22
2
votes
1 answer

Laravel Cashier (Stripe) get subscription cost or coupon used?

I'm using Laravel Cashier with Stripe. In my account panel I want to show users how much their monthly subscription is costing them. Users can have a normal plan without a coupon or the same plan with a coupon that makes it half price. Is there…
Mr J
  • 2,655
  • 4
  • 37
  • 58
2
votes
1 answer

laravel cashier braintree BadMethodCallException

I'm on laravel tinker. Utilizador means User in English. When I do Utilizador::all()->last()->subscribed('main') I get: BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::valid()' Don't know why. When…
alexandre1985
  • 1,056
  • 3
  • 13
  • 31
2
votes
1 answer

Laravel 5.4 Cashier - bridging the gap in documentation

I've been working my way through the documentation on Laravels website regarding Cashier. From the sounds of it, it seems like it is exactly what I need. A basic subscription configuration that integrates with Stripe. I am able to follow along…
John Hubler
  • 877
  • 1
  • 11
  • 27
2
votes
0 answers

Using Cashier's subscription table for offline payments?

Say I build and app, and I setup Cashier with Stripe and everything works fine but I also want to have an option for people making payments differently (say offline, by cheque). Rather than building a separate system alongside Cashier, I'm thinking…
Jean-Philippe Murray
  • 1,208
  • 2
  • 12
  • 34
2
votes
2 answers

Laravel cashier with Stripe: invoice number

Not sure it's the same elsewhere, but in my country, invoice numbers must be sequential for a service in a company. My Laravel application sells a service via subscription. It must produce invoices with sequential numbers (abcdef-0001, abcdef-0002,…
rap-2-h
  • 30,204
  • 37
  • 167
  • 263
2
votes
2 answers

laravel 5.3 cashier with stripe how to get remaining days to expire a plan

I am using Laravel 5.3 to subscribe users on plans with payment handling by stripe. I registered a plan on stripe, and subscribed user to that plan successfully using the following code $user->newSubscription($planName,…
Fawad-MT
  • 21
  • 2