#maddockst-apple-pay-ios

1 messages ยท Page 1 of 1 (latest)

orchid ermine
#

Hello ๐Ÿ‘‹
Juggling between a few threads at the moment, give me a few to catch up and I'll respond as soon as I can ๐Ÿ™‚ thanks

outer minnow
#

No rush. Thanks for the quick reply!

orchid ermine
#

can you share the example PaymentIntent ID or the subscription ID?

outer minnow
#

The test subscription ID is sub_1LZbzmHM14YvCzvfaBqAVqpc

#

Weirdly, the membership appears to be active but I still get that error

orchid ermine
#

huh I'm trying to look for the request throwing 402: Payment Required error but I'm not finding it.

outer minnow
#

Ok, weird. Interestingly, I can see it's throwing on this line in my code:

const subscription = await stripe.subscriptions.create({
    customer: customerId,
    items: [ 
        { price: priceId },
    ],
    payment_behavior: 'default_incomplete',
    payment_settings: { save_default_payment_method: 'on_subscription' },
    expand: [ 'latest_invoice.payment_intent' ],
    ...promotionalCodeId && { promotion_code: promotionalCodeId },
})

return {
    clientSecret: subscription.latest_invoice.payment_intent.client_secret // Cannot read properties of null (reading 'client_secret')"
}
#

So, I guess my question here, is subscription.latest_invoice.payment_intent correct to be null and if so, how should I handle this from the client when I'm trying to confirm the payment through confirmPayment(_:with:completion:)

#

Apologies, I'm a bit of a newbie to this and it's not helped that I'm doing this in NativeScript aha

orchid ermine
#

All good. Since the promo code is for full price of the invoice, I believe there won't be a payment required that means no payment_intent will be created either. So that is expected.

outer minnow
#

Ok, I understand that. The issue I have is it seems to not save the payment method so I'm unable to collect payment for future payments

orchid ermine
#

does that help?

outer minnow
#

So, at the moment this is my flow:

- Setup customer [Backend]
- Initialise Apple Pay [Client]
- Create a subscription / Retrieve existing subscription [Backend]
- Return client secret [Backend]
- Confirm payment [Client]
- Provision access [Client]
#

Would you be able to help me with the new flow please?

#

Also, at the moment I'm only persisting the customerId / subscriptionId in my own database ... What else would I need to perist now as there is mention of a customer ephemeral key

orchid ermine
outer minnow
#

Essentially yes. It's a NativeScript application but I'm interacting directly with STP* ios classes

orchid ermine
#

ah okay, so the guide I shared above uses PaymentSheet ๐Ÿ™‚ which works with more payment methods than just apple pay
Is that something that you'd want to consider or do you just want Apple Pay?

#

I don't know if we have a guide for just Apple Pay ๐Ÿ˜ฆ

outer minnow
#

So, I am (wrongly) using Stripe Elements + Apple Pay as two separate integrations. I'm not really in a position just now to switch out Elements for Payment Sheet

#

Unless you believe it'll be significantly easier for me to do it the Payment Sheet way?

#

Which I'm guessing is this?

orchid ermine
#

to be honest, it is more scalable to go the PaymentSheet way.

outer minnow
#

Ok then. I mean, we do want to look at doing Google Pay next so if PaymentSheet wraps it all into one, I'm up for that

orchid ermine
#

I need to step away soon but @lofty python can help with any follow ups you may have

outer minnow
#

Ok, I'll have a look at that. And, do I handle Coupons outside the sheet?

orchid ermine
#

yup, before presenting the PaymentSheet

#

If you're going with SetupIntent API to save the payment method before creating the subscription then you can pretty much handle it anyway you want as you're basically taking the coupon via some view on client-side and passing it off to your server-side before creating a sub

outer minnow
#

Ok. At the top, where it has "Card" / "iDeal" / "SEPA Debit" ... Can these be removed as we'll only ever need the card option

orchid ermine
#

yup, PaymentSheet is super customizable

outer minnow
#

Ok. Last thing, can the colours of the payment sheet be changed as well?

orchid ermine