| OLD | NEW |
| (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 /** |
| 8 * Merchant checks for ability to pay using debit cards. |
| 9 */ |
| 10 function checkBasicDebit() { // eslint-disable-line no-unused-vars |
| 11 try { |
| 12 new PaymentRequest( |
| 13 [{ |
| 14 supportedMethods: ['basic-card'], |
| 15 data: { |
| 16 supportedTypes: ['debit'], |
| 17 }, |
| 18 }], { |
| 19 total: { |
| 20 label: 'Total', |
| 21 amount: { |
| 22 currency: 'USD', |
| 23 value: '5.00', |
| 24 }, |
| 25 }, |
| 26 }) |
| 27 .canMakePayment() |
| 28 .then(function(result) { |
| 29 print(result); |
| 30 }) |
| 31 .catch(function(error) { |
| 32 print(error); |
| 33 }); |
| 34 } catch (error) { |
| 35 print(error); |
| 36 } |
| 37 } |
| 38 |
| 39 /** |
| 40 * Merchant checks for ability to pay using "basic-card" with "mastercard" as |
| 41 * the supported network. |
| 42 */ |
| 43 function checkBasicMasterCard() { // eslint-disable-line no-unused-vars |
| 44 try { |
| 45 new PaymentRequest( |
| 46 [{ |
| 47 supportedMethods: ['basic-card'], |
| 48 data: { |
| 49 supportedNetworks: ['mastercard'], |
| 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 } |
| 71 |
| 72 /** |
| 73 * Merchant checks for ability to pay using "basic-card" with "visa" as the |
| 74 * supported network. |
| 75 */ |
| 76 function checkBasicVisa() { // eslint-disable-line no-unused-vars |
| 77 try { |
| 78 new PaymentRequest( |
| 79 [{ |
| 80 supportedMethods: ['basic-card'], |
| 81 data: { |
| 82 supportedNetworks: ['visa'], |
| 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 } |
| 104 |
| 105 /** |
| 106 * Merchant checks for ability to pay using "mastercard". |
| 107 */ |
| 108 function checkMasterCard() { // eslint-disable-line no-unused-vars |
| 109 try { |
| 110 new PaymentRequest( |
| 111 [{ |
| 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 } |
| 133 |
| 134 /** |
| 135 * Merchant checks for ability to pay using "visa". |
| 136 */ |
| 137 function checkVisa() { // eslint-disable-line no-unused-vars |
| 138 try { |
| 139 new PaymentRequest( |
| 140 [{ |
| 141 supportedMethods: ['visa'], |
| 142 }], { |
| 143 total: { |
| 144 label: 'Total', |
| 145 amount: { |
| 146 currency: 'USD', |
| 147 value: '5.00', |
| 148 }, |
| 149 }, |
| 150 }) |
| 151 .canMakePayment() |
| 152 .then(function(result) { |
| 153 print(result); |
| 154 }) |
| 155 .catch(function(error) { |
| 156 print(error); |
| 157 }); |
| 158 } catch (error) { |
| 159 print(error); |
| 160 } |
| 161 } |
| 162 |
| 163 /** |
| 164 * Merchant requests payment via either "mastercard" or "basic-card" with "visa" |
| 165 * as the supported network. |
| 166 */ |
| 167 function buy() { // eslint-disable-line no-unused-vars |
| 168 try { |
| 169 new PaymentRequest( |
| 170 [{ |
| 171 supportedMethods: ['mastercard'], |
| 172 }, { |
| 173 supportedMethods: ['basic-card'], |
| 174 data: { |
| 175 supportedNetworks: ['visa'], |
| 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 } |
| 201 |
| 202 /** |
| 203 * Merchant requests payment via "basic-card" with "debit" as the supported card |
| 204 * type. |
| 205 */ |
| 206 function buyBasicDebit() { // eslint-disable-line no-unused-vars |
| 207 try { |
| 208 new PaymentRequest( |
| 209 [{ |
| 210 supportedMethods: ['basic-card'], |
| 211 data: { |
| 212 supportedTypes: ['debit'], |
| 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 } |
| 238 |
| 239 /** |
| 240 * Merchant requests payment via "basic-card" payment method with "mastercard" |
| 241 * as the only supported network. |
| 242 */ |
| 243 function buyBasicMasterCard() { // eslint-disable-line no-unused-vars |
| 244 try { |
| 245 new PaymentRequest( |
| 246 [{ |
| 247 supportedMethods: ['basic-card'], |
| 248 data: { |
| 249 supportedNetworks: ['mastercard'], |
| 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 } |
| OLD | NEW |