Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 The Chromium Authors. All rights reserved. | 2 * Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* global PaymentRequest:false */ | 7 /* global PaymentRequest:false */ |
| 8 | 8 |
| 9 var request; | 9 var request; |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 // No changes in price based on shipping address change. | 46 // No changes in price based on shipping address change. |
| 47 resolve(details); | 47 resolve(details); |
| 48 })); | 48 })); |
| 49 }) | 49 }) |
| 50 } catch (error) { | 50 } catch (error) { |
| 51 print(error.message); | 51 print(error.message); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Launches the PaymentRequest UI which accepts only Android Pay. | 56 * Launches the PaymentRequest UI which accepts only Android Pay and does not |
|
please use gerrit instead
2017/04/13 13:49:47
It's better to add a new function than altering th
sebsg
2017/04/13 19:45:56
Done.
| |
| 57 * require any other information. | |
| 57 */ | 58 */ |
| 58 function androidPayBuy() { // eslint-disable-line no-unused-vars | 59 function androidPayBuy() { // eslint-disable-line no-unused-vars |
| 59 try { | 60 try { |
| 60 request = new PaymentRequest( | 61 request = new PaymentRequest( |
| 61 [{supportedMethods: ['https://android.com/pay']}], { | 62 [{supportedMethods: ['https://android.com/pay']}], { |
| 62 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, | 63 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, |
| 63 shippingOptions: [{ | 64 }); |
| 64 id: 'freeShippingOption', | |
| 65 label: 'Free global shipping', | |
| 66 amount: {currency: 'USD', value: '0'}, | |
| 67 selected: true | |
| 68 }] | |
| 69 }, | |
| 70 {requestShipping: true}); | |
| 71 request.show() | 65 request.show() |
| 72 .then(function(resp) { | 66 .then(function(resp) { |
| 73 return resp.complete('success'); | 67 return resp.complete('success'); |
| 74 }).then(function() { | 68 }).then(function() { |
| 75 print(JSON.stringify(resp, undefined, 2)); | 69 print(JSON.stringify(resp, undefined, 2)); |
| 76 }).catch(function(error) { | 70 }).catch(function(error) { |
| 77 print(error); | 71 print(error); |
| 78 }); | 72 }); |
| 79 } catch (error) { | 73 } catch (error) { |
| 80 print(error.message); | 74 print(error.message); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 try { | 112 try { |
| 119 request.abort().then(function() { | 113 request.abort().then(function() { |
| 120 print('Aborted'); | 114 print('Aborted'); |
| 121 }).catch(function() { | 115 }).catch(function() { |
| 122 print('Cannot abort'); | 116 print('Cannot abort'); |
| 123 }); | 117 }); |
| 124 } catch (error) { | 118 } catch (error) { |
| 125 print(error.message); | 119 print(error.message); |
| 126 } | 120 } |
| 127 } | 121 } |
| OLD | NEW |