I am creating a checkout session in Node like so. https://stripe.com/docs/api/checkout/sessions/create
I've set the billing_address_collection
parameter to required
and am now wondering if I can retrieve the billing address collected from the checkout.completed
webhook that is triggered.
I'm not finding a good way to retrieve the billing address from a checkout session.
Is there a way to do this? Or should I just gather this information before sending the user to a checkout session?
When a card payment is submitted to a card network for authorization, Stripe provides the CVC, postal code, and billing street address for them to verify (if you collected these from the customer in your checkout flow).
Shipping address collection You can collect a customer's shipping address in Checkout by setting shipping_address_collection when you create a Checkout session.
The Checkout Session provides a URL that redirects customers to a Stripe-hosted payment page. Customers enter their payment details on the payment page and complete the transaction. After the transaction, a webhook fulfills the order using the checkout. session.
Checkout Sessions expire 24 hours after creation. After creating a Checkout Session, redirect your customer to the URL returned in the response.
Billing address can be collected via Checkout. It won't live on the CheckoutSession object though but instead on the PaymentMethod object.
When you get the checkout.session.completed
event, it has a payment_intent
field with the PaymentIntent object ID. The PaymentIntent object in turn has the PaymentMethod that you need. So you need to go from CheckoutSession -> PaymentIntent -> PaymentMethod to get the billing details.
How to do this: In your webhook event handler, retrieve [0] the PaymentIntent and expand
the PaymentMethod (by passing expand: ['payment_method']
).
The PaymentMethod has the billing details under the billing_details
hash [2]
[0] https://stripe.com/docs/api/payment_intents/retrieve
[1]https://stripe.com/docs/api/expanding_objects
[2] https://stripe.com/docs/api/payment_methods/object#payment_method_object-billing_details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With