我已经在Magento2.3上安装了Klarna Checkout v7,但出现错误:
Client error: 'POST https:\/\/api.klarna.com\/checkout\/v3\/orders' resulted in a '401 Unauthorized' response","code":401,"file":"\/var\/www\/vhosts\/missyminx.co.uk\/htdocs\/vendor\/guzzlehttp\/guzzle\/src\/Exception\/RequestException.php","line":113
我研究了Klarnas API,并创建了一个curl请求以验证凭据,通过curl运行它后,API密钥和私钥是否正确:
curl -u key:secret_key -X POST https://api.klarna.com/checkout/v3/
{
"purchase_country": "GB",
"purchase_currency": "GBP",
"locale": "en-GB",
"gui": {
"options": null
},
"options": {
"color_button": "#0072CC",
"color_button_text": "#ffffff",
"color_checkbox": "#0072CC",
"color_checkbox_checkmark": "#ffffff",
"color_header": "#0072CC",
"color_link": "#ffffff",
"radius_border": "0px",
"allow_separate_shipping_address": false,
"phone_mandatory": false,
"national_identification_number_mandatory": false,
"date_of_birth_mandatory": false,
"require_validate_callback_success": true,
"title_mandatory": false,
"shipping_in_iframe": false,
"additional_checkbox": null
},
"order_amount": 2399,
"order_lines": [
{
"reference": "100167-8",
"name": "Test Product I",
"discount_rate": 0,
"product_url": "https://www.your_website.com/test-product-i",
"image_url": "https://www.your_website.com/media/catalog/product/1/9/190212_031.jpg",
"tax_rate": 0,
"total_tax_amount": 0,
"type": "physical",
"quantity": 1,
"unit_price": 2000,
"total_amount": 2000
},
{
"type": "shipping_fee",
"reference": "flatrate_flatrate",
"name": "Shipping & Handling (UK Tracked)",
"quantity": 1,
"unit_price": 399,
"tax_rate": 0,
"total_amount": 399,
"total_tax_amount": 0
}
],
"order_tax_amount": 0,
"shipping_countries": [
"GB"
],
"merchant_urls": {
"terms": "https://www.your_website.com/terms",
"checkout": "https://www.your_website.com/checkout/klarna",
"confirmation": "https://www.your_website.com/checkout/klarna/confirmation/id/{checkout.order.id}",
"push": "https://www.your_website.com/kco/api/push/id/{checkout.order.id}",
"address_update": "https://www.your_website.com/kco/api/addressUpdate/id/{checkout.order.id}",
"validation": "https://www.your_website.com/kco/api/validate/id/{checkout.order.id}",
"notification": "https://www.your_website.com/kco/api/notification/id/{checkout.order.id}",
"cancellation_terms": "https://www.your_website.com/terms"
}
}
有什么想法可以解决这个问题吗?
答案 0 :(得分:0)
在调试之后,我注意到{checkout.order.id}变量不会仅在来宾结帐模式下提取信息。
因此解决方案是转到:
商店>配置>销售>结帐>结帐选项,并设置: 允许访客结帐:否