#astrodude42_best-practices

1 messages Ā· Page 1 of 1 (latest)

shy rootBOT
#

šŸ‘‹ 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/1219205089714114590

šŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

dull coveBOT
granite anvil
#

Is the question about how to display saved payment methods in payment element?

sleek pine
#

Thanks for the quick response! The question is about how to use the data provided by our backend (mentioned above) with the credit card information entered by a user (using a custom form made of Stripe Elements) and complete the payment on the web, using StripeJS API

granite anvil
sleek pine
#

Thanks for leading me to this page. I read about the Payment Element. Unfortunately, the customer i work for wants a custom form design made up of Stripe Elements, not the Payment Element. Would that be possible at all?

granite anvil
shy rootBOT
sleek pine
#

No, i wasn't aware of Card Element. Currently, every credit card payment form on our side is strictly made with Stripe Elements API. I.e.

import { loadStripe } from '@stripe/stripe-js'

const stripe = await loadStripe(STRIPE_PUBLIC_KEY)
const stripeElements = stripe.elements({
  …,
  clientSecret,
})

const cardNumber = stripeElements.create('cardNumber', …)
const cardExpiry = stripeElements.create('cardExpiry', …)
const cardCvc = stripeElements.create('cardCvc', …)

cardNumber.mount(`#cardNumber`)
cardExpiry.mount(`#cardExpiry`)
cardCvc.mount(`#cardCvc`)
sinful wedge
sleek pine
#

Hi šŸ™‚

#

ok, what about the general goal of implementation to replicate StripePaymentSheet from the Stripe iOS SDK which doesn't exist in StripeJS? Our backend creates the PaymentIntent and provides the data which is necessary for the iOS StripePaymentSheet (clientSecret, customerId, ephemeralKey and paymentIntentId). How can i reuse that data in the StripeJS API? Because this data identifies the PaymentIntent that needs to be completed by the web-UI.

sinful wedge
#

How can i reuse that data in the StripeJS API?
In stripe Js you don't need to use the ephemeralKey, you need just the payment_intent.client_secret
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements
if i were to create a SetupIntent instead of a PaymentIntent and use our custom Elements form, i would use confirmCardSetup
You need to use confirmSetup:
https://docs.stripe.com/js/setup_intents/confirm_setup
I strongly recommend you to follow this guide:
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
What would be the equivalent for PaymentIntent?
Just follow the same guide above, you need to use confirmPayment
https://stripe.com/docs/js/payment_intents/confirm_payment
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements

sleek pine
#

thank you very much! i guess that's what i was missing. will look into it right now and come back later if there are any related questions