I've been trying to build an Ecommerce website using Commerce JS. I'm stuck at 'Capturing Order' phase. Here is my orderData code that I'm sending to Commerce JS to capture, but it returns an error code of 401 & 422. 1st error is this:
{
"status_code": 401,
"error": {
"message": "You did not provide an API key. You need to provide your API key in the X-Authorization header (e.g. 'X-Authorization: YOUR_API_KEY').",
"type": "authentication_error"
}
}
Now if I've not provided API key then how am I able to use other functions of Commerce JS.
2nd error is: 'Line item ID not found', on the contrary line item ID is present with each item and it is maintained by Commmerce.js itself, I can see the line item ID in my console.
line_items : checkoutToken.live.line_items,
customer: {
firstname : shippingData.firstName,
lastname: shippingData.lastName,
email: shippingData.email
},
shipping: {
name :"Primary",
street: shippingData.address1,
town_city: shippingData.city,
county_state: shippingData.shippingSubdivision,
postal_zip_code: shippingData.zip,
country: shippingData.shippingCountry
},
fulfillment: {
shipping_method: shippingData.shippingOption
},
billing:{
"name": "John Doe",
"street": "234 Fake St",
"town_city": "San Francisco",
"county_state": "US-CA",
"postal_zip_code": "94103",
"country": "US"
},
payment : {
gateway: 'stripe',
stripe: {
payment_method_id: paymentMethod.id
}
}