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( | 35 print( |
36 JSON.stringify(resp.totalAmount, undefined, 2) + '<br>' + | 36 JSON.stringify(resp.totalAmount, undefined, 2) + '<br>' + |
37 request.shippingOption + '<br>' + | 37 request.shippingOption + '<br>' + |
38 JSON.stringify( | 38 JSON.stringify( |
39 toDictionary(resp.shippingAddress), undefined, 2) + | 39 toDictionary(resp.shippingAddress), undefined, 2) + |
40 '<br>' + resp.methodName + '<br>' + | 40 '<br>' + resp.methodName + '<br>' + |
41 JSON.stringify(resp.details, undefined, 2)); | 41 JSON.stringify(resp.details, undefined, 2)); |
42 }) | 42 }) |
43 .catch(function(error) { | 43 .catch(function(error) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 details.displayItems.splice(0, 0, shippingOption); | 81 details.displayItems.splice(0, 0, shippingOption); |
82 } else { | 82 } else { |
83 details.displayItems.splice(0, 1, shippingOption); | 83 details.displayItems.splice(0, 1, shippingOption); |
84 } | 84 } |
85 details.shippingOptions = [shippingOption]; | 85 details.shippingOptions = [shippingOption]; |
86 } else { | 86 } else { |
87 delete details.shippingOptions; | 87 delete details.shippingOptions; |
88 } | 88 } |
89 return details; | 89 return details; |
90 } | 90 } |
OLD | NEW |