#tienbt_api

1 messages · Page 1 of 1 (latest)

lethal hillBOT
#

đź‘‹ 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.

rose gulchBOT
flint prism
#

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

vocal abyss
#

yes

#

Please tell me which API I need to use to check payment status. My case: using paymentIntent and 3DS, thanks

flint prism
#

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!

vocal abyss
#

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?

flint prism
#

Did you read the doc I just shared above? Should explain it for you

vocal abyss
#

I read it.

flint prism
#

Then you should have your answer

vocal abyss
#

If status = required_payment_method, how do I retry the transaction?

flint prism
#

You re-confirm the payment via confirmPaymentIntent with Stripe.js

vocal abyss
#

If I do a retried, its status will be succeed or failed, right? Will the status no longer be requires_payment_method?

flint prism
#

No, if it were to decline again it would remain in requires_payment_method

#

There is no 'failed' status for a Payment Intent

vocal abyss
#

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 :

#
  1. Before entering the card entry screen, I will create an API payment intent call, and I will create a pending transaction on our site.
flint prism
# vocal abyss If my system does not perform a retry, how can we confirm that the transaction w...

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

#

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

vocal abyss
#
  1. In the general card input screen, I will use the payment element to display the card input form.
#
  1. After entering the card and submitting, the payment intent will be confirmed and we handle the following cases:
  2. If the confirmed payment intent return status is success, we will update the transaction on our system as completed
  3. If the confirm payment intent returns a status of canceled, we will update the transaction on our system as failed
  4. If the confirm payment intent returns a failed status, we will update the transaction on our system as failed
  5. 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?

flint prism
#

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

vocal abyss
#

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?

flint prism
#

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

flint prism
vocal abyss
#

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?

flint prism
#

I don't understand the question

vocal abyss
#

This part explains how the intent confirm may fail and how to handle that.

flint prism
#

Sure, seems reasonable

#

Did you test it?

vocal abyss
#

I code by php and vuejs

#

About BE, I create 2 API

#

1 API to create payment intent and create transaction in my side.

flint prism
#

OK, I'm not sure what you're asking me to be honest

vocal abyss
#

Should the confirm payment intent part be handled in BE or FE?

#

I need to ask about stripe integration in our system.

flint prism
vocal abyss
#

Yes, I am processing to confirm payment intent in FE

flint prism
#

OK, then I don't understand what question or issue you have

vocal abyss
#

After FE confirms the payment intent, what do we need to do next to update the transaction status in our system?

flint prism
#

As I said, you should be handling any fulfilment/post-payment logic with a webhook