3

亚马逊支付小部件的集成存在问题。我正在尝试加载通讯簿小部件。这是带有登录按钮和小部件的页面代码:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type='text/javascript'>
        window.onAmazonLoginReady = function() {
            amazon.Login.setClientId('amzn1.application-oa2-client.96328af648a14ee984ff2529df2906b2');
            amazon.Login.setUseCookie(true);
        };
        window.onAmazonPaymentsReady = function() {
            showButton();
        };
    </script>
    <script async="async" src='https://static-fe.payments-amazon.com/OffAmazonPayments/jp/js/Widgets.js'>
    </script>
</head>
<body>
<div id="AmazonPayButton"></div>
<a href="#" id="Logout">Logout</a>
<div id="addressBookWidgetDiv" style="height: 400px;"></div>
<script type="text/javascript">
    function showButton() {
        var authRequest;
        OffAmazonPayments.Button("AmazonPayButton", "AC0ND72N3R7GI", {
            type: "LwA",
            color: "Gold",
            size: "medium",

            authorization: function () {
                loginOptions = {
                    scope: "profile",
                    popup: true
                };
                authRequest = amazon.Login.authorize(loginOptions, function(){
                    new OffAmazonPayments.Widgets.AddressBook({
                        sellerId: 'AC0ND72N3R7GI',
                        onOrderReferenceCreate: function(orderReference) {

                        },
                        design: {
                            designMode: 'responsive'
                        },
                        onError: function(error) {
                            console.log(error.getErrorCode() + ': ' + error.getErrorMessage());
                        }
                    }).bind("addressBookWidgetDiv");
                });
            },
            onError: function (error) {
                console.log("The following error occurred: "
                        + error.getErrorCode()
                        + ' - ' + error.getErrorMessage());
            }
        });
    }
</script>
<script type="text/javascript">
    document.getElementById('Logout').onclick = function() {
        amazon.Login.logout();
    };
</script>
</body>
</html>

登录弹出窗口正常显示,但小部件未加载并出现以下错误:

买家与亚马逊的会话已过期。买家必须在您呈现小部件之前登录。

如果我切换到沙盒环境并使用测试帐户,也会发生同样的错误。(请注意,我使用的是日文版的 widgets.js 插件,因为卖家账户在日本地区)。期待一些帮助,谢谢。

4

0 回答 0