-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex4.html
More file actions
143 lines (138 loc) · 5.84 KB
/
index4.html
File metadata and controls
143 lines (138 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>アドレス帳、お支払い方法 | アマゾンペイメント、サンプルプログラム | Amazon Payments</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"
integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script type="text/javascript">
function getURLParameter(name, source) {
console.log("getURLParameter", name, source);
return decodeURIComponent((new RegExp('[?|&|#]' + name + '=' +
'([^&]+?)(&|#|;|$)').exec(source) || [, ""])[1].replace(/\+/g, '%20')) || null;
}
var accessToken = getURLParameter("access_token", location.hash);
if (typeof accessToken === 'string' && accessToken.match(/^Atza/)) {
document.cookie = "amazon_Login_accessToken=" + accessToken +";secure";
} else {
accessToken = getURLParameter("access_token", location.href);
}
window.onAmazonLoginReady = function() {
amazon.Login.setClientId('amzn1.application-oa2-client.242a859efb5f47f09847f3f0aebd50ca');
amazon.Login.setRegion('APAC');
amazon.Login.setLanguage('en_US');
amazon.Login.setUseCookie(true);
if (accessToken) {
amazon.Login.retrieveProfile(accessToken, function (response){
if (response.success) {
document.getElementById('profile').innerHTML =
response.profile.Name + " : " + response.profile.PostalCode
+ "<br />"
+ response.profile.PrimaryEmail;
}
});
}
}
</script>
</head>
<body>
<!-- sandbox -->
<!-- <script type='text/javascript'
src='https://origin-na.ssl-images-amazon.com/images/G/09/EP/offAmazonPayments/sandbox/prod/lpa/js/Widgets.js?sellerId=A23YM23UEBY8FM'>
</script> -->
<script type='text/javascript'
src='https://static-fe.payments-amazon.com/OffAmazonPayments/jp/lpa/js/Widgets.js'>
</script>
<div class="container">
<div class="jumbotron">
<h2 class="text-center">アマゾンペイメント、サンプルプログラム (本番)</h2>
<span>アドレス帳、お支払い方法を使ったサンプルプログラムです。</span>
<div class="row">
<div class="col-md-6 text-right">
<div id="AmazonPayButton"></div>
</div>
<div class="col-md-6">
<button type="button" name="button" id="AmazonLogoutButton" class="btn btn-danger"> Logout</button>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<input type="checkbox" name="name" id="popupFlg" value="1" checked="checked"> popup flg
<p>amazon.Login.retrieveProfile</p>
<h4 id="profile"></h4>
<h4>OrderReferenceId <span id='orderReferenceId'></span></h4>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div id="addressBookWidgetDiv" style="height:200px"></div>
<script type="text/javascript">
new OffAmazonPayments.Widgets.AddressBook({
sellerId: "A23YM23UEBY8FM",
onOrderReferenceCreate: function (orderReference) {
document.getElementById('orderReferenceId').innerHTML =
orderReference.getAmazonOrderReferenceId();
},
onAddressSelect: function (orderReference) {
console.log("onAddressSelect:orderReference", orderReference)
},
design: {
designMode: 'responsive'
},
onError: function (error) {
// your error handling code
console.log(error.getErrorCode());
console.log(error.getErrorMessage());
}
}).bind("addressBookWidgetDiv");
</script>
</div>
<div class="col-md-6">
<div id="walletWidgetDiv" style="height:200px" ng-show="orderReferenceId"></div>
<script type="text/javascript">
new OffAmazonPayments.Widgets.Wallet({
sellerId: "A23YM23UEBY8FM",
onPaymentSelect: function (orderReference) {
},
design: {
designMode: 'responsive'
},
onError: function (error) {
// your error handling code
console.log(error.getErrorCode());
console.log(error.getErrorMessage());
}
}).bind("walletWidgetDiv");
</script>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var authRequest;
var win = OffAmazonPayments.Button("AmazonPayButton", "A23YM23UEBY8FM", {
type: "LwA",
authorization: function() {
var flg = document.getElementById("popupFlg").checked;
loginOptions = {
scope: "profile postal_code",
response_type: 'token',
state: "johna:test",
popup: flg
};
authRequest = amazon.Login.authorize (loginOptions, "/index4.html");
}
});
document.getElementById('AmazonLogoutButton').addEventListener("click", function () {
amazon.Login.logout();
// document.cookie = "amazon_Login_accessToken=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
window.location.href = "/index4.html";
});
</script>
</body>
</html>