How to get Billing and Shipping Address data from Stripe Checkout
Stripe Checkout is an awesome tool for Stripe users to collect credit card info in a beautiful and PCI compliant way.
Up until a couple of months ago, Stripe supported developers requesting both the billing and shipping address from their customers. Since then, they’ve deprecated billing and shipping address to just billing address (renaming it address), and now they have also deprecated address support opting for just zip code support. However if you still want to get access to a customer’s billing and shipping address, fear not, the ability is still there, just a bit undocumented.
NOTE: This feature is deprecated, it might be removed at any time, or may just start acting weird.
Check it out:
So here’s how to implement it:
Simple Integration (Pure HTML)
You’ll want to add two data attributes to your Stripe checkout script tag:
Your html should look something like this:
When the form submits to your server, you’ll see this all this info added as part of the form:
(Also, the billing address info will also get added to the card token automagically.)
Custom Integration (JS)
The custom integration route is just a simple, just add
billingAddress=true to the object passed into your Stripe handler’s open method, like below:
The billing info will automatically be part of the card and token, the shipping info gets passed to your token callback as a second parameter (which I called
args). The contents args look like this:
- You cannot just request the shipping address, if you set
billingAddress=falsethe user will be prompted for a billing address.
- Funky stuff will happen if you try to use the address functionality and the new
zipCodeoption. If you use address, Stripe will grab the zip code that the customer entered as part of their billing address to do a zip code check.
P.S. Need help with your Stripe integration? Feel free to send me an email [email protected]