#coldrain

1 messages · Page 1 of 1 (latest)

crimson wolfBOT
steep canopy
#

Hi, can you add more details here so I can best assist. Are you intending to retrieve the Checkout Session by the Session id?

junior berry
#

no, I need to fetch info about that checkout, I've got an id after checkout.

steep canopy
#

What information are you looking for? What are you really trying to do with it?

junior berry
#

I need this

steep canopy
junior berry
#

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?

steep canopy
junior berry
#

yes, but i'm not getting it

steep canopy
#

You're not getting what? You're not retrieving the Checkout Session so I'm a bit lost.

junior berry
#

result

steep canopy
#

Let's back out, what do you want to see? Can you provide me more details on what you expect your code to do?

junior berry
#

when I try to use your API

#

I'm getting 500 err

steep canopy
junior berry
#

but there's no error logs

#

only one

steep canopy
#

Under the Method > is GET included?

junior berry
#

axios put

#

?

steep canopy
#

I'm looking further here

junior berry
#

what I'm doing wrong?

#

now im getting 404

steep canopy
#

Looking at your code further

junior berry
#

no, I'm passing everything right

steep canopy
#

can you console.log(req.body.id) please and share what it's logging?

junior berry
#

I cannot get that console log from server side

#

this is a error that i get

steep canopy
junior berry
#

I'm passing it

#

right now

steep canopy
#

I removed your last screenshot as it had sensitive data,

junior berry
#

thats

#

ok

#

its test env

#

anyway

#

no prod

steep canopy
#

That is true, I'm just hyper cautious.

junior berry
#

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

steep canopy
#

Ok, so you said you're passing the checkout session id, but the screenshots show the url.

junior berry
#

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

steep canopy
#

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.

junior berry
#

it is

steep canopy
#

From the first screenshot it does appear to be cs_123abc as you are showing a Thank you message with it

junior berry
#

after the payment this dynamic page occurs

#

then React gets id

steep canopy
#

On the same page

junior berry
#

and sends it to a server

#

as I said

#

now I'm getting unauthorized

#

error

#

this is what I'm getting from the console

steep canopy
#

For Get, you'd use your Stripe publishable key

junior berry
#

with a publishable

steep canopy
#

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' );

junior berry
#

I am passing it MANUALLY

#

Right now

#

I said I'm getting unauthorized

#

I need to pass a key otherwise

steep canopy
#

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

junior berry
#

y

#

but

#

theres

#

only 404

#

all the error here are from the web

#

not from my app

steep canopy
#

The issue here is that you're making /v1/checkout/sessions/undefined calls which is not cs_1234qrtyer

junior berry
#

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?

steep canopy
#

I'm currently talking to a teammate here about this, thank you for your patience

junior berry
#

ok i'll wait

robust obsidian
#

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?

junior berry
#

because I used to use Axios for any API

#

And I don't know how to work with node directly

robust obsidian
junior berry
#

I don't get why I can use it through a web and I can't do that by a app

robust obsidian
#

What do you mean by that?

junior berry
robust obsidian
#

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

junior berry
#

All I need to do - enter my api key in a login modal

#

WELL

#

I'm getting unauthorized

#

even tho I got {apiKey: envFile}

robust obsidian
#

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.

junior berry
#

I have to do it like this?

robust obsidian
#

Again - why don't you just use our client library? You're already initializing it with the const stripe line in your code

junior berry
#

As I said — I'm a n00b in a node js

robust obsidian
#

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

junior berry
#

Can't you just say what I am doing wrong or help me with a node js? Because I have no idea

robust obsidian
#

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.

junior berry
#

Ok, boss

#

where am I wrong right now?

robust obsidian
#

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?

junior berry
#

y

robust obsidian
#

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?

junior berry
robust obsidian
#

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

junior berry
robust obsidian
#

THat's what I mentioned earlier - your server isn't actually responding with anything, so you need to add more code

junior berry
#

how to get a data

worthy flower
#

that's a lot of pictures

junior berry
#

bcz i'm not familliar with a node

worthy flower
#

What's your real question as a developer?

#

Node is mostly Javascript, if you're familiar with JS it's the same

junior berry
#

I wanted to fetch from an API with a axios, but I couldn't so we decided to move to a node

worthy flower
#

Node is Javascript

#

So what's the problem/what's your question? Why do you use a .then and such with an await?

#

so you can do console.log(session.id); for example

#

Does that make sense?

worthy flower
#

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

junior berry
#

still don't get session

#

still getting undefined

worthy flower
#

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 😦

junior berry
#

oh, finally

#

thanks

#

I've also cleared everything

#

Just exploring js

worthy flower
#

ah nice!