#coldrain
1 messages · Page 1 of 1 (latest)
Hi, can you add more details here so I can best assist. Are you intending to retrieve the Checkout Session by the Session id?
no, I need to fetch info about that checkout, I've got an id after checkout.
What information are you looking for? What are you really trying to do with it?
I need this
So that API is referring to our Issuing. The Checkout API: https://stripe.com/docs/api/checkout/sessions is separate and represents a customer's session as they pay for a transaction. Is this, https://stripe.com/docs/api/checkout/sessions/retrieve what you're looking for?
oh,yes
I've tested it with by a web and everything is working, but I don't know how to write my backend js file for this
Can you take a look?
What do you have so far? We same sample codes on the right, https://stripe.com/docs/api/checkout/sessions/retrieve
You're not getting what? You're not retrieving the Checkout Session so I'm a bit lost.
result
Let's back out, what do you want to see? Can you provide me more details on what you expect your code to do?
That is so much clearer thank you, can you share the request id with me for when you see this error? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Under the Method > is GET included?
I'm looking further here
Yeah, I see that here: https://dashboard.stripe.com/test/logs/req_szOxdxafjuDYCg . It looks like you're passing passing checkout.session and not the value.
Looking at your code further
If you just console.log(req.body.id) what do you get?
no, I'm passing everything right
can you console.log(req.body.id) please and share what it's logging?
From the error, https://dashboard.stripe.com/test/logs/req_szOxdxafjuDYCg it looks like you're not passing the checkout id by itself. You'd want to just pass the cs_test_1234abc when retrieving the checkout session.
I removed your last screenshot as it had sensitive data,
That is true, I'm just hyper cautious.
response: {
status: 401,
statusText: 'Unauthorized',
headers: AxiosHeaders {
server: 'nginx',
date: 'Fri, 21 Oct 2022 22:26:07 GMT',
'content-type': 'application/json',
'content-length': '343',
connection: 'close',
'access-control-allow-credentials': 'true',
'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
'access-control-allow-origin': '*',
'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
'access-control-max-age': '300',
'cache-control': 'no-cache, no-store',
'www-authenticate': 'Basic realm="Stripe"',
'strict-transport-security': 'max-age=63072000; includeSubDomains; preload',
[Symbol(defaults)]: null
},
now im getting this? lol
Ok, so you said you're passing the checkout session id, but the screenshots show the url.
Im passing this
with dynamic id
because I'm actually posting a request by a url
response: {
status: 401,
statusText: 'Unauthorized',
headers: AxiosHeaders {
server: 'nginx',
date: 'Fri, 21 Oct 2022 22:30:05 GMT',
'content-type': 'application/json',
'content-length': '343',
connection: 'close',
'access-control-allow-credentials': 'true',
'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
'access-control-allow-origin': '*',
'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
'access-control-max-age': '300',
'cache-control': 'no-cache, no-store',
'www-authenticate': 'Basic realm="Stripe"',
'strict-transport-security': 'max-age=63072000; includeSubDomains; preload',
[Symbol(defaults)]: null
},
Now I'm unauthorized
I'm passing a key wrongly?
like this
Not the key I do not think, you'd get a different error.
I would really like to know what your req.body.id returns as this has to be cs_123abc to retrieve it.
it is
From the first screenshot it does appear to be cs_123abc as you are showing a Thank you message with it
On the same page
and sends it to a server
as I said
now I'm getting unauthorized
error
this is what I'm getting from the console
For Get, you'd use your Stripe publishable key
Sorry, you're right, you'll use the Secret Key as shown on the document: https://stripe.com/docs/api/checkout/sessions/retrieve
From further investigating, it looks like you're passing undefined when retrieving the Checkout Session. You'd need to debug why you're not getting the Checkout Session ID there. To confirm this, you can manually pass the Checkout Session id when
const session = await stripe.checkout.sessions.retrieve( 'cs_test_qwty13452' );
I am passing it MANUALLY
Right now
I said I'm getting unauthorized
I need to pass a key otherwise
On your Dashboard, can you toggle this to show your GET request and share the request id with me?
it starts with req_
and it will make my investigation much faster on my end
I see now, you are using /v1/issuing/transactions/ with GET : https://dashboard.stripe.com/test/logs/req_x5hhxYbSdOtjMO which ipi_1LvFUnHqPOI3slEhyFIK6yse is not an issuing transaction
y
but
theres
only 404
all the error here are from the web
not from my app
The issue here is that you're making /v1/checkout/sessions/undefined calls which is not cs_1234qrtyer
these request
are from the web
not from my app
i am getting unath error right from the server in a console
can i paste you screenshots
and wait answer from a dev?
I'm currently talking to a teammate here about this, thank you for your patience
ok i'll wait
Just hopping in! Give me a minute to catch up
Backing up for a bit - why are you using axios to make calls directly to Stripe's API and not using our client library?
because I used to use Axios for any API
And I don't know how to work with node directly
You should really just be using our node client library (it handles making the requests for you)- we have all the samples for how to use it in our API reference https://stripe.com/docs/api/checkout/sessions/retrieve?lang=node
I don't get why I can use it through a web and I can't do that by a app
What do you mean by that?
That's just a different way of calling our API - if it's not working from your app then something about your code is probably wrong and needs to be fixed
All I need to do - enter my api key in a login modal
WELL
I'm getting unauthorized
even tho I got {apiKey: envFile}
Yes, you're getting unauthorized because you're using axios incorrectly (as far as I can see in your code you're not actually passing the API key correctly with axios). That's why I said you should use our client library.
I have to do it like this?
Again - why don't you just use our client library? You're already initializing it with the const stripe line in your code
As I said — I'm a n00b in a node js
Yes, but I gave you a clear example from our API reference, and you seemed to be using it earlier (#1033122640317136927 message) - it's MUCH harder to get this working with axios compared to just using our client library
Can't you just say what I am doing wrong or help me with a node js? Because I have no idea
I already gave you an exact example of how to retrieve a Checkout Session with our node client library: https://stripe.com/docs/api/checkout/sessions/retrieve?lang=node
The axios code you have won't work for a couple of reasons:
- Our API does not accept application/json request bodies - we expect form-encoded request bodies (which we talk about here https://stripe.com/docs/api?lang=node)
- You're not setting the bearer authentication correctly in the headers. You should just use
authand do Basic authentication (see https://axios-http.com/docs/req_config for axios's docs and see https://stripe.com/docs/api/authentication for what we accept for Basic auth)
Using the client library is MUCH easier because it abstracts all this away for you - if you're not familiar with axios then you need to be checking their documentation on the correct ways to set authentication and the necessary headers.
So now something about your server call is failing - so you have to do some basic debugging to see what specific part is failing. You need to make sure the Checkout Session retrieval request is actually being made and see if it's successful
and is there a reason your server code is not responding with any status?
So something is wrong with how you've set up your api routes in nextJS (I assume that's what you're using)
You have to look through your code and make sure you have your API routes set up correctly
I'm not the most familiar with nextJS, but why did you remove the export default when you moved to using our client library?
Yeah so now the issue is that there's nothing in req.body.id - if you were to hardcode a Checkout Session ID string in there it'd probably work
THat's what I mentioned earlier - your server isn't actually responding with anything, so you need to add more code
that's a lot of pictures
bcz i'm not familliar with a node
What's your real question as a developer?
Node is mostly Javascript, if you're familiar with JS it's the same
I wanted to fetch from an API with a axios, but I couldn't so we decided to move to a node
Node is Javascript
So what's the problem/what's your question? Why do you use a .then and such with an await?
https://stripe.com/docs/api/checkout/sessions/retrieve?lang=node has the exact code so you want to do this const session = await stripe.checkout.sessions.retrieve( 'cs_test_a140XQ5ZdBt8vW26ncntHKAOA5oMc2PiNIbT6Ea5en8kQP3Os7WxiGiobI' );
After this, you're set, the variable named session has all the information you can see on https://stripe.com/docs/api/checkout/sessions/object
so you can do console.log(session.id); for example
Does that make sense?
idk
I'm sorry but I can't help you with an "idk".
I would recommend hiring a freelancer to help guide you at this point
you still have the then and await
I'm sorry but at this point I can't really help. You just send pictures of code with undefined 😦
ah nice!