Adding Shipping Options0:00
Now, depending on the type of store that you are building and the products that you are selling, you might want to also collect the shipping information from your customer. So the checkout method accepts an additional parameter, and here we can pass an array with additional options that we would like to send over to Stripe. Now, you can look at the API reference for more information about all the different things you can afford to Stripe. In this case, we first want to set customerUpdate and shipping to automatic. This is a requirement whenever you use Stripe text. It basically instructs Stripe whenever a shipping address is added. We want to sync this back to the customer, and this will also be used for text purposes,
Restricting Shipping Countries0:38
It basically instructs Stripe whenever a shipping address is added. We want to sync this back to the customer, and this will also be used for text purposes, because this depends on where your customer is living. Next, we'll add another key value array, in this case, shipping address collection. Now, we have to explicitly define the countries to which we support shipping. We can use the allowedCountries key, followed by an array, and we can use the abbreviations to define which countries are allowed. In this case, I'm going to set it to US and NL. Now, if we switch back to our browser and click checkout, we can see that our shipping address is now a required field.
Testing Checkout Shipping1:16
Now, if we switch back to our browser and click checkout, we can see that our shipping address is now a required field. We can enter our name, we can select a country, and we get autocomplete on our address. And again, Stripe will automatically calculate tax based on the shipping address, so that's awesome. You can even provide your business information, because in some cases, the tax will not be charged because you're exempt from paying taxes as a business.
