#dvanallen_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1301630286160990239
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there ๐ I don't believe the Customer Sheet is expected to allow customers to manage their default payment method for subscriptions, at either the Customer object level or Subscription object level. It looks like the default managed by that sheet is the default payment method for the device being used:
https://docs.stripe.com/elements/customer-sheet#:~:text=set their default payment method stored locally on the device
Can you elaborate a bit on what you mean when you say you attach a Payment Intent to a Customer? That verbiage is a bit odd and I'm not sure what it means or how it relates to a subscription integration.
sorry, what i meant is that i can use the payment sheet to attach a payment method to a customer (by passing in a customer configuration)
when i attach a customer to the payment sheet, then that makes it show the box that says "save this payment method for future use"
Ah gotcha. Yeah, that's native payment sheet behavior that lets your customers save their payment methods for future usage, but it doesn't allow them to set the payment method as default for Subscriptions. You will need to make that update yourself.
my understanding is that a subscription will use the customer's default payment method if there is no default payment method on the subscription itself. so i was hoping that we could use the payment customer sheet to give a customer control over their default payment method. but you're saying there is no native support for allowing a customer to update their default payment method used for subscriptions (i think the field i want is https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method)
Correct, and yup, that's the right field.
so when a customer does the initial payment in the paymentsheet i can listen for the payment_method.attached which would indicate they checked the box to save for future usage and then add that as their default payment method in the customer invoice settings
and i think when i want to update it i could use a customersheet and then pass the selected payment method back as seen in https://docs.stripe.com/elements/customer-sheet?platform=ios&mobile-customer-session=legacy-customer-ephemeral-key#ios-present-wallet-element
Yes, but this still feels a little off for a Subscription integration. Are you processing a payment then creating a Subscription later, or are you using the Payment Sheet to process the first payment for the Subscription?
the latter - we create a subscription, and then we grab the automatically created payment intent from the automatically created first invoice, and we generate the ephemeral key and client key and pass that back to our iOS app which uses that to present a payment sheet for the first payment
Gotcha, are you setting payment_settings.save_default_payment_method to on_subscription when creating the Subscription object?
https://docs.stripe.com/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
That will automatically save the payment method from the first payment as the default payment method for the Subscription. It still doesn't set it as the default at the Customer level, but should allow recurring subscription payments to use the new payment method without you making an extra request.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
we tried doing that, and we did see that the payments would continue to work when simulating time to the next subscription period, but then the issue is that we had no way to update that default payment method
Can you elaborate on that last point?
well, maybe it's more of a question, how would i be able to allow the user to update the default payment method on the subscription
You'd collect new payment method details, then you can make a request to update the Subscription passing the ID of the new Payment Method to the default_payment_method field:
https://docs.stripe.com/api/subscriptions/update#update_subscription-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
would i use the customersheet and grab the selected payment method or how would you recommend grabbing those payment details
What comes to mind for that is using a Setup Intent in conjuction with the Payment Sheet:
https://docs.stripe.com/payments/save-and-reuse
I have another thread going too, but I'll take a closer look through the Customer Sheet flow and see if I think it could be beneficial here.
ok thanks i can give that a try. my last concern here is that if we use the payment_settings.save_default_payment_method option on a subscription, there is not necessarily any text shown to the user in the paymentsheet that they would be saving the card for future payments
Oh hm, can you show me what you see when you do that? I thought our UIs did show a little blurb that payment details are being saved to be used in the future, but might be mixing up our UIs.
give me a few minutes and i can grab a screenshot
but basically the way it works is you can present a paymentsheet without using a customer configuration and without setting the paymentintent to save for off_session future usage, so then the box to save the payment for future payments is not shown in the paymentsheet. but then you can just set the subscription settings on the backend to save the payment method to the subscription anyways.
without setting the paymentintent to save for off_session future usage
I don't understand this part. The Subscription will cause the Payment Intent it generates to setup the payment method for future usage if you usesave_default_payment_method. That's not something you have to set on the Payment Intent.
yes it works fine but the issue is that there's no text in the paymentsheet that tells the customer that it will be saved
still working on the screenshot
nope my bad i see the text at the bottom, i was looking for the checkbox but i see the text there now
i will try the paymentsheet with setupintent and send the paymentmethod to the backend to update the subscription default payment method
thank you