Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: chrome/test/data/android/payments/dynamic_shipping.js

Issue 2020883002: PaymentRequest: Introduce PaymentMethodData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, 17 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
18 displayItems: 18 displayItems:
19 [{label: 'Subtotal', amount: {currency: 'USD', value: '5.00'}}] 19 [{label: 'Subtotal', amount: {currency: 'USD', value: '5.00'}}]
20 }; 20 };
21 21
22 var request = 22 var request = new PaymentRequest(
23 new PaymentRequest(['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(true)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698