I want to add Shipping Cost to the total checkout amount. I am using the stripe prebuild checkout page to plete the payment. When I enabled the Shipping option in Strip Session, Stripe started displaying the Shipping Address Form (that I don't want to display) on the checkout page.
I don't want to take the user's shipping address, I have already done this.
I tried to read the Stripe DCOS but didn't find the solution on this, If anyone can help me will be a great pleasure.
I want to add Shipping Cost to the total checkout amount. I am using the stripe prebuild checkout page to plete the payment. When I enabled the Shipping option in Strip Session, Stripe started displaying the Shipping Address Form (that I don't want to display) on the checkout page.
I don't want to take the user's shipping address, I have already done this.
I tried to read the Stripe DCOS but didn't find the solution on this, If anyone can help me will be a great pleasure.
Share Improve this question asked Apr 24, 2021 at 22:30 Akash KanaujiyaAkash Kanaujiya 2271 gold badge3 silver badges11 bronze badges3 Answers
Reset to default 5Here is how I have done it you can add many objects in shipping_options to have many shipping types
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
mode: 'payment',
shipping_options: [
{
shipping_rate_data: {
type: 'fixed_amount',
fixed_amount: {
amount: 1500,
currency: 'usd',
},
display_name: 'Next day air',
delivery_estimate: {
minimum: {
unit: 'business_day',
value: 1,
},
maximum: {
unit: 'business_day',
value: 1,
},
},
},
},
],
line_items: data.map((el) => {
return {
price_data: {
currency: 'usd',
product_data: {
name: el.title,
// images: [el.img],
},
unit_amount: 1000,
},
quantity: 1,
};
}),
success_url: '{{yoursite}}/success',
cancel_url: '{{yoursite}}/cancel',
});
enter code here
Also, you can check their docs here
You could just add it as a one-time item in the Checkout Session.
Add the block of code, after the line_items parameter solved mine[![enter image description here][1]][1]
line_items:lineItems,
shipping_options: [
{
shipping_rate_data: {
type: 'fixed_amount',
fixed_amount: {
amount: deliveryCost * 100,
currency: 'usd',
},
display_name: 'BLSSM Studios Courier Service',
delivery_estimate: {
minimum: {
unit: 'business_day',
value: 1,
},
maximum: {
unit: 'business_day',
value: 1,
},
},
},
},
],