【发布时间】:2021-06-01 22:00:36
【问题描述】:
我一直在尝试使用 Commerce JS 构建电子商务网站。我被困在“捕获订单”阶段。这是我发送给 Commerce JS 以捕获的 orderData 代码,但它返回错误代码 401 和 422。第一个错误是:
{
"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"
}
}
现在,如果我没有提供 API 密钥,那我怎么能使用 Commerce JS 的其他功能。
第二个错误是: “找不到订单项 ID”,相反,订单项 ID 存在于每个项目中,并且由 Commmerce.js 自己维护,我可以在控制台中看到订单项 ID。
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
}
}
【问题讨论】:
标签: javascript e-commerce commerce commerce.js