OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>Payment App: Test for invoking payment app</title> | 2 <title>Payment App: Test for invoking payment app</title> |
3 <script src="./result_queue.js"></script> | 3 <script src="./result_queue.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 function registerPaymentApp() { | 6 function registerPaymentApp() { |
7 navigator.serviceWorker.register('payment_app.js', { scope: './' }) | 7 navigator.serviceWorker.register('payment_app.js', { scope: './' }) |
8 .then(() => { | 8 .then(() => { |
9 return navigator.serviceWorker.ready; | 9 return navigator.serviceWorker.ready; |
10 }) | 10 }) |
11 .then(registration => { | 11 .then(registration => { |
12 return registration.paymentManager.instruments.set('payment-app-id', { | 12 return registration.paymentManager.instruments.set('payment-app-id', { |
13 name: 'Visa ****', | 13 name: 'Visa ****', |
14 enabledMethods: ['visa'] | 14 enabledMethods: ['basic-card'] |
15 }); | 15 }); |
16 }) | 16 }) |
17 .then(result => { | 17 .then(result => { |
18 sendResultToTest('registered'); | 18 sendResultToTest('registered'); |
19 }) | 19 }) |
20 .catch(result => { | 20 .catch(result => { |
21 sendResultToTest('error'); | 21 sendResultToTest('error'); |
22 }); | 22 }); |
23 } | 23 } |
24 | 24 |
25 var resultQueue = new ResultQueue(); | 25 var resultQueue = new ResultQueue(); |
26 navigator.serviceWorker.addEventListener('message', e => { | 26 navigator.serviceWorker.addEventListener('message', e => { |
27 resultQueue.push(e.data); | 27 resultQueue.push(e.data); |
28 }); | 28 }); |
29 | 29 |
30 </script> | 30 </script> |
OLD | NEW |