#dahri_code
1 messages ¡ Page 1 of 1 (latest)
đ 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.
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.
- dahri_code, 2 hours ago, 21 messages
- dahri_code, 2 days ago, 11 messages
- dahri_api, 5 days ago, 9 messages
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?
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?
No
Because there is no UI component with the Subscriptions API. It's just an API that generates a Subscription object that you can interface with other UIs, like the Payment Element. See: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=elements
ok, thanks
what is difference between session.create and stripe.subscriptions.create?
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
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?
Hmm, overall you'll need a number of different events to handle when payments fail or succeed. Outlined here: https://docs.stripe.com/billing/subscriptions/webhooks
on stripe where to setup the webhook for subscription?
https://docs.stripe.com/webhooks explains the end-to-end process