#bwestwood11
1 messages · Page 1 of 1 (latest)
the create checkout session doesn't work
What do you mean by it doesn't work? Can you share the error message?
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',
Can you share the request ID (req_xxx) that contains Not a valid URL? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
From the high level error, it looks like your success_url and cancel_url are likely in incorrect format, but I'd need the request ID to double check.
req_Oj1UYr8NPeat5a
i think that's the right one
it showing a bunch of 200 request
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 ||
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
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
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
localhost url is not accessible by phone, but your own computer. you'd need to set public url to work on phone
changed it and nothing
If i go on my laptop to competitiveedgedumpsters.com it works which isn't my computer I code on. However, the phone still doesn't work
the phone does show the GET request of all the listed prices from Stipe
What do you mean by phone still doesn't work? Is there any error thrown?
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
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?
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
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
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
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?
Where's the code for /api/payment? I only see POST function
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?
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
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
Yup, that would work
i don't understand how would I test it on my phone, would I have to run the build after this change?
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
What are these logs? Are these logs from POST function that triggered on the phone?
nothing triggers on the phone
this is the localhost on my computer
oh i got it now
So, does the phone trigger POST function before calling to Stripe function?
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
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
I have pressed it and waited over 30 secs to a minute and no stripe checkout popped up