It's not possible to get the billing address in shipping mode
Closed this issue · 4 comments
What happened?
I use AddressElement with shipping mode and PaymentElement. In such case there is Billing is same as shipping information checkbox. When I uncheck it, two fields appear, country and postal code. But there is no way to get the billing address.
On AddressElement change it returns this object:
{
"elementType": "address",
"elementMode": "shipping",
"value": {
"name": "",
"phone": "",
"address": {
"line1": "",
"line2": null,
"city": "",
"country": "US",
"postal_code": "",
"state": ""
},
"firstName": "",
"lastName": ""
},
"empty": false,
"complete": false,
"isNewAddress": true
}
On PaymentElement change it returns this object:
{
"elementType": "payment",
"collapsed": false,
"empty": false,
"complete": true,
"value": {
"type": "card"
}
}
Environment
No response
Reproduction
No response
The billing details collected by the Payment Element will be on the Payment Method attached to the Payment Intent after the payment is confirmed.
https://docs.stripe.com/api/payment_methods/object#payment_method_object-billing_details
The billing details collected by the Payment Element will be on the Payment Method attached to the Payment Intent after the payment is confirmed.
https://docs.stripe.com/api/payment_methods/object#payment_method_object-billing_details
@bredmond-stripe, thank you for your answer, I've checked stripe.confirmPayment
and stripe.retrievePaymentIntent
methods return Payment Intent but without attached Payment Method, I see only payment method string id there.
I didn't find a way to get Payment Method object.
You can use expansion to have the payment_method
returned as the object instead of the string ID: https://docs.stripe.com/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-expand
stripe.confirmPayment({
elements,
confirmParams: {
expand: ['payment_method'],
return_url: 'https://example.com',
},
})
expand: ['payment_method'],
@brendanm-stripe, thank you so much! It works!