#cnguyen - Refunds
1 messages ยท Page 1 of 1 (latest)
And, to be sure, the webhook for that (when stripe.confirm is OK but the bank network don't send a pi.succeeded but an error) is pi.payment-failed?
Hello! Not sure I understand, if the Payment Intent fails there's nothing to refund because you didn't get the funds. Can you provide more details?
I know that it's possible to have, in front, stripe.confirm that send me OK. Then, later, I receive normally a pi.succeeded but, sometimes, it could be a pi.payment-failed. No?
You're talking about the payment_intent.payment_failed event, correct?
yes
That event indicates the payment failed, meaning you didn't get any money, so there's nothing to refund.
Or what is the opposite webhook of pi.succeeded? It's payment_failed? Or maybe it's pi.cancelled?
Ah sorry I spoke about refund a customer to simplify the explanation but it's not true. In reality, I create a pending order in my CMS when I receive the stripe.confirm. And I want to handle the case where, I receive, after, a failed (and not a success) to delete the order ^^
Okay, so what's your question? You want to simulate a failed payment in test mode?
yes
Have a look at the test cards here: https://stripe.com/docs/testing#declined-payments
And I want to be sure that I have to handle payment_failed only? Webhook pi.canceled is not needed I think. Right? Or I can have also a stripe.confirm, then a pi.canceled?
I'm not sure, it depends on what you're trying to do exactly. Is the scenario that you're creating a Payment Intent, creating a pending order in your system, then when you get back events from the Payment Intent you want to decide if you should cancel the pending order or fulfill it?
Yes. I create the pending order when stripe.confirm (in front) confirm me the pi. Then, I update the order status from pending to processing if I receive the pi.succeeded webhook event. And I want to find the opposite, when it's not a pi.succeeded. In order to update the order status fron pending to canceled.
You may not ever get an event for that. If the customer leaves without doing anything no further events will fire, so you'll probably want some kind of timeout process on your end that triggers cancellation of both the Payment Intent and the pending order.
Does that make sense?
I though that the failed is like the succeeded. So it's async and allow to avoid the problem when the user left
for example, the confirm is sync. But I double check with the succeeded event
payment_intent.payment_failed fires when the customer attempts a payment and that attempt fails. For example, if I tried to pay $100 but I only had $50 available the payment would fail due to insufficient funds and a payment_intent.payment_failed event would fire.
But if the customer does not attempt to pay at all no event will fire.
But when I test the cards that you gave me. It's like the failed is synchronous. It's the error event on stripe.confirm sync event
So my problem si not the failed because, if the confirm send me a failure, I will not create the pending order
Sorry, I think we might be talking past each other. Can you give me very specific details about exactly what you're doing and what's happening that you do not expect?
OK
So, in the front part, I confirm a given PI. To do that, I wait the answer from the stripe.confirmCardPayment. If it's a failed. I do nothing and stop the shopper. If it's a success, I create a pending order.
Then... when I receive the async event 'payment_intent.succeeded'. I update the order the status from pending to processing. Because, Stripe said to me that I can't trust only confirmCardPayment.
Okay, let's back up a bit.
So, now, I want to handle the case if there is an error. But maybe, it's not possible to have, in first, a success from confirmCardPayment then, after, a pi failed event asynchronous
But if Stripe said to me to double check with async event 'payment_intent.succeeded'. I supposed that there is a way to don't have a success.
stripe.confirmCardPayment will not always trigger your client-side code after the payment succeeds. If, for example, someone attempts to pay, 3D Secure is triggered, the customer successfully authenticates, and then drops off before the rest of your code runs the only indication you will have that you got paid is the payment_intent.succeeded event. Are you creating pending orders as a result of payment_intent.succeeded, or only client-side after you get a result back from stripe.confirmCardPayment?
The both. To avoid this problem. I create the pending order with the confirmCardPayment but, if I only receive the payment_intent.succeeded, I will create the order too (if I see that the order wasn't created previously)
Yes ^^
There are two different situations, as far as I understand it:
- The customer attempts to pay, and the payment fails.
- The customer never attempts to pay
Are you asking about one of those or both of those?
- Yes, for this case, I block him, I display an error message and I do nothing (I don't create the order because I don't have a successful confirmCardPayment and I will not receive 'payment_intent.succeeded'
Both, to be sure
To clarify, you're only creating a pending order after stripe.confirmCardPayment succeeds or when you get payment_intent.succeeded, correct?
- I don't see the case. I the user never attempts. I will never have a confirmCardPayment, and I will not receive ''payment_intent.succeeded''. SO I will never create the order and is good too
correct
OK. So I'm looking for something that doesn't exist ๐
I was confused because of the 'payment_intent.succeeded'. I though that it was possible to have a successful confirmCardPayment then, an error after ^^
Oh, you thought stripe.confirmCardPayment could indicate the payment failed succeeded, but then you would get a payment_intent.payment_failed event?
Err...
Because, for me, if the event 'payment_intent.succeeded' exists. So there is the case that the failed it's possible too. But not in my case
Edited the message above.
No. I thought stripe.confirmCardPayment could indicate the payment succeeded, but then you would get a payment_intent.payment_failed event
Yes it's that
Yes, okay. So that's a bit tricky, actually.
or a canceled
https://stripe.com/docs/payments/payment-intents/verifying-status => because I read that
Normally, that won't happen. However, stripe.confirmCardPayment happens client-side, so the customer/user can alter the code and make it do whatever they want. Thus, you could potentially have the scenario described above if someone was messing around or being malicious. In order to guard against that what you should do is, when stripe.confirmCardPayment appears to succeed, ask your server to fetch the Payment Intent from the API and confirm it actually succeeded, then proceed from there.
But I think that it's for subscription or off_session pi
To clarify, what I recommend is confirming the Payment Intent has actually been successfully paid server side. Do not trust only your client-side code before you do anything like fulfill an order.
Because client-side code can be altered and can't be trusted.
Yes. This part is good because of 'payment_intent.succeeded'
And, it means that I don't have to handle the 'pi.canceled' or the 'pi.payment_failed' because, it means that I don't create the order.
Yep!
thank you. It was a very interesting discussion ^^