#maddockst-iOS-PaymentSheet

1 messages · Page 1 of 1 (latest)

soft raft
#

Hi there

gilded dust
#

Hello!

soft raft
#

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

gilded dust
#

I am creating the customer, creating a subscription, authorising a setup / payment intent.

soft raft
#

Ah I see

#

So you are specifically asking about a trialing Sub

#

Which won't contain a PaymentIntent for the initial invoice

gilded dust
#

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

soft raft
#

Sorry, server is busy.

gilded dust
#

No problem at all

soft raft
#

One sec

#

I think there is an easy solution for this, but need to confirm.

gilded dust
#

Ok awesome

soft raft
#

Okay

#

Yep

#

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

gilded dust
#

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?

soft raft
#

Yep

gilded dust
#

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?

soft raft
#

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

gilded dust
#

Yes, of course. But that's fine, I can work with status !== 'incomplete' or something

soft raft
#

Yep exactly

gilded dust
#

Perfect

#

Really appreciate the help

#

You've been great