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

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

Issue 2623653003: [Payments] Move Payment Request test files to chrome/test/data/payments (Closed)
Patch Set: Created 3 years, 11 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
(Empty)
1 /*
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
4 * found in the LICENSE file.
5 */
6
7 /* global PaymentRequest:false */
8 /* global toDictionary:false */
9
10 var request;
11
12 /**
13 * Launches the PaymentRequest UI that accepts credit cards.
14 */
15 function ccBuy() { // eslint-disable-line no-unused-vars
16 try {
17 var details = {
18 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
19 shippingOptions: [{
20 id: 'freeShippingOption',
21 label: 'Free global shipping',
22 amount: {currency: 'USD', value: '0'},
23 selected: true
24 }]
25 };
26 request = new PaymentRequest(
27 [{supportedMethods: ['visa']}], {
28 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
29 shippingOptions: [{
30 id: 'freeShippingOption',
31 label: 'Free global shipping',
32 amount: {currency: 'USD', value: '0'},
33 selected: true
34 }]
35 },
36 {requestShipping: true});
37 request.show()
38 .then(function(resp) {
39 return resp.complete('success')
40 }).then(function() {
41 print(
42 resp.shippingOption + '<br>' +
43 JSON.stringify(
44 toDictionary(resp.shippingAddress), undefined, 2) +
45 '<br>' + resp.methodName + '<br>' +
46 JSON.stringify(resp.details, undefined, 2));
47 }).catch(function(error) {
48 print(error);
49 });
50 request.addEventListener('shippingaddresschange', function(e) {
51 e.updateWith(new Promise(function(resolve) {
52 // No changes in price based on shipping address change.
53 resolve(details);
54 }));
55 })
56 } catch (error) {
57 print(error.message);
58 }
59 }
60
61 /**
62 * Launches the PaymentRequest UI which accepts only Android Pay.
63 */
64 function androidPayBuy() { // eslint-disable-line no-unused-vars
65 try {
66 request = new PaymentRequest(
67 [{supportedMethods: ['https://android.com/pay']}], {
68 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
69 shippingOptions: [{
70 id: 'freeShippingOption',
71 label: 'Free global shipping',
72 amount: {currency: 'USD', value: '0'},
73 selected: true
74 }]
75 },
76 {requestShipping: true});
77 request.show()
78 .then(function(resp) {
79 return resp.complete('success');
80 }).then(function() {
81 print(
82 resp.shippingOption + '<br>' +
83 JSON.stringify(
84 toDictionary(resp.shippingAddress), undefined, 2) +
85 '<br>' + resp.methodName + '<br>' +
86 JSON.stringify(resp.details, undefined, 2));
87 }).catch(function(error) {
88 print(error);
89 });
90 } catch (error) {
91 print(error.message);
92 }
93 }
94
95 /**
96 * Launches the PaymentRequest UI which accepts only an unsupported payment
97 * method.
98 */
99 function noSupported() { // eslint-disable-line no-unused-vars
100 try {
101 request = new PaymentRequest(
102 [{supportedMethods: ['https://randompay.com']}], {
103 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
104 shippingOptions: [{
105 id: 'freeShippingOption',
106 label: 'Free global shipping',
107 amount: {currency: 'USD', value: '0'},
108 selected: true
109 }]
110 },
111 {requestShipping: true});
112 request.show()
113 .then(function(resp) {
114 return resp.complete('success');
115 }).then(function() {
116 print(
117 resp.shippingOption + '<br>' +
118 JSON.stringify(
119 toDictionary(resp.shippingAddress), undefined, 2) +
120 '<br>' + resp.methodName + '<br>' +
121 JSON.stringify(resp.details, undefined, 2));
122 }).catch(function(error) {
123 print(error);
124 });
125 } catch (error) {
126 print(error.message);
127 }
128 }
129
130 /**
131 * Aborts the current PaymentRequest.
132 */
133 function abort() { // eslint-disable-line no-unused-vars
134 try {
135 request.abort().then(function() {
136 print('Aborted');
137 }).catch(function() {
138 print('Cannot abort');
139 });
140 } catch (error) {
141 print(error.message);
142 }
143 }
OLDNEW
« no previous file with comments | « chrome/test/data/android/payments/free_shipping.js ('k') | chrome/test/data/android/payments/name.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698