我正在构建一种 Klarna Payments 的沙盒集成(使其原则上工作并稍后将逻辑实施到真实商店中)。文档中描述的第一步,会话创建,已经奏效。现在我正在尝试显示 Klarna 小部件:
klarna-widget.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Klarna Widget</title>
</head>
<body>
<script>
window.klarnaAsyncCallback = function () {
Klarna.Payments.init({
client_token: 'evstbGciOiJSUzI1...'
})
Klarna.Payments.load(
{
container: '#klarna-payments-container',
payment_method_category: 'pay_later'
},
function (res) {
console.debug(res);
}
)
};
</script>
<script src="https://x.klarnacdn.net/kp/lib/v1/api.js" async></script>
<div id="klarna-payments-container"></div>
</body>
</html>
当前结果如下所示:
而不是文档中显示的预期结果:
但是表格不存在。如何让它显示?
更新
刚刚看了看控制台。有一些警告和错误:
DevTools failed to load SourceMap: Could not load content for https://x.klarnacdn.net/device-recognition/1f14eaf/main.bundle.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
blob:https://klarna-payments-eu.playground.klarna.com/2ca435b3-87fb-4538-aa91-45c6c94e9243:16
WebSocket connection to 'wss://127.0.0.1:5939/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED
td_zM @ blob:https://klarna-payments-eu.playground.klarna.com/2ca435b3-87fb-4538-aa91-45c6c94e9243:16
(anonymous) @ blob:https://klarna-payments-eu.playground.klarna.com/2ca435b3-87fb-4538-aa91-45c6c94e9243:14
(13) WebSocket connection to '<URL>' failed: WebSocket is closed before the connection is established.
...
但res
对象似乎很好:
{show_form: true}
show_form: true
__proto__:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()