#maddockst-iOS-PaymentSheet
1 messages · Page 1 of 1 (latest)
Hello!
So the recommended way here is to use Webhooks
And you would listen for payment_intent.succeeded
Which will contain the PaymentIntent and details about the Charge which would contain the PaymentMethod
Ok thanks. Just referring to your other colleagues post: #1017071690284531743 message
I am creating the customer, creating a subscription, authorising a setup / payment intent.
Ah I see
So you are specifically asking about a trialing Sub
Which won't contain a PaymentIntent for the initial invoice
Well, I pass a paymentintent or setupintent to the Payment Sheet (depending on trialing etc).
The issue is my client doesn't want the subscription to be active (in our database) until the subscription is active AND a payment method is attached.
So, to complete the flow I'm assuming that on payment_intent.succeeded I'll have to update the default_payment_method for the customer?
In order to allow future subscription payments to be taken
Sorry, server is busy.
No problem at all
Ok awesome
Okay
Yep
So what you want is to use payment_settings.save_default_payment_method: https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
When you create the Sub
This param works so that once the PaymentIntent or SetupIntent is confirmed, the PaymentMethod is automatically attached to the Sub as the default_payment_method
Then you can just listen for customer.subscription.updated events
And check for whether the default_payment_method is null or not for when you mark the Sub as active in your database
Ah ok, i did use that previously. Cool. So I have't got to manage the attaching myself through the WebSocket any more then?
Also, once I get a completed from the PaymentSheet, I can provision access to my services then couldn't I?
Yep
That's ideal. And finally, I'm going to get 2 x customer.subscription.updated events aren't I? First where the subscription has a status of active but default_payment_method is null and the second where default_payment_method is no longer null?
Yep
Recommend testing it out! But each time anything on the Subscription object updates a customer.subscription.updated event will fire
The status will be trialing in some cases here
But mostly you are just checking for the default_payment_method property
And when it moves from null to pm_xxxx
Yes, of course. But that's fine, I can work with status !== 'incomplete' or something
Yep exactly