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 12 matching lines...) Expand all Loading... |
23 [{supportedMethods: ['visa']}], details, {requestShipping: true}); | 23 [{supportedMethods: ['visa']}], details, {requestShipping: true}); |
24 | 24 |
25 request.addEventListener('shippingaddresschange', function(evt) { | 25 request.addEventListener('shippingaddresschange', function(evt) { |
26 evt.updateWith(new Promise(function(resolve) { | 26 evt.updateWith(new Promise(function(resolve) { |
27 resolve(updateDetails(details, request.shippingAddress)); | 27 resolve(updateDetails(details, request.shippingAddress)); |
28 })); | 28 })); |
29 }); | 29 }); |
30 | 30 |
31 request.show() | 31 request.show() |
32 .then(function(resp) { | 32 .then(function(resp) { |
33 resp.complete(true) | 33 resp.complete("success") |
34 .then(function() { | 34 .then(function() { |
35 print(request.shippingOption + '<br>' + | 35 print(request.shippingOption + '<br>' + |
36 JSON.stringify( | 36 JSON.stringify( |
37 toDictionary(request.shippingAddress), undefined, 2) + | 37 toDictionary(request.shippingAddress), undefined, 2) + |
38 '<br>' + resp.methodName + '<br>' + | 38 '<br>' + resp.methodName + '<br>' + |
39 JSON.stringify(resp.details, undefined, 2)); | 39 JSON.stringify(resp.details, undefined, 2)); |
40 }) | 40 }) |
41 .catch(function(error) { | 41 .catch(function(error) { |
42 print(error.message); | 42 print(error.message); |
43 }); | 43 }); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 details.displayItems.splice(0, 0, shippingOption); | 79 details.displayItems.splice(0, 0, shippingOption); |
80 } else { | 80 } else { |
81 details.displayItems.splice(0, 1, shippingOption); | 81 details.displayItems.splice(0, 1, shippingOption); |
82 } | 82 } |
83 details.shippingOptions = [shippingOption]; | 83 details.shippingOptions = [shippingOption]; |
84 } else { | 84 } else { |
85 delete details.shippingOptions; | 85 delete details.shippingOptions; |
86 } | 86 } |
87 return details; | 87 return details; |
88 } | 88 } |
OLD | NEW |