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 const instrumentPromises = [ |
13 name: 'Visa ****', | 13 registration.paymentManager.instruments.set( |
14 enabledMethods: ['basic-card'] | 14 'basic-card-payment-app-id', |
15 }); | 15 { |
| 16 name: 'Visa ****', |
| 17 enabledMethods: ['basic-card'] |
| 18 }), |
| 19 |
| 20 registration.paymentManager.instruments.set( |
| 21 'bobpay-payment-app-id', |
| 22 { |
| 23 name: "Bob Pay", |
| 24 enabledMethods: ['https://bobpay.com'] |
| 25 }), |
| 26 ]; |
| 27 |
| 28 return Promise.all(instrumentPromises); |
16 }) | 29 }) |
17 .then(result => { | 30 .then(result => { |
18 sendResultToTest('registered'); | 31 sendResultToTest('registered'); |
19 }) | 32 }) |
20 .catch(result => { | 33 .catch(result => { |
21 sendResultToTest('error'); | 34 sendResultToTest('error'); |
22 }); | 35 }); |
23 } | 36 } |
24 | 37 |
25 var resultQueue = new ResultQueue(); | 38 var resultQueue = new ResultQueue(); |
26 navigator.serviceWorker.addEventListener('message', e => { | 39 navigator.serviceWorker.addEventListener('message', e => { |
27 resultQueue.push(e.data); | 40 resultQueue.push(e.data); |
28 }); | 41 }); |
29 | 42 |
30 </script> | 43 </script> |
OLD | NEW |