#michael-ece-handleerrors
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- michael_19345, 6 hours ago, 5 messages
- michael_19345, 3 days ago, 16 messages
- michael-ece-link, 3 days ago, 15 messages
- michael_19345, 4 days ago, 3 messages
- michael_19345, 4 days ago, 6 messages
- michael_19345, 4 days ago, 24 messages
and 2 more
👋 @covert sinew can you try and provide a lot more details about your question's context like what exact integration path you use, which product (ExpressCheckoutElement, PaymentElement, PaymentRequestButton, other?) and what part of the code would error, what you did/before after, etc.
ECE
Please try and provide clear details all in one clear self contained message instead of just one answer
at the minute this function is failing: await holdTicketsAndCreateOrderFromCart();
when this throws an error i want to close the google pay popup and show a custom error modal? or, show the serverside error inside the google pay popup if possible?
expressCheckoutElement.on('confirm', async () => {
const { error: submitError } = await this.elements.submit();
if (submitError) {
rootState.hasError = true;
rootState.dialogTitle = 'Error';
rootState.dialogErrorMsg = submitError?.message;
return;
}
try {
// Create the PaymentIntent (returns the clientSecret), Hold tickets and Create Order
await holdTicketsAndCreateOrderFromCart();
} catch (error) {
throw new Error(error);
}
const confirmOptions = {
elements: this.elements, // `elements` instance used to create the Express Checkout Element
clientSecret: cartState.stripePaymentIntentClientSecret, // `clientSecret` from the created PaymentIntent
redirect: this.confirmRedirect,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: 'http://localhost:3333/index.html',
},
} as any;
if (this.confirmRedirect === 'always') {
confirmOptions.confirmParams = {
return_url: this.confirmURL,
};
}
const resp = await this.stripe.confirmPayment(confirmOptions);
const { error } = resp;
Okay so you're inside the confirm callback and you get an error before you call confirmPayment() likely at the step where you get to your server to create the PaymentIntent, hold inventory, etc.?
michael-ece-handleerrors
yesh
correct
if this holdTicketsAndCreateOrderFromCart(); fails, can we close the google pay/apple pay modal? or throw the error inside it?
Gotcha, let me have a look
not yet
@covert sinew okay the only way we know is to basically unmount the element which woul work. You can then remount if needed but I assume you wouldn't since you don't have any inventory left
There doesn't seem to be another way
@covert sinew I've confirmed that there's no other solution unfortunately today to just dismiss the sheet. It'll be a feature request we'll track but won't happen soon as you're the first person asking for this.
ok
thanks
unmounting works for now
need to remount when the custom modal is closed though
there is no way to bubble up the error message so it shows in the popup?
if you just want to show the error in the popup and not close it you can use event.paymentFailed()
can i pass the error message into event.paymentFailed()?
no I don't think that's possible either sorry
yeah, so it wouldnt tell the user why it failed
correct, the unmount + your own modal/alert is likely the cleanest for you here