Chromium Code Reviews| 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; | |
|
please use gerrit instead
2017/04/20 21:23:13
No need.
sebsg
2017/04/20 21:27:46
Done.
| |
| 32 | |
| 33 request.addEventListener('shippingaddresschange', function(evt) { | |
| 34 evt.updateWith(new Promise(function(resolve) { | |
| 35 shippingAddressChange = request.shippingAddress; | |
| 36 print(JSON.stringify(shippingAddressChange, undefined, 2)); | |
|
please use gerrit instead
2017/04/20 21:23:13
Use request.shippingAddress directly.
sebsg
2017/04/20 21:27:46
Done.
| |
| 37 resolve(details); | |
| 38 })); | |
| 39 }); | |
| 40 | |
| 41 request.show(); | |
| 42 } catch (error) { | |
| 43 print(error.message); | |
| 44 } | |
| 45 } | |
| OLD | NEW |