#sc0rp10npy_code

1 messages ¡ Page 1 of 1 (latest)

sullen timberBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1275497812997574826

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

sullen hazel
#

Let me explain more

#

I have created customer with user sign up and saved customer id

now i have to give user option to save their payment method

as per docs i have to setup intent and then pass the client secret to credit card form.

#

how can I use stripe built in page in nextjs for this? so that at end i directly get the payment token that I can use to charge user at month end for their subscription amount

sturdy horizon
sullen hazel
#

no the cart amount will change everytime so subscritions can't be used

#

i read the checkout docs
but how do I use it in nextjs?

sullen timberBOT
sturdy horizon
#

Subscriptions can totally be used even if the "cart amount" changes every time. Though that sentence can mean many different things so I'll need you to be a lot more specific about your business model and what you need help with.

As for Next.js we don't really have any specific docs for that framework sorry. You'll have to map our examples to your own code

sullen hazel
#

ohh

#

so basically user saves their payment method, then add items to cart
and checkout

now when the delivery happens, the payment gets deducted automatically from user account 7 days before the delivery

#

can I use subscription in this?

sturdy horizon
#

Sorry this is still really cryptic. Is this a recurring payment situation? Or just one-time payment and done?

sullen hazel
#

basically the business is about eco foods
so we provide boxes with organic foods

Once the User creates an account, they are presented with their box (which is empty at the beggining) and a huge array of various items. The User then goes through those items and adds the ones they like to their box. Once they have added their wanted products, they click a button to activate the box. This is where they have to enter all their payment details. Once all of the payment info has been saved, the box will be activated, and the User will receive their goods, which they have selected, every 30 days from the box activation date. The User can change the content of their box anytime, they just need to deactivate the box, remove/add items, activate the box back again. If the box is not active the user will not be charged. If they deactivate their box within 2 weeks left until delivery, they will still be charged for that delivery.

so we are saving payment method so that they don't have to manually pay every month

so tl;dr
its subscription based, but amount can change as per box value

sturdy horizon
#

@hard flame can you confirm you are taking over?

hard flame
#

I'm taking over now. Thanks for the ping

#

So yeah, Subscriptions would work for this use-case. Have you already created a test flow for this? There's a great quickstart guide here for using Checkout to get the Subscription setup: https://docs.stripe.com/billing/subscriptions/build-subscriptions

In terms of updating the Subscription each month, you would need to use a different flow other than Checkout, since Checkout only creates the Subscription. It doesn't allow for updating it. For updating the Subscription, you would want to look into the Customer Billing Portal to get started: https://docs.stripe.com/no-code/customer-portal

sullen hazel
hard flame
#

Let's focus on one question at a time.

The Billing Portal I linked to will require that you use webhooks to get notified of updates the Customer makes during the Portal Session. If you don't want to do that, then you would have to build a custom front-end that allows the customer to update the their Subscription, which would fetch() your server and make back-end API calls to Stripe.

sullen hazel