#Nyxi
1 messages ยท Page 1 of 1 (latest)
I thouht it was the country of the user, but apparently it's the Stripe account's country
๐ happy to help
Hi!
Yes, that's the Stripe account's country. However, when you initialise the Payment Request, you haven't provided Stripe.js with clientSecret yet, but it already needs the country information to display the Apple/Google Pay pop-up.
Similarly, you might think you have all the information about the purchase in the PaymentIntent, but you still need to type in the amount and the currency when creating a Payment Request. Unfortunately, it's a limitation of how Payment Request works.
Alright, cool. I just wanted to make sure.
Of course. Please, let me know if you have more questions.
I do, actually. Unrelated. If a payment intent is in requires_capture, and I want to move it back to requires_payment_method but without canceling it, how would I do that?
You can just change the Payment Method
Can I do it without having a payment method?
Why would you need it to get to that state?
Because I have a webhook-based flow where the state of the payment intent becomes important. requires_capture means "we are waiting for the webhook to land", so on failure, I would want the webhook to reset the payment intent but not cancel it
And the reason I'm talking about "failure" is because it's a ticketing system, so the webhook must ensure the tickets are still available before it can cmplete the capture
Hi there ๐ jumping in for my teammate as they need to step away soon. You will need to take an action on the Payment Intent that causes the state change, you cannot just change the state. I believe most updates on an intent in that state will move it from requires_capture to either requires_confirmation or requires_payment_method depending on the change.
Thinking through your business use case, if the tickets are not available then what are you hoping to reuse the Payment Intent for?
Yeah I suppose I could just recreate the payment intent if the user wants to try again
I was thinking to just "update the payment itnent with the updated info", but cancel and recreate is also fine
What is the updated information that you have? Does updating the Payment Intent with those details result in the behavior you're looking for?
New ticket reservation attempt would potentially have a new price
But it's fine, I can cancel it
If a payment intent is in requires_capture and I call cancel() on it, there is no realistic scenario where that would fail (bar server error)?
Correct
Okay, thanks
Any time!
/**
* @param PaymentIntent $intent
*
* @return void
* @throws ApiErrorException
*/
private function handleCancelPaymentIntent(PaymentIntent $intent): void
{
try {
$intent->cancel();
} catch (ApiErrorException $exception) {
if ($exception->getError()?->payment_intent?->status !== PaymentIntent::STATUS_CANCELED) {
throw $exception;
}
}
}
So this is a pretty fail-safe way to cancel it, including if multiple sources try at the same time
Or does the API silently do this for you? Assume cancel on already canceled == success ?
That seems fine, but I'm not sure I understand the questions raised in your last message.
I mean if it's just considered a success if you call cancel on an already-canceled intent
Like, if I don't need the above check at all
Oh, gotcha. No, the API will return an error if the intent has already been cancelled.
Alright, cool
If I call capture on a payment intent that is not in requires_capture, I will get payment_intent_unexpected_state, yes?
No Sorry, read too fast, yes.
Great
And canceled is also the only state that will trigger payment_intent_unexpected_state if cancel() is called on a payment intent?
As in, the only un-cancelable state
aside from succeeded
of course
processing also typically blocks cancellation
but for card payments, processing is essentially the same as succeeded, is it not?
This async stuff with tickets is race-condition hell
Yes, card payments know immediately whether they succeed or fail.
ok