#kun_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/1339021604885106809
đ 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.
- kun_api, 8 hours ago, 23 messages
Hello! 3D Secure and other required next actions would be handled in step #6 of that guide, when you conditionally call stripe.handleNextAction if needed: https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=payment&client=html#next-actions
app.post('/create-confirm-intent', async (req, res) => {
try {
const intent = await stripe.paymentIntents.create({
confirm: true,
amount: 1099,
currency: 'usd',
// In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default.
automatic_payment_methods: {enabled: true},
confirmation_token: req.body.confirmationTokenId, // the ConfirmationToken ID sent by your client
});
res.json({
client_secret: intent.client_secret,
status: intent.status
});
} catch (err) {
res.json({
error: err
})
}
});
this step will send me client_secret so I can use in stripe.handleNextAction ??
Yep.
further more
this.stripeService
.confirmCardSetup(this.clientSecret, {
this stripe method also do the 3D verification
so what is the difference between these two fucntions?
confirmCardSetup is not related to the guide you're using. It's used to confirm a Setup Intent with a card, which is not what you're doing.
ohhh got it
You can read more about that function here: https://docs.stripe.com/js/setup_intents/confirm_card_setup
you are right I am using setpintent and then confirm it
Sorry, not sure I understand. The guide you linked to uses Payment Intents, not Setup Intents.
a quick question
stripe createConfirmationToken method will it send me error if someone add dummy card instead of confirmation token?
and this is how I can validate the card right?
I got your point
Let's back up a bit. Can you tell me, at a high level, what you're trying to build?
I am trying to setup one time payment using stripe card elements on frontend end
and on server side I am using payment intent
What do you mean by "setup" exactly? Are you trying to take an immediate one-time payment now, or are you trying to save payment info now and make the payment later?
what I exactly wanted is
the client adds its card information then I using this card information customer pay the bill immediatly
And do you want to save the payment info for later use, or only use it once for this one payment?
I will save the card details including
paymentMethodId for later use as well
Okay, and do you want to build a custom payment form on your own site for this, or do you want to use Stripe's page for this? The latter is easier and quicker to build.
No I will use custom business logic and will do it from my server
What specific custom business logic do you need?
Once the card information I get from the stripe element and one they are validate
I will use them to pay the bill for the user . tht is why I am using payment setup intent at backend
and then pass the client secret to frontend again for the 3D
Wait, I think there's a misunderstanding. Are you trying to perform 3D Secure as a separate step from the payment step?
I am following this guide
https://docs.stripe.com/payments/finalize-payments-on-the-server?client=html
and the 3D verification is in step 6
Yeah, don't worry about that for now. I'm asking you what you want to build so I can tell you if it's possible or not, and if it is possible point you to the right guide.
In order to do that I need to understand what custom business logic you need.
I also need to understand how you're thinking about 3D Secure and the payment steps.
ok let me summarize it
User comes to my application buy 12 usd product
by click on pay its card will be charged 12 usd and then he can confrim it using 3D
That's not how it works. 3D Secure happens during the payment process, before the payment happens, it doesn't happen after the payment.
so what this method do
stripe.handleNextAction(
which is in step 6
On that guide, in step #5, you attempt to collect the payment. If the payment requires a next action, like 3D Secure, the Payment Intent will go into a status of requires_action which means the payment hasn't happened yet, and the required action needs to be handled first. At that point you send the client secret to your frontend and call stripe.handleNextAction to have the customer handle the next action. If that next action succeeds only then does the payment go through.
what are the other statuses I can get except for require_action
A Payment Intent can have any of these statuses: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-status
except for succeeded and canceled
all other status will have client secret?
I mean thses statuses
processing
requires_action
requires_capture
requires_confirmation
requires_payment_method
You don't really need to worry about all of those statuses at this point in this particular flow. What I'm still not clear on is the custom business logic you mentioned earlier. Can you tell me more about that?
The business logic is to just charge the customer with 3D
Oh, okay, so you don't need to use this flow at all, which is more complex than required for your use case.
so what flow I should use then?
I reccommend you follow this guide instead: https://docs.stripe.com/payments/save-during-payment
That takes a payment and saves the payment info for future use. It handles 3D Secure and everything as well.
An even easier approach would be to use Stripe Checkout, as either a hosted page you redirect to or an embedded form on your website: https://docs.stripe.com/payments/checkout/save-during-payment
I recommend that unless you really need the more custom flow above.
I went through this guide quickly
can you tell me the difference
and why this is more suitable for my task?
const {error} = await stripe.confirmPayment({
//`Elements` instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
and on the frontend why is method not taking client_secret from payment intent as a parameter?
The https://docs.stripe.com/payments/save-during-payment guide uses the Payment Element and is more flexible and customizable, but is also more complex and requires more effort to build and maintain. The https://docs.stripe.com/payments/checkout/save-during-payment guide uses Stripe Checkout, which offloads a lot of the work to Stripe, but at the cost of being a bit less customizable.
The guide you were originally using is designed for use cases where people want to examine the payment details inside the Confirmation Token before proceeding. It's more of an advanced flow designed for companies who do things like special logic to determine if a payment should even be attempted or not.
so I should follow this guide?
My primary recommendation is to use Stripe Checkout and this guide: https://docs.stripe.com/payments/checkout/save-during-payment
If you don't want to use Stripe Checkout then https://docs.stripe.com/payments/save-during-payment would be my recommendation.
yes because our appliation requirements dont allow us to use stripe checkout directly
Why?
I dont knwo
its client requirements
a quick question
once the card details are saved
the guid you recommend me https://docs.stripe.com/payments/save-during-payment
for next payment i should only use payment method id right?
Yep. Using the saved payment info later is covered in step #7 of that guide: https://docs.stripe.com/payments/save-during-payment#charge-saved-payment-method
No problem!
you have guided me well