#burger-reactnative-subscription

1 messages ยท Page 1 of 1 (latest)

whole harbor
#

Hello!

errant laurel
#

hello ๐Ÿ™‚

whole harbor
#

In theory what you do is that you
1/ Create the Customer
2/ Create the Subscription with payment_behavior: 'default_incomplete
That will automatically create the first invoice for you, that first invoice will have a PaymentIntent, that PaymentIntent will have a client_secret and that's the client_secret you give to your mobile app where you confirm it. When you do, the subscription becomes active

errant laurel
#

hmm, so i've covered that but it's just not marrying up to the subscription loool

whole harbor
#

that's the thing, you need to start with the subscription

#

do you have a PaymentIntent id pi_123 that I can look at

errant laurel
#

yes

#

sure do

#

pi_3LGmGaKYfNu7l2460ITvUv3z

whole harbor
#

That's not the right way unfortunately

#

Waht you want is what I explained above. You have to create the subscription first

#

and that Subscription will create an Invoice in_123 and that Invoice will have a PaymentIntent pi_ABC

errant laurel
#

the subscription is created first then the card details captured + then the backend is called

whole harbor
#

ohhh

#

you create both

errant laurel
#

ooft so i can pass in a param for paymentIntent?

whole harbor
#

that's your subscription creation call

#

that call has the PaymentIntent for you: pi_3LGmGSKYfNu7l2460AIx8dGb

#

you need to use that one not a new one

errant laurel
#

ooft

#

so instead of paymentintent.create i'm using paymentintent.retrieve

whole harbor
#

kind of

#

you don't need any

#

You already have it

#

So when you create that Subscription you get itback in node and you already expanded the Invoice and the PaymentIntent

#

you can do subscription.latest_invoice.payment_intent.client_secret immediately and send that to your mobile app

errant laurel
#

ahh, i see, i think it's getting tossed there, i'll give that a whirl, cheers!

whole harbor
#

sure thing! let me know if you're stuck

errant laurel
#

aight, changed everything over, but went with paymentSheet

paymentsheet returns "success" on the same payment intent client secret but i don't think anythings happening after that lelel

whole harbor
#

At that point the PaymentIntent should have status: "succeeded" and then the Subscription should have status: "active"

#

do you have another PaymentIntent id I can look at?

errant laurel
#

ahh, this where i update via webhooks?

whole harbor
#

yes!

#

though it completes on your mobile app so you can hit your server after the fact to report the success

errant laurel
#

perfect, i'll chuck in some code for handling it server side now ๐Ÿ˜„

whole harbor
#

Always use webhooks since your request could fail, you could lose internet, etc. But if I were building this I'd still submit to my server to try and move forward quickly

errant laurel
#

yeah definitely always using webhooks when required ๐Ÿ™‚

#

would you say paymentsheet is a good way to process these payments for subscriptions?

whole harbor
#

I think so yes, that's what I'd do at least

errant laurel
#

so if the payment succeeds, it triggers the webhook, but doesn't log a payment to the customer?

whole harbor
#

the PaymentIntent would be on the customer with a successful Charge

#

Do you have that cus_123 or pi_123 handy?

errant laurel
#

yeah didn't go through and payment sheet seems to have returned an image lol
cus_LyeKGrXNOQpv73

whole harbor
#

what does "returned an image" mean? ๐Ÿ˜…

errant laurel
#

"paymentOption"

from

const { error, paymentOption } = await presentPaymentSheet();
#

ooft i think i missed something

#

scrap that, little bit of dodgy code on my behalf by the looks