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

Side by Side Diff: chrome/test/data/payments/basic_card.js

Issue 2659083003: Relax card type handling. (Closed)
Patch Set: Clarify comment Created 3 years, 10 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 /** 7 /**
8 * Merchant checks for ability to pay using debit cards. 8 * Calls PaymentRequest.canMakePayment() and prints out the result.
9 * @param {sequence<PaymentMethodData>} methodData The supported methods.
10 * @private
9 */ 11 */
10 function checkBasicDebit() { // eslint-disable-line no-unused-vars 12 function canMakePaymentHelper(methodData) {
11 try { 13 try {
12 new PaymentRequest( 14 new PaymentRequest(
13 [{ 15 methodData, {
14 supportedMethods: ['basic-card'],
15 data: {
16 supportedTypes: ['debit'],
17 },
18 }], {
19 total: { 16 total: {
20 label: 'Total', 17 label: 'Total',
21 amount: { 18 amount: {
22 currency: 'USD', 19 currency: 'USD',
23 value: '5.00', 20 value: '5.00',
24 }, 21 },
25 }, 22 },
26 }) 23 })
27 .canMakePayment() 24 .canMakePayment()
28 .then(function(result) { 25 .then(function(result) {
29 print(result); 26 print(result);
30 }) 27 })
31 .catch(function(error) { 28 .catch(function(error) {
32 print(error); 29 print(error);
33 }); 30 });
34 } catch (error) { 31 } catch (error) {
35 print(error); 32 print(error);
36 } 33 }
37 } 34 }
38 35
39 /** 36 /**
37 * Merchant checks for ability to pay using "basic-card" regardless of issuer
38 * network.
39 */
40 function checkBasicCard() { // eslint-disable-line no-unused-vars
41 canMakePaymentHelper([{
42 supportedMethods: ['basic-card'],
43 }]);
44 }
45
46 /**
47 * Merchant checks for ability to pay using debit cards.
48 */
49 function checkBasicDebit() { // eslint-disable-line no-unused-vars
50 canMakePaymentHelper([{
51 supportedMethods: ['basic-card'],
52 data: {
53 supportedTypes: ['debit'],
54 },
55 }]);
56 }
57
58 /**
40 * Merchant checks for ability to pay using "basic-card" with "mastercard" as 59 * Merchant checks for ability to pay using "basic-card" with "mastercard" as
41 * the supported network. 60 * the supported network.
42 */ 61 */
43 function checkBasicMasterCard() { // eslint-disable-line no-unused-vars 62 function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
44 try { 63 canMakePaymentHelper([{
45 new PaymentRequest( 64 supportedMethods: ['basic-card'],
46 [{ 65 data: {
47 supportedMethods: ['basic-card'], 66 supportedNetworks: ['mastercard'],
48 data: { 67 },
49 supportedNetworks: ['mastercard'], 68 }]);
50 },
51 }], {
52 total: {
53 label: 'Total',
54 amount: {
55 currency: 'USD',
56 value: '5.00',
57 },
58 },
59 })
60 .canMakePayment()
61 .then(function(result) {
62 print(result);
63 })
64 .catch(function(error) {
65 print(error);
66 });
67 } catch (error) {
68 print(error);
69 }
70 } 69 }
71 70
72 /** 71 /**
73 * Merchant checks for ability to pay using "basic-card" with "visa" as the 72 * Merchant checks for ability to pay using "basic-card" with "visa" as the
74 * supported network. 73 * supported network.
75 */ 74 */
76 function checkBasicVisa() { // eslint-disable-line no-unused-vars 75 function checkBasicVisa() { // eslint-disable-line no-unused-vars
77 try { 76 canMakePaymentHelper([{
78 new PaymentRequest( 77 supportedMethods: ['basic-card'],
79 [{ 78 data: {
80 supportedMethods: ['basic-card'], 79 supportedNetworks: ['visa'],
81 data: { 80 },
82 supportedNetworks: ['visa'], 81 }]);
83 },
84 }], {
85 total: {
86 label: 'Total',
87 amount: {
88 currency: 'USD',
89 value: '5.00',
90 },
91 },
92 })
93 .canMakePayment()
94 .then(function(result) {
95 print(result);
96 })
97 .catch(function(error) {
98 print(error);
99 });
100 } catch (error) {
101 print(error);
102 }
103 } 82 }
104 83
105 /** 84 /**
106 * Merchant checks for ability to pay using "mastercard". 85 * Merchant checks for ability to pay using "mastercard".
107 */ 86 */
108 function checkMasterCard() { // eslint-disable-line no-unused-vars 87 function checkMasterCard() { // eslint-disable-line no-unused-vars
109 try { 88 canMakePaymentHelper([{
110 new PaymentRequest( 89 supportedMethods: ['mastercard'],
111 [{ 90 }]);
112 supportedMethods: ['mastercard'],
113 }], {
114 total: {
115 label: 'Total',
116 amount: {
117 currency: 'USD',
118 value: '5.00',
119 },
120 },
121 })
122 .canMakePayment()
123 .then(function(result) {
124 print(result);
125 })
126 .catch(function(error) {
127 print(error);
128 });
129 } catch (error) {
130 print(error);
131 }
132 } 91 }
133 92
134 /** 93 /**
135 * Merchant checks for ability to pay using "visa". 94 * Merchant checks for ability to pay using "visa".
136 */ 95 */
137 function checkVisa() { // eslint-disable-line no-unused-vars 96 function checkVisa() { // eslint-disable-line no-unused-vars
97 canMakePaymentHelper([{
98 supportedMethods: ['visa'],
99 }]);
100 }
101
102 /**
103 * Calls PaymentRequest.show() and prints out the result.
104 * @param {sequence<PaymentMethodData>} methodData The supported methods.
105 * @private
106 */
107 function buyHelper(methodData) {
138 try { 108 try {
139 new PaymentRequest( 109 new PaymentRequest(methodData, {
140 [{ 110 total: {
141 supportedMethods: ['visa'], 111 label: 'Total',
142 }], { 112 amount: {
143 total: { 113 currency: 'USD',
144 label: 'Total', 114 value: '5.00',
145 amount: {
146 currency: 'USD',
147 value: '5.00',
148 },
149 }, 115 },
150 }) 116 },
151 .canMakePayment() 117 })
152 .then(function(result) { 118 .show()
153 print(result); 119 .then(function(response) {
120 response.complete('success')
121 .then(function() {
122 print(JSON.stringify(response, undefined, 2));
123 })
124 .catch(function(error) {
125 print(error);
126 });
154 }) 127 })
155 .catch(function(error) { 128 .catch(function(error) {
156 print(error); 129 print(error);
157 }); 130 });
158 } catch (error) { 131 } catch (error) {
159 print(error); 132 print(error);
160 } 133 }
161 } 134 }
162 135
163 /** 136 /**
164 * Merchant requests payment via either "mastercard" or "basic-card" with "visa" 137 * Merchant requests payment via either "mastercard" or "basic-card" with "visa"
165 * as the supported network. 138 * as the supported network.
166 */ 139 */
167 function buy() { // eslint-disable-line no-unused-vars 140 function buy() { // eslint-disable-line no-unused-vars
168 try { 141 buyHelper([{
169 new PaymentRequest( 142 supportedMethods: ['mastercard'],
170 [{ 143 }, {
171 supportedMethods: ['mastercard'], 144 supportedMethods: ['basic-card'],
172 }, { 145 data: {
173 supportedMethods: ['basic-card'], 146 supportedNetworks: ['visa'],
174 data: { 147 },
175 supportedNetworks: ['visa'], 148 }]);
176 },
177 }], {
178 total: {
179 label: 'Total',
180 amount: {
181 currency: 'USD',
182 value: '5.00',
183 },
184 },
185 })
186 .show()
187 .then(function(response) {
188 response.complete('success').then(function() {
189 print(JSON.stringify(response, undefined, 2));
190 }).catch(function(error) {
191 print(error);
192 });
193 })
194 .catch(function(error) {
195 print(error);
196 });
197 } catch (error) {
198 print(error);
199 }
200 } 149 }
201 150
202 /** 151 /**
152 * Merchant requests payment via "basic-card" with any issuer network.
153 */
154 function buyBasicCard() { // eslint-disable-line no-unused-vars
155 buyHelper([{
156 supportedMethods: ['basic-card'],
157 data: {
158 supportedTypes: ['debit'],
159 },
160 }]);
161 }
162
163 /**
203 * Merchant requests payment via "basic-card" with "debit" as the supported card 164 * Merchant requests payment via "basic-card" with "debit" as the supported card
204 * type. 165 * type.
205 */ 166 */
206 function buyBasicDebit() { // eslint-disable-line no-unused-vars 167 function buyBasicDebit() { // eslint-disable-line no-unused-vars
207 try { 168 buyHelper([{
208 new PaymentRequest( 169 supportedMethods: ['basic-card'],
209 [{ 170 data: {
210 supportedMethods: ['basic-card'], 171 supportedTypes: ['debit'],
211 data: { 172 },
212 supportedTypes: ['debit'], 173 }]);
213 },
214 }], {
215 total: {
216 label: 'Total',
217 amount: {
218 currency: 'USD',
219 value: '5.00',
220 },
221 },
222 })
223 .show()
224 .then(function(response) {
225 response.complete('success').then(function() {
226 print(JSON.stringify(response, undefined, 2));
227 }).catch(function(error) {
228 print(error);
229 });
230 })
231 .catch(function(error) {
232 print(error);
233 });
234 } catch (error) {
235 print(error);
236 }
237 } 174 }
238 175
239 /** 176 /**
177 * Merchant requests payment via "basic-card" with "debit" as the supported card
178 * type.
179 */
180 function buyBasicDebit() { // eslint-disable-line no-unused-vars
181 buyHelper([{
182 supportedMethods: ['basic-card'],
183 data: {
184 supportedTypes: ['debit'],
185 },
186 }]);
187 }
188
189 /**
240 * Merchant requests payment via "basic-card" payment method with "mastercard" 190 * Merchant requests payment via "basic-card" payment method with "mastercard"
241 * as the only supported network. 191 * as the only supported network.
242 */ 192 */
243 function buyBasicMasterCard() { // eslint-disable-line no-unused-vars 193 function buyBasicMasterCard() { // eslint-disable-line no-unused-vars
244 try { 194 buyHelper([{
245 new PaymentRequest( 195 supportedMethods: ['basic-card'],
246 [{ 196 data: {
247 supportedMethods: ['basic-card'], 197 supportedNetworks: ['mastercard'],
248 data: { 198 },
249 supportedNetworks: ['mastercard'], 199 }]);
250 },
251 }], {
252 total: {
253 label: 'Total',
254 amount: {
255 currency: 'USD',
256 value: '5.00',
257 },
258 },
259 })
260 .show()
261 .then(function(response) {
262 response.complete('success').then(function() {
263 print(JSON.stringify(response, undefined, 2));
264 }).catch(function(error) {
265 print(error);
266 });
267 })
268 .catch(function(error) {
269 print(error);
270 });
271 } catch (error) {
272 print(error);
273 }
274 } 200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698