Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shawnyv's avatar
Level 13

Adding Subscription to Cashier Customer

Hey all,

This was frustrating me earlier, and I had a hard time finding documentation about it, so I wanted to share.

Apologies in advance if this is well understood by everybody but me! :)

In my application, I was allowing customers to attach their card as a customer, without making any transactions first.

The issue came up when I wanted to attach a subscription using Cashier.

This didn't work, even when the user had a valid stripe customer id (stripe_id = 'cus_xxxxx'):

$quantity = request('quantity');
$user = auth()->user();
$subscription = $user->newSubscription('product','plan')->quantity($quantity)->create();

Instead, I had to manually grab the payment method from Stripe first, to pass into Stripe:

$quantity = request('quantity');
$user             = auth()->user();
$payment_method = $user->paymentMethods()->first();
$subscription = $user->newSubscription('product','plan')->quantity($quantity)->create($payment_method->id;);

By grabbing the first paymentMethods from the user, we're then able to access the Stripe payment identifier token value (ie 'pm_xxxxx'). This is what cashier expects.

If nothing else, this will help me in the next project I set up like this! :)

0 likes
3 replies
Nakov's avatar

hey @shawnyv,

This is tricking the customer, because he might not want to use that payment method as a one to be charged.

You should show a list of payment methods attached for that customer, and then allow the customer to chose which one should be default, only then the subscription will work as it should :)

Earlier today we had similar discussion with a user here. So from the Billable trait, hasPaymentMethod() will also return false if you don't have a Default payment method for the customer.

So I think that the proper way is to list all the payment methods for the customer, and allow him/her to select which one should be used by default.

You can take a look at the discussion here:

https://laracasts.com/discuss/channels/laravel/cashier-addpaymentmethod-does-not-update-card-brand

Now that user is pretty angry with me, but nonetheless I am trying to help here :)

You can try that approach and let me know if it does the job.. just to test if it will work when the user has a default payment method, try this line first:

$user->updateDefaultPaymentMethod($user->paymentMethods()->first()->id);

// then 

$subscription = $user->newSubscription('product','plan')->quantity($quantity)->create();

should work I believe :) but let's see :)

shawnyv's avatar
Level 13

In my app, I've set up only one payment method per customer. They're free to change it as they like. No tricks necessary!

Nakov's avatar

@shawnyv okay, then set that one as a default on Stripe as well :) then you won't need to do what you did there I believe.

Please or to participate in this conversation.