#maddockst-apple-pay-ios
1 messages ยท Page 1 of 1 (latest)
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
No rush. Thanks for the quick reply!
can you share the example PaymentIntent ID or the subscription ID?
The test subscription ID is sub_1LZbzmHM14YvCzvfaBqAVqpc
Weirdly, the membership appears to be active but I still get that error
huh I'm trying to look for the request throwing 402: Payment Required error but I'm not finding it.
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
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.
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
hmm yeah thinking of an alternative, You could alter your flow a bit to use SetupIntents API which would setup the payment method before creating a subscription
https://stripe.com/docs/payments/save-and-reuse
does that help?
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
Just so that I'm on the same page, you're implementing native Apple Pay integration right?
https://stripe.com/docs/apple-pay
Essentially yes. It's a NativeScript application but I'm interacting directly with STP* ios classes
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 ๐ฆ
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?
to be honest, it is more scalable to go the PaymentSheet way.
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
Awesome! yeah the guide I linked above is pretty detailed.
Edit: this one ๐ https://stripe.com/docs/payments/save-and-reuse
I need to step away soon but @lofty python can help with any follow ups you may have
Ok, I'll have a look at that. And, do I handle Coupons outside the sheet?
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
Ok. At the top, where it has "Card" / "iDeal" / "SEPA Debit" ... Can these be removed as we'll only ever need the card option
yup, PaymentSheet is super customizable
Ok. Last thing, can the colours of the payment sheet be changed as well?
You can choose payment_method_types when you create SetupIntent
https://stripe.com/docs/api/setup_intents/create#create_setup_intent-payment_method_types
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ok. Last thing, can the colours of the payment sheet be changed as well?
I believe so, You can find the customization options here
https://stripe.com/docs/payments/save-and-reuse?platform=ios&ui=payment-sheet#customization