#nick_api

1 messages ¡ Page 1 of 1 (latest)

pine oreBOT
#

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

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

cunning sable
#

Hi jack again!

warm hatch
warm hatch
#

Hmm, why is your frontent calling the checkout sessions API?

#

What's the code in Payment.html:357?

cunning sable
#

here is what i am calling

https://api.stripe.com/v1/checkout/sessions/${customerid}

warm hatch
#

No you should only retrieve the checkout session from your backend with your API key.

cunning sable
#

do you have an exmaple?

warm hatch
pine oreBOT
cunning sable
#

Oh wait

#

Yea done that.

thorny pelican
cunning sable
#

"Unrecognized request URL (POST: /v1/checkout/sessions/). If you are trying to list objects, remove the trailing slash. If you are trying to retrieve an object, make sure you passed a valid (non-empty) identifier in your code. Please see https://stripe.com/docs or we can help at https://support.stripe.com/."

Explore our guides and examples to integrate Stripe.

thorny pelican
#

the error message seems pretty self explanatory, is there something specific that you have a question about?

cunning sable
#

So i am confused.

thorny pelican
#

can you paste the line of code that is throwing that error here

cunning sable
#
        try {
          const sessionResponse = await fetch(`https://api.stripe.com/v1/checkout/sessions/${customerid}`, {
            method: "GET",
            headers: {
              "Authorization": `Bearer sk_test_KEYHERE`,
              "Content-Type": "application/x-www-form-urlencoded",
            }
          });

          const sessionResult = await sessionResponse.json();
          console.log(sessionResult);```
thorny pelican
#

is there a reason why you are you using fetch, and not one of the stripe SDKs? If you try and log customerid before the try catch block, what do you get?

cunning sable
thorny pelican
#

we have a stripe-node SDK : https://github.com/stripe/stripe-node. It's ultimately up to you, but I strongly recommend using the stripe-node library instead of rolling your own. The library is basically a wrapper for the underlying HTTP requests with some useful features like automatic retries, idempotency keys and robust error handling. You could roll your own, but you'd be reinventing the wheel and would be opening yourself up to all sorts of unhandled edge cases and increasing problems as your integration gets more complex.