#BinaryWritter - Subscriptions

1 messages · Page 1 of 1 (latest)

winged crater
#

Hi 👋

#

When you say "it doesn't work", can you be more specific?

unkempt fulcrum
#

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

winged crater
#

Have you installed Stripe?

unkempt fulcrum
#

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

winged crater
#

Okay. So what is the exact error you are encountering. Also I'm not super familiar with Next

unkempt fulcrum
#

Hope you can see this image

winged crater
#

Okay but that doesn't tell me much. What are you trying to do here?

unkempt fulcrum
#

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

winged crater
#

Okay. So let's take a couple steps back. Have you integrated Stripe before? Using this tech stack?

unkempt fulcrum
#

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

winged crater
#

Subscriptions are a pretty complex topic and I highly recommend taking a slow and steady approach to understand them

unkempt fulcrum
#

Ok thank you, i have already read, but ill do it again

winged crater
unkempt fulcrum
#

Ok thank you, ill read all that

unkempt fulcrum
#

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

dim dove
#

👋 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?

unkempt fulcrum
#

Yes, i have created a index.js in the pages/api folder but all server calls are not recognized

#

Hello

dim dove
#

Hi :). Okay and how are you attempting to hit your server?

unkempt fulcrum
#

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

dim dove
#

Okay can you share your client-side code where you are attempting to hit your server?

#

And can you share you server endpoint?

unkempt fulcrum
#

Could you send me here a ' symbol for the code, i cant find it in my keyboard?

dim dove
#

Three backticks test

#

backtick = `

unkempt fulcrum
#

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

dim dove
#

Thanks, let me take a look.

#

Hmm okay that looks fine to me... and your Express server is running, I assume?

unkempt fulcrum
#

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

dim dove
#

That should be fine. So you are running node index.js in a terminal?

#

And you can see your local server running?

unkempt fulcrum
#

It displays a message that says running on port 4242 but besides that i dont know if its running

dim dove
#

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?

unkempt fulcrum
dim dove
#

Ah okay so yeah you aren't actually hitting your server endpoint... it is using your 3000 port

unkempt fulcrum
#

I get lots of not found errors when i click in the ckeckout button

dim dove
#

Try changing the form to use the full URL...action="http://localhost:4242/create-checkout-session"

unkempt fulcrum
#

I have changed the action as you say but throws a error

#

localhost no envió ningún dato.
ERR_EMPTY_RESPONSE

dim dove
#

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

unkempt fulcrum
#

in network i can see chekout but also a error like the above

#

Its like express and server are not recognized

dim dove
#

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?

unkempt fulcrum
dim dove
#

Okay so that is working then, you are hitting your server now!

unkempt fulcrum
#

Sorry server crashes

dim dove
#

So now you need to debug why your Server isn't redirecting

unkempt fulcrum
#

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 ?

viscid pewter
#

Hello 👋
Taking over here
Can you give me a short summary of your issue while I catch up on the thread?

#

thanks 🙂

unkempt fulcrum
#

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

viscid pewter
#

ah okay
Did you clone this code/folder structure from anywhere?

unkempt fulcrum
#

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

viscid pewter
#

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

unkempt fulcrum
#

Ok thank you

#

Your implementations are with node.js, but havent find any for Next.js

viscid pewter
#

yeah I don't think we have any next.js specific docs
Mostly, it'd be React + Node

unkempt fulcrum
#

The Next.js docs say that to implement Express i have to place that code in the pages/api folder

viscid pewter
unkempt fulcrum
#

Thank you !! Ill check it out !!

#

Say thanks from my part to you and to all your other admins