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]
Foobar October 21, 2014 -
Absolutely perfect. I have no idea why they don’t document `billingAddress` and `shippingAddress`, but thanks for this post!
Mark January 26, 2015 -
You are a life saver! Could not find documentation on this anywhere. And this was something so simple.
Kenji March 20, 2015 -
Is it possible to have a quantity selector? and is it possible to use checkout for recurrent payments?
This is great!
matthewarkin March 24, 2015 -
You can use checkout for recurring payments. Stripe Checkout just creates card tokens, what you do with the tokens is up to you.
You cannot have a quantity selector in the popup, but you could create your own on your site.
Kelly April 9, 2015 -
This is great. I’m having trouble getting the shipping info that’s passed back to save to the db. Do I need to do anything else besides add ‘args’ after ‘token’ like in your example js? I’m not sure why I’m not able to get it to save. Thanks!
matthewarkin April 14, 2015 -
How you get args to your server-side code is up to you
nacho August 18, 2015 -
nice nice stuff! Maybe Stripe doesnt have documented this issue but they have a great open API so talented and skilled people like you can make our life better
Steven Pack August 18, 2015 -
I went through the same pain. I wrote a similar guide, but it includes a code snippet on submitting the address to your server side page too.
matthewarkin August 19, 2015 -
I purposely ignored how to send it from the custom integration because there are too many possible ways people may wish to send data to their server using that method.
Vehid September 23, 2015 -
Is there any way to change the default country on the checkout form? Currently it is “United States” and my clients have to change it to Canada. It would be also nice to feed the default city too. Thank you for the great platform anyway.
matthewarkin September 28, 2015 -
Not to my knowledge
Alberto July 9, 2016 -
is this feature still considered deprecated?
Because I can find it in the docs and there’s no warning about it: https://stripe.com/docs/checkout#integration-options-shipping-address
matthewarkin July 9, 2016 -
It has since been undeprecated
Arjun July 26, 2016 -
Great article! Just one question: How does stripe collect the apartment number if there is only a field for the first line of the address?
matthewarkin July 26, 2016 -
Make the address “123 Main Street APT 404″ though that would only be helpful for shipping address, for billing address only line 1 gets verified by AVS.