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 10 matching lines...) Expand all Loading... |
21 amount: {currency: 'USD', value: '5.00'} | 21 amount: {currency: 'USD', value: '5.00'} |
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 = new PaymentRequest( |
32 new PaymentRequest(['visa'], details, {requestShipping: true}); | 32 [{supportedMethods: ['visa']}], details, {requestShipping: 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 details.items.splice(-1, 0, shippingOption); | 88 details.items.splice(-1, 0, shippingOption); |
89 } else { | 89 } else { |
90 details.items.splice(-2, 1, shippingOption); | 90 details.items.splice(-2, 1, shippingOption); |
91 } | 91 } |
92 details.shippingOptions = [shippingOption]; | 92 details.shippingOptions = [shippingOption]; |
93 } else { | 93 } else { |
94 delete details.shippingOptions; | 94 delete details.shippingOptions; |
95 } | 95 } |
96 return details; | 96 return details; |
97 } | 97 } |
OLD | NEW |