#tyler_code

1 messages ¡ Page 1 of 1 (latest)

runic cliffBOT
#

👋 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/1336357689915347016

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

teal shuttle
#

hey there, taking a look at this!

#

Ah, we don't recommend using redirectToCheckout({ sessionId }); any longer

#

Instead, the session object has a url you can redirect your customers to without using Stripe.js

oak moat
#
    try {
      const response = await fetch("/api/create-checkout-session", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({ priceId }),
      });

      const { sessionUrl, error } = await response.json();

      console.log(response);

      if (error) {
        console.error("Error creating checkout session:", error);
        return;
      }

      window.location.href = sessionUrl;
    } catch (error) {
      console.error("Error during subscription:", error);
    }
  };
#

Like this?

teal shuttle
#

Yep!