Having problem with intergration of amazon pay widgets. I'm trying to load Address Book Widget. Here's the code from page with login button and a widget:
<!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>
The login popup window appears normally, but the widget doesn't load with the following error:
Buyer's session with Amazon has expired. The buyer must sign in before you render the widget.
Same error also occurs if I switch to sandbox environment and use test account. (Note that I'm using japanese version of widgets.js plugin because seller account is in Japan region). Looking forward for some help, thank you.