OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ | 5 #ifndef IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ |
6 #define IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ | 6 #define IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ |
7 | 7 |
8 #include <memory> | |
9 #include <vector> | 8 #include <vector> |
10 | 9 |
11 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
12 | 11 |
13 // C++ bindings for the PaymentRequest API. Conforms to the following specs: | 12 // C++ bindings for the PaymentRequest API. Conforms to the 18 July 2016 |
14 // https://w3c.github.io/browser-payment-api/ (18 July 2016 editor's draft) | 13 // editor's draft at https://w3c.github.io/browser-payment-api/. |
15 // https://w3c.github.io/webpayments-methods-card/ (31 May 2016 editor's draft) | |
16 | 14 |
17 namespace base { | 15 namespace base { |
18 class DictionaryValue; | 16 class DictionaryValue; |
19 } | 17 } |
20 | 18 |
21 namespace web { | 19 namespace web { |
22 | 20 |
23 // A shipping or billing address. | 21 // A shipping or billing address. |
24 class PaymentAddress { | 22 class PaymentAddress { |
25 public: | 23 public: |
26 PaymentAddress(); | 24 PaymentAddress(); |
27 PaymentAddress(const PaymentAddress& other); | 25 PaymentAddress(const PaymentAddress& other); |
28 ~PaymentAddress(); | 26 ~PaymentAddress(); |
29 | 27 |
30 bool operator==(const PaymentAddress& other) const; | 28 bool operator==(const PaymentAddress& other) const; |
31 bool operator!=(const PaymentAddress& other) const; | 29 bool operator!=(const PaymentAddress& other) const; |
32 | 30 |
33 // Populates |value| with the properties of this PaymentAddress. | |
34 std::unique_ptr<base::DictionaryValue> ToDictionaryValue() const; | |
35 | |
36 // The CLDR (Common Locale Data Repository) region code. For example, US, GB, | 31 // The CLDR (Common Locale Data Repository) region code. For example, US, GB, |
37 // CN, or JP. | 32 // CN, or JP. |
38 base::string16 country; | 33 base::string16 country; |
39 | 34 |
40 // The most specific part of the address. It can include, for example, a | 35 // The most specific part of the address. It can include, for example, a |
41 // street name, a house number, apartment number, a rural delivery route, | 36 // street name, a house number, apartment number, a rural delivery route, |
42 // descriptive instructions, or a post office box number. | 37 // descriptive instructions, or a post office box number. |
43 std::vector<base::string16> address_line; | 38 std::vector<base::string16> address_line; |
44 | 39 |
45 // The top level administrative subdivision of the country. For example, this | 40 // The top level administrative subdivision of the country. For example, this |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 PaymentAddress payment_address; | 254 PaymentAddress payment_address; |
260 base::string16 shipping_option; | 255 base::string16 shipping_option; |
261 | 256 |
262 // Properties set via the constructor for communicating from the page to the | 257 // Properties set via the constructor for communicating from the page to the |
263 // browser UI. | 258 // browser UI. |
264 std::vector<PaymentMethodData> method_data; | 259 std::vector<PaymentMethodData> method_data; |
265 PaymentDetails details; | 260 PaymentDetails details; |
266 PaymentOptions options; | 261 PaymentOptions options; |
267 }; | 262 }; |
268 | 263 |
269 // Contains the response from the PaymentRequest API when a user accepts | |
270 // payment with a Basic Payment Card payment method (which is currently the only | |
271 // method supported on iOS). | |
272 class BasicCardResponse { | |
273 public: | |
274 BasicCardResponse(); | |
275 BasicCardResponse(const BasicCardResponse& other); | |
276 ~BasicCardResponse(); | |
277 | |
278 bool operator==(const BasicCardResponse& other) const; | |
279 bool operator!=(const BasicCardResponse& other) const; | |
280 | |
281 // Populates |value| with the properties of this BasicCardResponse. | |
282 std::unique_ptr<base::DictionaryValue> ToDictionaryValue() const; | |
283 | |
284 // The cardholder's name as it appears on the card. | |
285 base::string16 cardholder_name; | |
286 | |
287 // The primary account number (PAN) for the payment card. | |
288 base::string16 card_number; | |
289 | |
290 // A two-digit string for the expiry month of the card in the range 01 to 12. | |
291 base::string16 expiry_month; | |
292 | |
293 // A two-digit string for the expiry year of the card in the range 00 to 99. | |
294 base::string16 expiry_year; | |
295 | |
296 // A three or four digit string for the security code of the card (sometimes | |
297 // known as the CVV, CVC, CVN, CVE or CID). | |
298 base::string16 card_security_code; | |
299 | |
300 // The billing address information associated with the payment card. | |
301 PaymentAddress billing_address; | |
302 }; | |
303 | |
304 // Information provided in the Promise returned by a call to | 264 // Information provided in the Promise returned by a call to |
305 // PaymentRequest.show(). | 265 // PaymentRequest.show(). |
306 class PaymentResponse { | 266 class PaymentResponse { |
307 public: | 267 public: |
308 PaymentResponse(); | 268 PaymentResponse(); |
309 PaymentResponse(const PaymentResponse& other); | |
310 ~PaymentResponse(); | 269 ~PaymentResponse(); |
311 | 270 |
312 bool operator==(const PaymentResponse& other) const; | 271 bool operator==(const PaymentResponse& other) const; |
313 bool operator!=(const PaymentResponse& other) const; | 272 bool operator!=(const PaymentResponse& other) const; |
314 | 273 |
315 // Populates |value| with the properties of this PaymentResponse. | 274 // Populates |value| with the properties of this PaymentResponse. |
316 std::unique_ptr<base::DictionaryValue> ToDictionaryValue() const; | |
317 | |
318 // TODO(jdonnelly): Remove this after removing downstream use. | |
319 void ToDictionaryValue(base::DictionaryValue* value) const; | 275 void ToDictionaryValue(base::DictionaryValue* value) const; |
320 | 276 |
321 // The payment method identifier for the payment method that the user selected | 277 // The payment method identifier for the payment method that the user selected |
322 // to fulfil the transaction. | 278 // to fulfil the transaction. |
323 base::string16 method_name; | 279 base::string16 method_name; |
324 | 280 |
325 // A credit card response object used by the merchant to process the | 281 // A JSON-serialized object that provides a payment method specific message |
326 // transaction and determine successful fund transfer. | 282 // used by the merchant to process the transaction and determine successful |
327 BasicCardResponse details; | 283 // fund transfer. This data is returned by the payment app that satisfies the |
| 284 // payment request. |
| 285 base::string16 details; |
328 }; | 286 }; |
329 | 287 |
330 } // namespace web | 288 } // namespace web |
331 | 289 |
332 #endif // IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ | 290 #endif // IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ |
OLD | NEW |