#michael-ece-handleerrors

1 messages · Page 1 of 1 (latest)

halcyon sailBOT
#

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.

warm sage
#

👋 @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.

covert sinew
#

ECE

warm sage
#

Please try and provide clear details all in one clear self contained message instead of just one answer

covert sinew
#

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;
warm sage
#

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

covert sinew
#

yesh

#

correct

#

if this holdTicketsAndCreateOrderFromCart(); fails, can we close the google pay/apple pay modal? or throw the error inside it?

warm sage
#

Gotcha, let me have a look

covert sinew
#

thanks

warm sage
#

no

#

Sorry we help in real time here and I can't follow up individually with you

covert sinew
#

ok

#

im still here

#

any updates?

warm sage
#

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

halcyon sailBOT
covert sinew
#

ohh, ok

#

let me try this

warm sage
#

@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.

covert sinew
#

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?

warm sage
#

if you just want to show the error in the popup and not close it you can use event.paymentFailed()

covert sinew
#

can i pass the error message into event.paymentFailed()?

warm sage
#

no I don't think that's possible either sorry

covert sinew
#

yeah, so it wouldnt tell the user why it failed

warm sage
#

correct, the unmount + your own modal/alert is likely the cleanest for you here