-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdemo-simple.html
81 lines (78 loc) · 2.42 KB
/
demo-simple.html
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
<!DOCTYPE html>
<html>
<head>
<title>Simple request with no shipping</title>
<link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/vs.min.css">
<style>
#script-display { padding-left: 40px; position: relative; }
#script-display .line { position: absolute; left: 0; width: 30px; text-align: right; display: inline-block; padding-right:3px; border-right: 1px solid grey; }
</style>
<script src="lib/paymentrequest.js"></script>
<script>
function go1() {
window.__walletUrl = "lib/wallet.html";
go();
}
function go2() {
window.__walletUrl = "lib/wallet2.html";
go();
}
function go3() {
window.__walletUrl = "lib/wallet3.html";
go();
}
</script>
<script language="javascript" id="payment-script">
function go() {
var request = new PaymentRequest(
[{
supportedMethods:['urn:payment:visa','urn:payment:mc','urn:payment:amex']
}],
{
total: {
label: "Total due",
amount: { currencyCode: "USD", value: "60.00" }, // US$60.00
}
}
);
request.show()
.then(function(response) {
// process transaction response here
return response.complete(true);
})
.then(function() {
alert("Buy!");
})
.catch(function(e) {
alert(e.name);
});
}
</script>
</head>
<body style="margin:1em;">
<a href="index.html">Index</a>
<h2>Simple request with no shipping</h2>
<button class="btn btn-success" onclick="go1()">Sample 1: Browser UX</button>
<button class="btn btn-success" onclick="go2()">Sample 2: Payment App UX</button>
<button class="btn btn-success" onclick="go3()">Sample 3: Prices differ by method</button>
<div>
<h3>Script</h3>
<pre><code id="script-display"></code></pre>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
<script>
document.getElementById("script-display").textContent = document.getElementById("payment-script").text;
hljs.initHighlighting();
function number(e) {
var l = 0;
var html = e.innerHTML.replace(/\n/g,function() {
l++;
return "\n" + '<a class="line" name="L' + l + '" href="#L' + l + '">' + l + '</a>';
});
e.innerHTML = html;
}
number(document.getElementById("script-display"));
</script>
</body>
</html>