#Dheeraj Kumawat-redirecttocheckout
1 messages · Page 1 of 1 (latest)
Hey there! Are you creating a Checkout Session? Or just passing parameters to redirectToCheckout?
passing parameter to redirectToCheckout
stripe.redirectToCheckout({
lineItems:[
{
price: "",
quantity:1,
},
],
mode:"payment",
successUrl:currentAddress,
cancelUrl: currentAddress,
billingAddressCollection: "required"
})
.then(function(result){
});
like this
Yeah you can't use dynamic/ad-hoc pricing with redirectToCheckout like that. You'll need to create a Checkout Session and you can use the price_data param: https://stripe.com/docs/api/checkout/sessions/create?lang=node#create_checkout_session-line_items-price_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
const stripe = require('stripe')('sk_test_51JRYycEyVrenzoaUuOW55bEq0sNjCb1Z7mo26EyUm25GYSnvEyNY3vZOl5hAg638d0ZKMLFTscEIjXL1ME1NXiRI00LMeYdKtl');
const session = await stripe.checkout.sessions.create({
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
line_items: [
{price: 'price_H5ggYwtDq4fbrJ', quantity: 2},
],
mode: 'payment',
});
in session also their is no option to provide dynamic amount
There is, using price_data: https://stripe.com/docs/api/checkout/sessions/create?lang=node#create_checkout_session-line_items-price_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
its also using price key
after the session what to do?
i am new to this so need some step guidance for this
I recommend checking out the quickstart guide: https://stripe.com/docs/checkout/quickstart
But generally you'd redirect your customer to the url field returned in the Checkout Session object
i have a html and javascript based application. How to do this in that?
this link has php file in this but i need to implement it for html and javascript page only