| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 /** |
| 8 * Launches the PaymentRequest UI that prints the shipping address received |
| 9 * on shippingAddressChange events at the end of the transaction. |
| 10 */ |
| 11 function buy() { // eslint-disable-line no-unused-vars |
| 12 try { |
| 13 var details = { |
| 14 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, |
| 15 displayItems: [ |
| 16 { |
| 17 label: 'Pending shipping price', |
| 18 amount: {currency: 'USD', value: '0.00'}, |
| 19 pending: true |
| 20 }, |
| 21 { |
| 22 label: 'Subtotal', |
| 23 amount: {currency: 'USD', value: '5.00'} |
| 24 } |
| 25 ] |
| 26 }; |
| 27 |
| 28 var request = new PaymentRequest( |
| 29 [{supportedMethods: ['visa']}], details, {requestShipping: true}); |
| 30 |
| 31 var shippingAddressChange; |
| 32 |
| 33 request.addEventListener('shippingaddresschange', function(evt) { |
| 34 evt.updateWith(new Promise(function(resolve) { |
| 35 print(JSON.stringify(request.shippingAddress, undefined, 2)); |
| 36 resolve(details); |
| 37 })); |
| 38 }); |
| 39 |
| 40 request.show(); |
| 41 } catch (error) { |
| 42 print(error.message); |
| 43 } |
| 44 } |
| OLD | NEW |