question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IntegrationError from Stripe when using redirectToCheckout

See original GitHub issue

version: “3.0.0-beta.2”

What is the issue?

when I use redirectToCheckout, it would throw this error

Error

My Code

  ...
  // use-shopping-cart hook
  const {
    totalPrice,
    cartCount,
    clearCart,
    cartDetails,
    redirectToCheckout,
    addItem,
    removeItem,
  } = useShoppingCart();

  // Detect if the cart is empty
  useEffect(() => {
    setCartEmpty(!cartCount);
  }, [cartCount]);

  const handleCheckout: React.FormEventHandler<HTMLFormElement> = async (event) => {
    event.preventDefault();
    setLoading(true);

    const response = await fetchPostJSON('/api/checkout_sessions/cart', cartDetails);

    if (response.statusCode === 500) {
      console.error(response.message);
      return;
    }

    console.log(response);

    redirectToCheckout({ sessionId: response.id });  // <- this is the line that throws the error
  };
 ...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
andria-devcommented, Mar 9, 2021

Oh okay, my bad. If you could create a GitHub Release with a list of all the changes to the React API for the beta version it would help people checking out the beta version by letting them know what’s going on @dayhaysoos.

0reactions
andria-devcommented, Mar 21, 2021

@dayhaysoos We should definitely add a warning when stripe is not of type string that tells them that use-shopping-cart will takes the public API key itself and will do the loading of Stripe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

stripe.redirectToCheckout: Invalid value for sessionId. You ...
Stripe has problem: Uncaught IntegrationError: stripe. ... I tried to define an json object and use session.id but still doesn't work.
Read more >
Redirect to Checkout - Stripe JS Reference
Use stripe.redirectToCheckout to redirect your customers to Checkout, a Stripe-hosted page to securely collect payment information.
Read more >
Checkout migration guide | Stripe Documentation
Learn how to migrate from the legacy version of Checkout to the current version.
Read more >
Checkout prices migration guide | Stripe Documentation
Learn how to update your integration to use prices with Stripe Checkout. The Prices API adds new features and flexibility to how you...
Read more >
stripe.confirmPayment - Stripe JS Reference
Use stripe.confirmPayment to confirm a PaymentIntent using data collected by the Payment Element. When called, stripe.confirmPayment will attempt to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found