#shahin_paymentelement-applepay
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1299116373057736835
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
shahin_paymentelement-applepay
@jaunty saddle I don't really understand the question. If you use SetupIntent it's to collect payment method details for later. So there's no payment amount to show since you are not charging them
My flow is like:
user selects products they like and when try press purchase
- I call
createPaymentMethodto get apm_xtoken - client-side - Create a customer and attach the created payment method to the customer - backend
- Create a payment intent like - backend
paymentIntent = await this.stripe.paymentIntents.create({
customer: customerId,
amount: amount,
currency: currency,
confirm: true,
payment_method: paymentId,
payment_method_types: ['card'],
capture_method: 'manual',
confirmation_method: 'manual',
setup_future_usage: 'off_session'
});
So in short the total is known right before user click the Purchase button, is there any way to tell ApplePay to know what amount to show?
No, and really the flow you have is definitely incorrect
On top of using confirmation_method: 'manual' which is really problematic for many reasons
The correct flow would be https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment which is basically
- Render PaymentElement with the right amount but no PaymentIntent yet
- Create a ConfirmationToken (which will support ApplePay + showing the right amount)
- Go to your server, create and confirm the PaymentIntent (what you already do)
- Optionally go back client-side if something extra is needed such as 3DS
Please correct me if I am wrong, in my flow I need to replace createPaymentMethod with createConfirmationToken, right? Or would this require some back-end changes too?
I have a single page checkout form, so I need to re-instantiate PaymentElement every time user adds something to basket, right?
Could you please eloborate on backend changes too?
You don't reinstantiate no, you update your existing instance see https://docs.stripe.com/js/elements_object/create_without_intent and then https://docs.stripe.com/js/elements_object/update when you change the amount
And really this is quite subtle. My advice is to try the guide I gave you on its own end to end instead of trying to shoehorn it in your existing complex code, especially as you are using confirmation_method:'manual' which has its own problems
All right! Thank you for the help! Would you mind leaving this thread open for a few days, so I can contact if I have further questions.
I'm sorry but threads here are short lived as we help hundreds of people in real time every week.
If you have a follow up question you can start a new thread and whomever is available on my team at that time can help you further!
got you. Thank you very much!