#bala-Subscription
1 messages · Page 1 of 1 (latest)
Hi there, can you elaborate more on pass the price money using redirect checkout API and create sessions API ? Also can you share with me the code?
const item = {
// price: "price_1LA7xZSBJFbPZu8A6GtPM5ah",
price: "20",
quantity: 1
};
const checkoutOptions = {
lineItems: [
item
],
mode: "payment",
successUrl: ${window.location.origin}/success,
cancelUrl: ${window.location.origin}/cancel
};
const redirectToCheckout = async () => {
console.log("redirectToCheckout");
const stripe = await getStripe();
// const session = await stripe.checkout.sessions.create({
// success_url: ${window.location.origin}/success,
// cancel_url: ${window.location.origin}/cancel,
// line_items: [
// {price: '20', quantity: 1},
// ],
// mode: 'payment',
// });
const { error } = await stripe.redirectToCheckout(checkoutOptions);
console.log("Stripe checkout error", error);
};
@stripe/react-stripe-js version = 1.9.0@stripe/stripe-js version = 1.32.0
A few things
- You mention subscription but you set the checkout mode to
paymentinstead ofsubscription - I don't think stripe.redirectToCheckout() accepts the list of params that you passed in, check https://stripe.com/docs/js/checkout/redirect_to_checkout for the list of accepted params.
I'll suggest you to get started with subscription by using this doc. https://stripe.com/docs/billing/quickstart