#tienbt_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/1217035156028915752
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Sure, seems expected if the payment was off-session. Any declines/3DS requests will transition the PI to requires_payment_method. You'd need to re-confirm the intent, providing payment details again. See: https://docs.stripe.com/payments/paymentintents/lifecycle
If the payment attempt fails (for example due to a decline), the PaymentIntent’s status returns to requires_payment_method so that the payment can be retried.
If you can provide a specific pi_xxx example then I can confirm
yes
Please tell me which API I need to use to check payment status. My case: using paymentIntent and 3DS, thanks
You'd look at the status field on the Payment Intent
Whether that's in a API request response payload or a payment_intent.* event, depends on your integration!
Yes, I know, but in case the 3DS fails or the card has problems, its status is required_payment_method -> This case is payment failure, right?
Did you read the doc I just shared above? Should explain it for you
I read it.
Then you should have your answer
If status = required_payment_method, how do I retry the transaction?
You re-confirm the payment via confirmPaymentIntent with Stripe.js
If I do a retried, its status will be succeed or failed, right? Will the status no longer be requires_payment_method?
No, if it were to decline again it would remain in requires_payment_method
There is no 'failed' status for a Payment Intent
If my system does not perform a retry, how can we confirm that the transaction was unsuccessful?
I will describe my system to you as follows :
- Before entering the card entry screen, I will create an API payment intent call, and I will create a pending transaction on our site.
You'd receive a payment_intent.payment_failed webhook event and the intent will transition to status: 'requires_payment_method'. There'd also be a last_payment_error field on the object: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-last_payment_error
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This should all be easy enough for you to try in test mode with a card that will decline and/or require 3DS that you can fail
- In the general card input screen, I will use the payment element to display the card input form.
- After entering the card and submitting, the payment intent will be confirmed and we handle the following cases:
- If the confirmed payment intent return status is success, we will update the transaction on our system as completed
- If the confirm payment intent returns a status of canceled, we will update the transaction on our system as failed
- If the confirm payment intent returns a failed status, we will update the transaction on our system as failed
- If confirm payment intent returns status as requires_payment_method and last_payment_error exists, we will update the transaction on our system as failed
Could you please advise me on whether this plan is good for us?
If the confirm payment intent returns a status of canceled, we will update the transaction on our system as failed
This will only happen if you explicitly cancel the intent or it 'expires' in a auth/capture scenario
If the confirm payment intent returns a failed status, we will update the transaction on our system as failed
There is no 'failed' status, as I've explained
In any case, you should be using webhook to determine payment outcomes: https://docs.stripe.com/payments/handling-payment-events
This part explains how the intent confirm may fail and how to handle that: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment
Is using weehook a must? We cannot use retrieve for testing.
After entering the card and submitting, the payment intent will be confirmed and we handle the following cases:
If the confirmed payment intent return status is success, we will update the transaction on our system as completed -> ok
If the confirm payment intent returns a status of canceled, we will update the transaction on our system as failed -> can happen
If the confirm payment intent returns a failed status, we will update the transaction on our system as failed -> no happen
Is it right?
It's not a must but it's highly recommended yes as ultimately there's no guarantee your users will be redirected to the return_url after completing the payment (like authenticating with their bank). If you have custom fulfilment logic that runs at the return_url then that may never be triggered
As I said, you should just test out these flows and see how they behave with the test cards. I'm answering the same questions over and over
switch (paymentIntent.status) {
case 'succeeded':
message.innerText = 'Success! Payment received.';
break;
case 'processing':
message.innerText = "Payment processing. We'll update you when payment is received.";
break;
case 'requires_payment_method':
message.innerText = 'Payment failed. Please try another payment method.';
// Redirect your user back to your payment page to attempt collecting
// payment again
break;
default:
message.innerText = 'Something went wrong.';
break;
}
Is this part handle error?
I don't understand the question
This part explains how the intent confirm may fail and how to handle that.
I code by php and vuejs
About BE, I create 2 API
1 API to create payment intent and create transaction in my side.
OK, I'm not sure what you're asking me to be honest
Should the confirm payment intent part be handled in BE or FE?
I need to ask about stripe integration in our system.
The front-end with Stripe.js: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment
Yes, I am processing to confirm payment intent in FE
OK, then I don't understand what question or issue you have
After FE confirms the payment intent, what do we need to do next to update the transaction status in our system?
As I said, you should be handling any fulfilment/post-payment logic with a webhook