我正在我的 web 应用程序中实现 Klarna Checkout。后端使用 aws 无服务器。前端:反应。我被困在创建订单上。它在邮递员内部工作正常,但我无法获得基本的身份验证工作 axios。
出于测试目的,我从我的反应应用程序发布订单。一旦我让它工作,它将被移动到后端。
我的 axios 代码如下所示。
axios
.post(
"https://api.playground.klarna.com/checkout/v3/orders",
{
purchase_country: "DE",
purchase_currency: "EUR",
locale: "de-DE",
order_amount: 3,
order_tax_amount: 0,
order_lines: [
{
type: "digital",
reference: "Test",
name: "Test Subscription",
quantity: 1,
quantity_unit: "pcs",
unit_price: 3,
tax_rate: 0,
total_amount: 3,
total_discount_amount: 0,
total_tax_amount: 0
}
],
merchant_urls: {
terms: "https://www.example.com/terms.html",
checkout: "https://www.example.com/checkout.html",
confirmation: "https://www.example.com/confirmation.html",
push: "https://www.example.com/api/push"
}
},
{
auth: {
username: "xxx",
password: "xxx"
},
headers: {
"Content-Type": "application/json"
}
}
)
.then(result => console.dir(result));
我在 OPTIONS 收到 401 错误。
我得到的回应。
我用邮递员试过了,效果很好。