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

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

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

Powered by Google App Engine
This is Rietveld 408576698