#elBR-subscription-default-pm
1 messages · Page 1 of 1 (latest)
Hello 👋
You can't change the customer that is linked to a subscription.
However, you can update their billing information by calling the API
https://stripe.com/docs/api/customers/update?lang=php
but if I update the customer, all invoicing history, cards and other informations will be there?
I believe so, it should be there
but is suposed to change ownership completely. Cards that belong to the past customer should not be listed anymore
You can detach the previous payment methods by calling the API and have the customer input a new one (preferably using SetupIntents API) and set that as customer.invoice_settings.default_payment_method
https://stripe.com/docs/api/payment_methods/detach?lang=php
can I ask you another question please
what happens if user has an active subscription and has a customer default payment method (no subscription default method) and then he decides to remove the default card and add another card that is not default
How are they detaching it? With the customer portal?
no customer portal
but I am asking if I create a subscription and do not set a default payment method for the susbscription, but on the same time the customer does not have any default payment method on his payment methods, does the subscription charge any card?
No, it will only charge the card that you have specified as the default for either the customer or subscription. If there is no default for either, no card will be automatically charged.
ok
here it tells that if you delete the default card, then the most recently added card will become the new default
Good catch, so yeah that card would be the default and would then be charged. I apologize, I was unaware of that nuance to the delete behavior.
Ah that is for the sources API. If you are working with the PaymentMethods API, we don't mention a similar behavior. https://stripe.com/docs/api/payment_methods/detach#customer_detach_payment_method
So it would be good to test if you are working with PaymentMethods
ah, but was is the difference between detach payment method and delete that I showed you?
I think there is probably a difference but I have not gotten a chance to check yet. If you have a few minutes to run a quick test that can help confirm how it works
I'm still helping a couple other threads too much to test myself at the moment
the problem is that it requires a card_id
like this
'card_1LvMbQEMyoEBRsWZtxbFALLo'
my payment methods do not have any card id
The PaymentMethods API is backwards compatible, so you can use that card_ ID anywhere a pm_ ID would work. But I don't think it works the other way around, so you probably need to use the payment method detach method that I mentioned
ok, but is the behaviour the same if I detach it? So will the most recently added card will become the new default?
I want that if customer has not default card payments, the subscription to go to past_due and not charge another card
I want to be sure about that
I don't know for sure unfortunately. Testing this in test mode would be the way to find that out.
But I cannot simulate the new charge of the subscription
I must pass the billing cycle time
If the fields for the defaults on the customer and subscription are empty, the subscription will not charge either. I thought you were asking about whether detaching would automatically update invoice_settings.default_payment_method to a new pm_123... ID which would be something you could check quicker
Also in future you may find Test Clocks helpful, they do allow you to fast forward time to see how subscriptions will act in the future when they cycle https://stripe.com/docs/billing/testing/test-clocks
ok thank you Pompey
I have another question. Does Stripe prevent the creation of a new payment method if user for example creates a new payment method but adds the same card information?
We don't prevent that, so two payment methods would exist for the same card. You can write your own custom code to prevent duplicates but at the moment we don't have anything pre-built for that
Basically you can listen to the payment_method.attached event, when a card is attached, you check its fingerprint, against the fingerprints of existing cards, and remove one of the duplicate PMs if duplicates exist
Ok, my last question regarding payment methods
If I create a subscription and do not provide any default payment method, but let front-end create ask for card details using Stripe Elements, why does the card get saved automatically as payment method for the customer?
or If the customer pays an invoice
I don’t want that to happen
No, those shouldn't set the default payment method automatically. You will still have to designate it as the default with API calls after the payment method has been created and attached
no, they do not set it as default payment method, but they get listed as payment methods
Oh wait I see, you said that you already are seeing that happen. Do you have an example ID of a customer that this happened for? (cus_123)
elBR-subscription-default-pm