How To Add Shipping And Delivery Addresses With Stripe
I'm trying to create an E-commerce website with JavaScript, React, and Stripe. For the life of me I can't figure out how to include a billing and shipping address in my checkout. I
Solution 1:
Stripe doesn't have an element to collect billing details directly but it's something you can build yourself in your form. Assuming you collect the relevant fields, you would pass the information at the time you call confirmCardPayment
as documented here by passing the billing_details
parameter:
constpayload=awaitstripe.confirmCardPayment(clientSecret, {
payment_method: {
card:elements.getElement(CardElement),
billing_details: {
name:'Jenny Rosen',
address: {
line1:'1 Main street',
city:'San Francisco',
postal_code:'90210',
state:'CA',
country:'US',
},
},
},
});
Similarly, you can pass the shipping details in the same call in the shipping
parameter
constpayload=awaitstripe.confirmCardPayment(clientSecret, {
payment_method: {
card:elements.getElement(CardElement),
},
shipping: {
name:'Jenny Shipping',
address: {
line1:'1 Main street',
city:'San Francisco',
postal_code:'90210',
state:'CA',
country:'US',
},
},
});
You can combine both in one call.
Post a Comment for "How To Add Shipping And Delivery Addresses With Stripe"