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 /* global toDictionary:false */ | 8 /* global toDictionary:false */ |
9 | 9 |
10 /** | 10 /** |
(...skipping 11 matching lines...) Expand all Loading... |
22 }, | 22 }, |
23 { | 23 { |
24 id: 'total', | 24 id: 'total', |
25 label: 'Total', | 25 label: 'Total', |
26 amount: {currency: 'USD', value: '5.00'} | 26 amount: {currency: 'USD', value: '5.00'} |
27 } | 27 } |
28 ] | 28 ] |
29 }; | 29 }; |
30 | 30 |
31 var request = | 31 var request = |
32 new PaymentRequest(['visa'], details, {requestShipping: true}); | 32 new PaymentRequest([{supportedMethods: ['visa']}], details, {requestShip
ping: true}); |
33 | 33 |
34 request.addEventListener('shippingaddresschange', function(evt) { | 34 request.addEventListener('shippingaddresschange', function(evt) { |
35 evt.updateWith(new Promise(function(resolve) { | 35 evt.updateWith(new Promise(function(resolve) { |
36 resolve(updateDetails(details, request.shippingAddress)); | 36 resolve(updateDetails(details, request.shippingAddress)); |
37 })); | 37 })); |
38 }); | 38 }); |
39 | 39 |
40 request.show() | 40 request.show() |
41 .then(function(resp) { | 41 .then(function(resp) { |
42 resp.complete(true) | 42 resp.complete(true) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 details.items.splice(-1, 0, shippingOption); | 87 details.items.splice(-1, 0, shippingOption); |
88 } else { | 88 } else { |
89 details.items.splice(-2, 1, shippingOption); | 89 details.items.splice(-2, 1, shippingOption); |
90 } | 90 } |
91 details.shippingOptions = [shippingOption]; | 91 details.shippingOptions = [shippingOption]; |
92 } else { | 92 } else { |
93 delete details.shippingOptions; | 93 delete details.shippingOptions; |
94 } | 94 } |
95 return details; | 95 return details; |
96 } | 96 } |
OLD | NEW |