I am building an e-commerce site with reactjs and commerce.js. Currently I'm testing the checkout process using Stripe. The commerce.js docs describe the capture() method and specifically state that the billing information is optional. It says nothing about a customer.id being necessary to bypass billing info. Yet I get this error when I call commerce.checkout.capture(tokenId, orderData); without inserting billing info into orderData:
Validation/missing fields
billing.country: The Billing country field is required when customer.id is not present.
Here is the shape of my orderData with no billing info. Note that I get the above error for all missing billing fields. Just trying to shorten the question. If I add orderData.billing and duplicate the shipping section, the checkout works fine. Would like to avoid this if possible though. Anyone know why I'm getting this error?
const orderData = {
line_items: checkout_token.line_items,
customer: {
firstname: firstname,
lastname: lastname,
email: email,
},
shipping: {
name: name_s,
street: street_s,
town_city: city_s,
county_state: state_s,
postal_zip_code: zip_code_s,
country: country_s,
},
fulfillment: {
shipping_method: shipping_option.id,
},
payment: {
gateway: "stripe",
stripe: {
payment_method_id: paymentMethod.id,
},
},
};