OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>No Shipping Test</title> | 4 <title>No Shipping Test</title> |
5 <meta charset="utf-8"> | 5 <meta charset="utf-8"> |
6 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scal
e=1"> | 6 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scal
e=1"> |
7 <style> | 7 <style> |
8 button { | 8 button { |
9 width: 100%; | 9 width: 100%; |
10 height: 5em; | 10 height: 5em; |
11 font-size: 3em; | 11 font-size: 3em; |
12 } | 12 } |
13 </style> | 13 </style> |
14 </head> | 14 </head> |
15 <body> | 15 <body> |
16 <button onclick="buy()" id="buy">No Shipping Test</button> | 16 <button onclick="buy()" id="buy">No Shipping Test</button> |
17 <script> | 17 <script> |
18 function print(msg) { | 18 function print(msg) { |
19 document.open(); | 19 document.open(); |
20 document.write('<pre id="result" style="font-size: 2em;">' + msg + '</pre>'); | 20 document.write('<pre id="result" style="font-size: 2em;">' + msg + '</pre>'); |
21 document.close(); | 21 document.close(); |
22 } | 22 } |
23 function buy() { | 23 function buy() { |
24 try { | 24 try { |
25 new PaymentRequest(['visa'], { | 25 new PaymentRequest(['visa'], { |
26 'items' : [ { | 26 'items' : [ { |
27 'id' : 'total', | 27 'id' : 'total', |
28 'label' : 'Total', | 28 'label' : 'Total', |
29 'amount' : {'currencyCode' : 'USD', 'value' : '5.00'} | 29 'amount' : {'currency' : 'USD', 'value' : '5.00'} |
30 } ] | 30 } ] |
31 }) | 31 }) |
32 .show() | 32 .show() |
33 .then(function(resp) { | 33 .then(function(resp) { |
34 resp.complete(true) | 34 resp.complete(true) |
35 .then(function() { | 35 .then(function() { |
36 print(resp.methodName + '<br>' + | 36 print(resp.methodName + '<br>' + |
37 JSON.stringify(resp.details, undefined, 2)); | 37 JSON.stringify(resp.details, undefined, 2)); |
38 }) | 38 }) |
39 .catch(function(error) { print(error.message); }); | 39 .catch(function(error) { print(error.message); }); |
40 }) | 40 }) |
41 .catch(function(error) { print(error.message); }); | 41 .catch(function(error) { print(error.message); }); |
42 } catch (error) { | 42 } catch (error) { |
43 print(error.message); | 43 print(error.message); |
44 } | 44 } |
45 } | 45 } |
46 </script> | 46 </script> |
47 </body> | 47 </body> |
48 </html> | 48 </html> |
OLD | NEW |