#BinaryWritter - Subscriptions
1 messages · Page 1 of 1 (latest)
Hello, it throws a not found error in create-checkout-session, besides i want to implement more subscriptions but i dont know how
For what i know create-checkout-session is implemented in the server code, but i get a not found error
As im using Next.js i created a index.js in the pages/api routes, and there i have placed the server code
Have you installed Stripe?
Yes, i think its installed, let me check please so i can tell you what npm packages i have installed
I have installed @ancient depot/react-stripe-js, also @ancient depot/stripe-js and stripe
Those 3 packages
Okay. So what is the exact error you are encountering. Also I'm not super familiar with Next
Okay but that doesn't tell me much. What are you trying to do here?
Oh yes, sorry that is some of the multiple errors i get when i try to run the code from the App.js of the example
Okay. So let's take a couple steps back. Have you integrated Stripe before? Using this tech stack?
I see a checkout button but no subscription plan info or anithing more
No i havent integrated Stripe before i want all payments types and also subscriptions
Subscriptions are a pretty complex topic and I highly recommend taking a slow and steady approach to understand them
Ok thank you, i have already read, but ill do it again
And instead of just the Quickstart. I would suggest you checkout out the Design an Integration and Build a subscriptions integration pages:
https://stripe.com/docs/billing/subscriptions/designing-integration
https://stripe.com/docs/billing/subscriptions/build-subscriptions
Ok thank you, ill read all that
Hello again, @winged crater the problem i have its that Next.js doesnt recognize the action create-checkout-session when i click the checkout button
👋 stepping in here for Snufkin as they needed to step away
So it sounds like you are having an issue hitting your Server from your Client?
Yes, i have created a index.js in the pages/api folder but all server calls are not recognized
Hello
Hi :). Okay and how are you attempting to hit your server?
In Next.js i have created a index.js in the pages/api so all server code goes there, but when i run my app, i get not found errors at create-checkout-session
Okay can you share your client-side code where you are attempting to hit your server?
And can you share you server endpoint?
Could you send me here a ' symbol for the code, i cant find it in my keyboard?
Thank you !!!
This is the server code
And this is my checkout
In server code the require('stripe') doesnt seem to work
I have created a env.local for secret and public stripe keys
and webhooks
this is my webhook
Thanks, let me take a look.
Hmm okay that looks fine to me... and your Express server is running, I assume?
You mean like node server.js of something, i have tried but no luck also
My next.js is in port 3000 and server is port 4242
That should be fine. So you are running node index.js in a terminal?
And you can see your local server running?
It displays a message that says running on port 4242 but besides that i dont know if its running
Yeah okay so if it has that message then that is likely running. Can you try it again and screenshot what you see in your developer console of your browser?
Ah okay so yeah you aren't actually hitting your server endpoint... it is using your 3000 port
I get lots of not found errors when i click in the ckeckout button
Try changing the form to use the full URL...action="http://localhost:4242/create-checkout-session"
I have changed the action as you say but throws a error
localhost no envió ningún dato.
ERR_EMPTY_RESPONSE
Okay can you add a log to the top of your create-checkout-session endpoint that says something like console.log("hit my server")
And then restart the server
And test again
And let's see if that shows up in your server terminal
Now it tries to find http://localhost:4242/create-checkout-session but same error
in network i can see chekout but also a error like the above
Its like express and server are not recognized
Can you share a screenshot again of what you see in browser console?
Does it show that it is trying to hit the correct URL?
Its trying to hit http://localhost:4242/create-checkout-session but with a error oh in terminal i can see our log 'hit my server' message
Okay so that is working then, you are hitting your server now!
Sorry server crashes
So now you need to debug why your Server isn't redirecting
It displays some data
and the server crashes
the node one
do i have to place in package.json a proxy thing?
In stripe examples they do
also do i move the server code to other folder other than pages/api ?
Hello 👋
Taking over here
Can you give me a short summary of your issue while I catch up on the thread?
thanks 🙂
Yes Hello i want to implement all posible payment methods and also subscriptions but in Next.js my server code that its in pagaes/api index.js cant find the checkout create-chechout-session throwing a error in console about that
My code is up in this thread
And the node server crashes
If in checkout the action of the form i remove the http://localhost:4242 the console also throws a error but server continues running
ah okay
Did you clone this code/folder structure from anywhere?
No i have only added the code from the docs to the pages/api directory in Next.js but i dont know where it should go
the server code there and the checkout to a pages/Checkout.js file
ah okay. I don't think we have a next.js specific sample or guide that you can follow for this.
Let me see if I can share any react specific resources which you can use
Ok thank you
Your implementations are with node.js, but havent find any for Next.js
yeah I don't think we have any next.js specific docs
Mostly, it'd be React + Node
The Next.js docs say that to implement Express i have to place that code in the pages/api folder
There's an example here for next
https://github.com/tmarek-stripe/demo-react-stripe-js