See the code behind this demo!

Shipping address and costs with Checkout

You can collect shipping costs by creating them in the dashboard, and then configuring them when creating your checkout sesssion. You can also specify that shipping address collection should be done for the countries to ship to. Click the "Pay" button to redirect to Checkout and see these in action.


Console

> Ready ...

                                      
  const session = await stripe.checkout.sessions.create({
    // Create this shipping rate in the dashboard ...
    shipping_rates: ['shr_1JHTgbAPEf9EarUkbq5qXfIU'],
    // Specify for which countries shipping addresses should be collected ...
    shipping_address_collection: {
      allowed_countries: ['US', 'CA'],
    },
    payment_method_types: ['card'],
    line_items: [
      {
        price_data: {
          currency: 'usd',
          product_data: {
            name: 'Tiny Demos',
            images: ['https://i.imgur.com/EHyR2nP.png'],
          },
          unit_amount: 2000,
        },
        quantity: 1,
      },
    ],
    mode: 'payment',
    success_url: 'https://stripe-tinydemos-checkout-shipping.glitch.me/success',
    cancel_url: 'https://stripe-tinydemos-checkout-shipping.glitch.me/cancel',
  });
          
        

Experiment and learn

Make copies, remix, change and learn how to play with this tinydemo.


Any questions?

Reach out to us on any of our contact channels: