Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateDefaultPaymentMethod() should update subscription's default payment method #1650

Closed
FrozenGod opened this issue Feb 8, 2024 · 2 comments

Comments

@FrozenGod
Copy link

FrozenGod commented Feb 8, 2024

The updateDefaultPaymentMethod() method only updates the invoice_settings.default_payment_method on the Customer object in Stripe.

But when a plan is swapped with another plan ($subscription->swapAndInvoice($plan)) – Stripe charges the card attached at the time of subscription creation because as described in the Stripe documentation:

Setting default_payment_method on the Subscription will cause all future invoices for that subscription to be paid with the specified payment method, overriding any invoice_settings.default_payment_method set on the associated Customer.

What's the point of updating Customer’s invoice_settings.default_payment_method if Subscription’s default_payment_method overrides it every time?

Is it possible to change the default_payment_method on the Subscription in the current version of Cashier?

Currently updating the default payment method results in the following:

Payment method is set as default for the Customer (*4444):
image

Payment method is NOT set as default on the Subscription (*4242):
image

New charge on a new invoice for swapping plans charges the Subscription default payment method (*4242), and not the Customer default (*4444):
image

This means that we cannot initiate a default payment method change (the pm to be actually charged for next invoices) using Cashier's build-in methods alone. This makes the whole defaultPaymentMethod() method redundant because it does nothing functionality-wise. It just changes the position of the "Default" badge in the Stripe customer object with no real world utility.

The subscription was created using:

$billable->newSubscription('default', $plan)->checkout([...]);
@driesvints
Copy link
Member

Hi there. The current behaviour is the wanted one imo. I don't think that changing the default payment method on the customer should update the payment method on all of the existing subscriptions. We could add a new method on the subscription model maybe to update that payment method as well but I don't think that the current updateDefaultPaymentMethod method should automatically change the PM for a subscription as those are two separate concerns.

@FrozenGod
Copy link
Author

Hi @driesvints

I don't really know what is the default payment method used for. Stripe sets the default payment method on the subscription by default, which always overrides the default payment method of the customer.

Maybe I'm not aware of the various use cases but for subscriptions I really can't come up with a way to have any use in the Customer's default payment method.

I think it's not the best approach by Stripe in the first place. I understand Cashier is just a wrapper on an existing API and I agree that Cashier should at least have an additional method for changing Subscription's payment method.

It was easy to create an event handler with:

$subscription = $billable->subscription();
        $subscription->updateStripeSubscription([
            'default_payment_method' => $newPaymentMethodId,
        ]);

But the time it took me to debug and research why my default payment method is not charged by default is definitely a huge waste of time, especially for people who use Cashier and/or Stripe API for the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants