【发布时间】:2020-10-07 14:38:58
【问题描述】:
我正在构建一种 Klarna Payments 的沙盒集成(使其在原则上正常工作,并在以后将逻辑实施到真实商店中)。文档中描述的第一步,session creating,已经奏效。现在我正在尝试显示 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>
目前的结果是这样的:
而不是documentation中显示的预期结果:
但是表格不存在。 如何显示?
更新
刚刚看了看控制台。有一些警告和错误:
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__()
【问题讨论】:
-
您检查过控制台吗?如果未显示表单,Klarna 一定返回了一些错误:developers.klarna.com/documentation/klarna-payments/…
-
@DipenShah 谢谢你的提示!是的,实际上有一个错误。请查看更新后的问题。
-
错误并没有说太多。您能否检查一下加载回调函数中的
res值是什么?此外,我相信pay_later显示了正确的表单,您可能想添加多个付款选项,而不是像:"payment_method_categories": [ "pay_later", "pay_now" ] -
@DipenShah 似乎没问题:
{show_form: true}. -
表示显示正确的表格。让我问一下,您希望展示什么?
标签: payment-gateway payment klarna klarna-widget