#sreekanth_api
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/1232622610081124475
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- sreekanth_api, 20 minutes ago, 33 messages
- sreekanth_api, 1 day ago, 80 messages
- sreekanth_api, 2 days ago, 46 messages
hi
hi there!
are you using Checkout Session? and you want to prefill the card of the user?
The issue arises from our current flow: users add their card details to Stripe, and during payment, we present their saved cards for selection. Once a card is selected and the user clicks submit, we handle the payment on the backend. However, we face a challenge with secure payments that require authentication, as we cannot complete the transaction until authentication is successfully completed
how are you accepting payments? Checkout Session, Payment Element, something else?
we are adding the card details to the stripe during signup and we are using the same for payment...
can you answer my question above?
customer = await stripe.customers.create({
payment_method: req.body.paymentMethod
});
// List the customer's payment methods to find one to charge
const paymentMethods = await stripe.paymentMethods.list({
customer: customer.id,
type: "card"
});
// Create and confirm a PaymentIntent with the order amount, currency,
// Customer and PaymentMethod ID
paymentIntent = await stripe.paymentIntents.create({
amount: calculateOrderAmount(),
currency: "usd",
payment_method: paymentMethods.data[0].id,
customer: customer.id,
off_session: true,
confirm: true
});
res.send({
succeeded: true,
clientSecret: paymentIntent.client_secret,
publicKey: process.env.STRIPE_PUBLISHABLE_KEY
});
so you are using the PaymentIntent API, got it.
const token = await stripe.tokens.create({
card: {
number: req.body['card[number]'],
exp_month: req.body['card[exp_month]'],
exp_year: req.body['card[exp_year]'],
cvc: req.body['card[cvc]'],
name: req.body.cardholder_name,
},
});
const card = await stripe.customers.createSource(
customer.id,
{ source: token.id }
);
console.log("carddetails",card);
const updatedCustomer = await stripe.customers.update(customer.id, {
invoice_settings: {
default_payment_method: card.id
}
})
wait why are you using Tokens? this is a very old integration that we don't recommend using.
yes, this is old code....
However, we face a challenge with secure payments that require authentication, as we cannot complete the transaction until authentication is successfully completed
When 3DS is required, you have to tell your customers to come back to your website, and there confirm the PaymentIntent on the frontend to trigger 3DS.
as you can see code we are collecting the card details and attaching to the customer... and we are using the same for payment...
Since we are directly handling payments in the backend, the issue we are facing pertains to authenticated payments
Since we are directly handling payments in the backend, the issue we are facing pertains to authenticated payments
yes, I explains above how to handle this
and this is covered here: https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
currently we are showing saved cards in the custom ui and making payments directly in the backend...
yes I know.
If we use payment elements or checkout, will saved cards be displayed?
are you asking a different question now? so your previous issue is resolved?
No, if we use payment elements or checkout, authentication for payment will be handled in the frontend. However, based on my observation, saved cards will not be displayed in the payment elements or checkout.
understood ?
you are mixing completely different issues here.
- if you want to confirm the payment on the backend, that is possible! you just need to handle the case where 3DS is requested (as I explained previously)
- if you don't want to confirm the payment on the backend, then you can confirm it on the frontend (this is the recommended flow).
so which option do you want?
If we use payment elements or checkout, will saved cards be displayed?
Checkout can display a saved card yes. Not with Payment Element currently, but you could build your own UI for this.
for Checkout Session this is explained here: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-customer
I have checked the documentation. If we notify the user, which page should we show to them?
do we have any demo link?
you build your own customer page that calls this method: https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-attached
This means that we will notify the user to open the app, where we will display a popup with the same payment intent secret. The user can then accept it
correct. and when you call the function above, the 3DS flow will start.
Are there any restrictions, such as needing to display it within the same domain?
no, as long as you use the correct Stripe API key
so, we can send emails to that action ?
like we can show that custom ui in the email itself
I'm not sure I understand. but yes you can send your own emails, with a link to your website, that then calls stripe.confirmCardPayment().