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 /** |
11 * Launches the PaymentRequest UI that offers free shipping in California and | 11 * Launches the PaymentRequest UI that offers free shipping in California and |
12 * $5.00 shipping in US. Does not allow shipping outside of US. | 12 * $5.00 shipping in US. Does not allow shipping outside of US. |
13 */ | 13 */ |
14 function buy() { // eslint-disable-line no-unused-vars | 14 function buy() { // eslint-disable-line no-unused-vars |
15 try { | 15 try { |
16 var details = { | 16 var details = { |
17 items: [ | 17 displayItems: [ |
18 { | 18 { |
19 id: 'sub', | 19 id: 'sub', |
20 label: 'Subtotal', | 20 label: 'Subtotal', |
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 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 function updateDetails(details, addr) { | 69 function updateDetails(details, addr) { |
70 if (addr.regionCode === 'US') { | 70 if (addr.regionCode === 'US') { |
71 var shippingOption = { | 71 var shippingOption = { |
72 id: '', | 72 id: '', |
73 label: '', | 73 label: '', |
74 amount: {currency: 'USD', value: '0.00'} | 74 amount: {currency: 'USD', value: '0.00'} |
75 }; | 75 }; |
76 if (addr.administrativeArea === 'CA') { | 76 if (addr.administrativeArea === 'CA') { |
77 shippingOption.id = 'ca'; | 77 shippingOption.id = 'ca'; |
78 shippingOption.label = 'Free shipping in California'; | 78 shippingOption.label = 'Free shipping in California'; |
79 details.items[details.items.length - 1].amount.value = '5.00'; | 79 details.displayItems[details.displayItems.length - 1].amount.value = |
| 80 '5.00'; |
80 } else { | 81 } else { |
81 shippingOption.id = 'us'; | 82 shippingOption.id = 'us'; |
82 shippingOption.label = 'Standard shipping in US'; | 83 shippingOption.label = 'Standard shipping in US'; |
83 shippingOption.amount.value = '5.00'; | 84 shippingOption.amount.value = '5.00'; |
84 details.items[details.items.length - 1].amount.value = '10.00'; | 85 details.items[details.items.length - 1].amount.value = '10.00'; |
85 } | 86 } |
86 if (details.items.length === 3) { | 87 if (details.items.length === 3) { |
87 details.items.splice(-1, 0, shippingOption); | 88 details.items.splice(-1, 0, shippingOption); |
88 } else { | 89 } else { |
89 details.items.splice(-2, 1, shippingOption); | 90 details.items.splice(-2, 1, shippingOption); |
90 } | 91 } |
91 details.shippingOptions = [shippingOption]; | 92 details.shippingOptions = [shippingOption]; |
92 } else { | 93 } else { |
93 delete details.shippingOptions; | 94 delete details.shippingOptions; |
94 } | 95 } |
95 return details; | 96 return details; |
96 } | 97 } |
OLD | NEW |