#bwestwood11

1 messages · Page 1 of 1 (latest)

verbal sedgeBOT
copper plume
#

the create checkout session doesn't work
What do you mean by it doesn't work? Can you share the error message?

last monolith
#

so when I use my computer it works on the domain and localhost

#

however, when I use it on the phone or any other computer it doesn't

#

here is the code

#

How would I be able to console log it on a phonne to see an error

#

i see an error I got in the /api/payment

#

error - StripeInvalidRequestError: Not a valid URL
at StripeError.generate (/var/task/.next/server/chunks/306.js:3479:20)
at res.toJSON.then.StripeAPIError.message (/var/task/.next/server/chunks/306.js:7157:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'StripeInvalidRequestError',

copper plume
last monolith
#

req_Oj1UYr8NPeat5a

#

i think that's the right one

#

it showing a bunch of 200 request

copper plume
#

Thanks for sharing! The success_url Stripe received was http://localhost:3000/success || https://competitiveedgedumpsters.com/success. The validation of an URL is invalid that contains ||

last monolith
#

do i have to add this to it as well

#

session_id={CHECKOUT_SESSION_ID}",

copper plume
#

You can either set http://localhost:3000/success OR https://competitiveedgedumpsters.com/success without ||

#

The issue is with the URL format that you set in the request

#

It shouldn't contain ||

#

It's an invalid URL

last monolith
#

i changed it to localhost:3000/success

#

and got no more errors in the logs

#

but on the phone it is not working

#

im clicking the checkout button and it looks like its not sending an event to the log at all

copper plume
#

http://localhost:3000/success is the localhost URL on your computer and it can't be accessed from your phone. You'd need a URL that can be accessed publicly, for example, https://competitiveedgedumpsters.com/success

last monolith
#

only on my computer

#

I will try that again

copper plume
#

localhost url is not accessible by phone, but your own computer. you'd need to set public url to work on phone

last monolith
#

changed it and nothing

#

the phone does show the GET request of all the listed prices from Stipe

copper plume
#

What do you mean by phone still doesn't work? Is there any error thrown?

last monolith
#

no error thrown

#

nothing happens

#

just asked somebody to try on a computer t their house and it doesn't work. so it seems to only work on my computer with localhost and the actually domain

copper plume
#

If you test on the phone, URL should be set to actual domain (not localhost). Was the Checkout Session created successfully if you test on the phone with URL set as actual domain?

last monolith
#

Yes I set it to actual domain and no checkout session was successful on the phone. Nothing happened when I click the button

#

Can it potentially be the env variable, even though the env variable works for the GET request to list the products

#

And it is https secured so I already checked that

copper plume
#

From your latest request history https://dashboard.stripe.com/test/logs/req_fDAQHagop8vU4N, I can see that a Checkout Session was created successfully. Was this the one made on your phone? I'm trying to understand whether the issue was with not creating a Checkout Session or your phone has an issue with Checkout Session URL redirection

last monolith
#

No request are showing up when I try on my phone

#

All those requests are from my computer and tweaking the code a little to see

copper plume
#

It sounds like your code doesn't make it from frontend to backend to create a Checkout Session. Could you share your code how you make a call to your backend to create a Checkout Session?

last monolith
copper plume
#

Where's the code for /api/payment? I only see POST function

last monolith
#

That last screenshot is

#

Just didn’t add the two imports in the screenshot

copper plume
#

For completeness, can you share how your /api/payment is defined and called POST function, so that I can double check if anything is missing?

last monolith
#

In NextJS 13 api/payment is defined based on folders

#

So there is an api folder

#

And inside of the api folder there is a payment folder

#

And then the code above is called page.jsx

copper plume
#

I see! Could you add log at the beginning of the POST function (before calling Stripe function) and check if the POST function is called when your phone tries to make a /api/payment request? This is to narrow down whether it's a Next or Stripe issue on the phone

last monolith
#

so a console.log(req)

#

?

copper plume
#

Yup, that would work

last monolith
#

i don't understand how would I test it on my phone, would I have to run the build after this change?

copper plume
#

This is a log added in your server that you will need to rebuild your server. There shouldn't be impact to your phone. The log should appear in your server log

#

You can try to add a log in your GET function and check how it appears in your console log. You can then do the same to the POST function

last monolith
copper plume
#

What are these logs? Are these logs from POST function that triggered on the phone?

last monolith
#

nothing triggers on the phone

#

this is the localhost on my computer

#

oh i got it now

copper plume
#

So, does the phone trigger POST function before calling to Stripe function?

last monolith
#

i don't know how to tell that i see that a post request of status 200 is being called when i click on mobile in the Vercel logs

verbal sedgeBOT
copper plume
#

If your /api/payment returns 200, it likely the POST function is triggered successfully with Checkout Session returned

#

There can be a lag to the Dashboard request history sometimes that you don't see the request immediately

last monolith
#

I have pressed it and waited over 30 secs to a minute and no stripe checkout popped up