0

我在 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 请求来验证凭据、API 密钥和密钥在通过 curl 运行后是否正确:

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"
  }
}

问题可能出在哪里?

4

1 回答 1

0

调试后,我注意到 {checkout.order.id} 变量仅在访客结帐模式下不提取信息。

所以解决办法是去:

商店 > 配置 > 销售 > 结帐 > 结帐选项并设置:允许访客结帐:否

于 2019-03-01T13:20:01.013 回答