#red_error

1 messages ยท Page 1 of 1 (latest)

wooden falconBOT
#

๐Ÿ‘‹ 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/1384150438483333120

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

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.

astral mortar
#

๐Ÿ‘‹ happy to help

#

please share your code

rose hatch
#

hi - the whole thing, or just a section?

astral mortar
#

the part where it's failing

rose hatch
#

do you see it above?

astral mortar
#

that doesn't have .type

rose hatch
#
  console.log("in handleSubmit with e: " + e);

  e.preventDefault();
  setLoading(true);

  const { error } = await stripe.confirmPayment({
    elements,
    confirmParams: {
      // Make sure to change this to your payment completion page
      return_url: "http://localhost:4242/complete.html",
    },
    redirect: 'if_required'
  });

  // This point will only be reached if there is an immediate error when
  // confirming the payment. Otherwise, your customer will be redirected to
  // your `return_url`. For some payment methods like iDEAL, your customer will
  // be redirected to an intermediate site first to authorize the payment, then
  // redirected to the `return_url`
  console.error("error encountered after submit: " + error);
  if (error.type === "card_error" || error.type === "validation_error") {
    showMessage(error.message);
  } else {
    showMessage("An unexpected error occurred.");
  }

  setLoading(false);
}```
#

it drops through to console.error("error encountered after submit: " + error);

#

even though error is undefined

#

because of the integration requirements from GoHighLevel I have to run this in an iframe, so I cannot redirect

astral mortar
#

this means that error is null

#

because the confirmPayment succeeds

rose hatch
#

how should I handle successful transaction in this case

#

this is the Stripe code I copied - do I just need to check for null error and continue?

astral mortar
#

I would just add a ? for null coalescing error?.

rose hatch
#

ok. Is there any built in code to display success confirmation?

#

in the JS you provide?

#

I just added the debug statement: console.error("error encountered after submit: " + error); but will drop down into the error IF statement

astral mortar
#

I'm suggesting doing this

    showMessage(error.message);
  } else {
    showMessage("An unexpected error occurred.");
  }
rose hatch
#

ok - but then it will just show An unexpected error occurred. when the payment is successful?

astral mortar
#

then there's another error happening

#

would you mind sharing the PaymentIntent ID you're confirming?

rose hatch
#

sure - 1 sec

#

what should happen if the payment is successful in that code? If redirect is set off, it will just drop into that error section, no?

astral mortar
#

no it would go to the else block

#

ohhhhh!

#

I see what you mean

#

you need to check if the error is null then you consider the payment to be successful otherwise you would go through the if/else code without the ?.

wooden falconBOT
rose hatch
#

right!

#

is there a JS funtion in your JS package to display confirmation though?

#

"id": "pi_3Race4BBPymgN3Ps1DZTf5wP"

#

I just added check for null - no error now obviously, but page just sits there

#

I need to show successful payment details

sullen vortex
#

Hi, taking over as my teammate needs to step away. Let me catch up.

rose hatch
#

hello!

#

thanks

#

I can't redirect as I am forced to run in iframe due to GoHighLevel integrations

#

the payment is succcessful, I'm just trying to figure out how to show successful payment in the UI - is there a method to call?

sullen vortex
rose hatch
#

they do have their own integration ,but it doesn't meet our needs for surcharging

#

the return URL won't work in an iframe though, right?

sullen vortex
#

Looking still

rose hatch
#

thanks!

sullen vortex
#

Ok, on that page, we state 'Avoid placing the Payment Element within another iframe because some payment methods require redirecting to another page for payment confirmation.'. What you're looking for is not supported

rose hatch
#

well - I'm not using the payment methods that require redirecting

#

even if I redirect, though, how do I get the info on the successful payment?

sullen vortex
#

We document that on that same step: 'Use one of the query parameters to retrieve the PaymentIntent. Inspect the status of the PaymentIntent to decide what to show your customers.'

rose hatch
#

ah ok

#

can I grab the PaymentIntent on the original page?

sullen vortex
#

I'm unsure what 'original page' means, but you can retrieve the PI using your publishable key on your client-side.

rose hatch
#

the page the above code is on - but that works, thanks!