#dahri_code

1 messages ¡ Page 1 of 1 (latest)

serene veldtBOT
#

👋 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/1276135090535006280

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

tribal deltaBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

stiff glade
#

No, your code overall seems confused. ui_mode is a parameter on Checkout Sessions

#

Looks like you're trying to use stripe.checkout.sessions.create instead?

icy island
#

exactly i wanted to ask is i have ui mode embedded here:

exports.createPaymentIntent = async (req, res) => {
try {

const {credits} = req.body;
console.log(credits)
const session = await stripe.checkout.sessions.create({
  ui_mode: 'embedded',
    line_items: [
      {
        price_data: {
          currency: 'usd',
          product_data: {
            name: 'Buying Credits for $0.5 per sec',
          },
          unit_amount: parseInt(credits)*100,
        },
        quantity: 1,
      },
    ],
    mode: 'payment',
    return_url: 'http://localhost:5173/dashboard/buy-credits',
    metadata: {
      userId: req.user.id,
  }
  });

  res.send({clientSecret: session.client_secret});

} catch (error) {
res.send('Request Failed')
}

};

#

can i use same ui mode for subscription?

stiff glade
#

No

icy island
#

ok, thanks

#

what is difference between session.create and stripe.subscriptions.create?

stiff glade
#

One creates a Checkout Session, which is a hosted UI to facilitate payment collection and automatically creates/starts the subscription for you: https://docs.stripe.com/payments/checkout

Using the Subscriptions API directly otherwise means you need to build your own UI for payment collection using Elements (as per the last link). It's a more involved integration

Build a low-code payment form and embed it on your site or host it on Stripe.

icy island
#

thanks, also i have webhook for one time payment where i m getting event and when event is if(event.type==='checkout.session.completed') so i run the process for one time payment.
now do i need to create new webhook or similar i can use with different event type?

stiff glade
icy island
#

on stripe where to setup the webhook for subscription?

stiff glade