| 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> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "components/payments/core/basic_card_response.h" |
| 13 #include "components/payments/core/payment_address.h" |
| 12 | 14 |
| 13 // C++ bindings for the PaymentRequest API. Conforms to the following specs: | 15 // C++ bindings for the PaymentRequest API. Conforms to the following specs: |
| 14 // https://w3c.github.io/browser-payment-api/ (18 July 2016 editor's draft) | 16 // https://w3c.github.io/browser-payment-api/ (18 July 2016 editor's draft) |
| 15 // https://w3c.github.io/webpayments-methods-card/ (31 May 2016 editor's draft) | 17 // https://w3c.github.io/webpayments-methods-card/ (31 May 2016 editor's draft) |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class DictionaryValue; | 20 class DictionaryValue; |
| 19 } | 21 } |
| 20 | 22 |
| 21 namespace web { | 23 namespace web { |
| 22 | 24 |
| 23 // A shipping or billing address. | |
| 24 class PaymentAddress { | |
| 25 public: | |
| 26 PaymentAddress(); | |
| 27 PaymentAddress(const PaymentAddress& other); | |
| 28 ~PaymentAddress(); | |
| 29 | |
| 30 bool operator==(const PaymentAddress& other) const; | |
| 31 bool operator!=(const PaymentAddress& other) const; | |
| 32 | |
| 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, | |
| 37 // CN, or JP. | |
| 38 base::string16 country; | |
| 39 | |
| 40 // 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, | |
| 42 // descriptive instructions, or a post office box number. | |
| 43 std::vector<base::string16> address_line; | |
| 44 | |
| 45 // The top level administrative subdivision of the country. For example, this | |
| 46 // can be a state, a province, an oblast, or a prefecture. | |
| 47 base::string16 region; | |
| 48 | |
| 49 // The city/town portion of the address. | |
| 50 base::string16 city; | |
| 51 | |
| 52 // The dependent locality or sublocality within a city. For example, used for | |
| 53 // neighborhoods, boroughs, districts, or UK dependent localities. | |
| 54 base::string16 dependent_locality; | |
| 55 | |
| 56 // The postal code or ZIP code, also known as PIN code in India. | |
| 57 base::string16 postal_code; | |
| 58 | |
| 59 // The sorting code as used in, for example, France. | |
| 60 base::string16 sorting_code; | |
| 61 | |
| 62 // The BCP-47 language code for the address. It's used to determine the field | |
| 63 // separators and the order of fields when formatting the address for display. | |
| 64 base::string16 language_code; | |
| 65 | |
| 66 // The organization, firm, company, or institution at this address. | |
| 67 base::string16 organization; | |
| 68 | |
| 69 // The name of the recipient or contact person. | |
| 70 base::string16 recipient; | |
| 71 | |
| 72 // The name of an intermediary party or entity responsible for transferring | |
| 73 // packages between the postal service and the recipient. | |
| 74 base::string16 care_of; | |
| 75 | |
| 76 // The phone number of the recipient or contact person. | |
| 77 base::string16 phone; | |
| 78 }; | |
| 79 | |
| 80 // A set of supported payment methods and any associated payment method specific | 25 // A set of supported payment methods and any associated payment method specific |
| 81 // data for those methods. | 26 // data for those methods. |
| 82 class PaymentMethodData { | 27 class PaymentMethodData { |
| 83 public: | 28 public: |
| 84 PaymentMethodData(); | 29 PaymentMethodData(); |
| 85 PaymentMethodData(const PaymentMethodData& other); | 30 PaymentMethodData(const PaymentMethodData& other); |
| 86 ~PaymentMethodData(); | 31 ~PaymentMethodData(); |
| 87 | 32 |
| 88 bool operator==(const PaymentMethodData& other) const; | 33 bool operator==(const PaymentMethodData& other) const; |
| 89 bool operator!=(const PaymentMethodData& other) const; | 34 bool operator!=(const PaymentMethodData& other) const; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 254 |
| 310 // Populates the properties of this PaymentRequest from |value|. Returns true | 255 // Populates the properties of this PaymentRequest from |value|. Returns true |
| 311 // if the required values are present. | 256 // if the required values are present. |
| 312 bool FromDictionaryValue(const base::DictionaryValue& value); | 257 bool FromDictionaryValue(const base::DictionaryValue& value); |
| 313 | 258 |
| 314 // The unique ID for this PaymentRequest. If it is not provided during | 259 // The unique ID for this PaymentRequest. If it is not provided during |
| 315 // construction, one is generated. | 260 // construction, one is generated. |
| 316 base::string16 payment_request_id; | 261 base::string16 payment_request_id; |
| 317 | 262 |
| 318 // Properties set in order to communicate user choices back to the page. | 263 // Properties set in order to communicate user choices back to the page. |
| 319 PaymentAddress shipping_address; | 264 payments::PaymentAddress shipping_address; |
| 320 base::string16 shipping_option; | 265 base::string16 shipping_option; |
| 321 | 266 |
| 322 // Properties set via the constructor for communicating from the page to the | 267 // Properties set via the constructor for communicating from the page to the |
| 323 // browser UI. | 268 // browser UI. |
| 324 std::vector<PaymentMethodData> method_data; | 269 std::vector<PaymentMethodData> method_data; |
| 325 PaymentDetails details; | 270 PaymentDetails details; |
| 326 PaymentOptions options; | 271 PaymentOptions options; |
| 327 }; | 272 }; |
| 328 | 273 |
| 329 // Contains the response from the PaymentRequest API when a user accepts | |
| 330 // payment with a Basic Payment Card payment method (which is currently the only | |
| 331 // method supported on iOS). | |
| 332 class BasicCardResponse { | |
| 333 public: | |
| 334 BasicCardResponse(); | |
| 335 BasicCardResponse(const BasicCardResponse& other); | |
| 336 ~BasicCardResponse(); | |
| 337 | |
| 338 bool operator==(const BasicCardResponse& other) const; | |
| 339 bool operator!=(const BasicCardResponse& other) const; | |
| 340 | |
| 341 // Populates |value| with the properties of this BasicCardResponse. | |
| 342 std::unique_ptr<base::DictionaryValue> ToDictionaryValue() const; | |
| 343 | |
| 344 // The cardholder's name as it appears on the card. | |
| 345 base::string16 cardholder_name; | |
| 346 | |
| 347 // The primary account number (PAN) for the payment card. | |
| 348 base::string16 card_number; | |
| 349 | |
| 350 // A two-digit string for the expiry month of the card in the range 01 to 12. | |
| 351 base::string16 expiry_month; | |
| 352 | |
| 353 // A two-digit string for the expiry year of the card in the range 00 to 99. | |
| 354 base::string16 expiry_year; | |
| 355 | |
| 356 // A three or four digit string for the security code of the card (sometimes | |
| 357 // known as the CVV, CVC, CVN, CVE or CID). | |
| 358 base::string16 card_security_code; | |
| 359 | |
| 360 // The billing address information associated with the payment card. | |
| 361 PaymentAddress billing_address; | |
| 362 }; | |
| 363 | |
| 364 // Information provided in the Promise returned by a call to | 274 // Information provided in the Promise returned by a call to |
| 365 // PaymentRequest.show(). | 275 // PaymentRequest.show(). |
| 366 class PaymentResponse { | 276 class PaymentResponse { |
| 367 public: | 277 public: |
| 368 PaymentResponse(); | 278 PaymentResponse(); |
| 369 PaymentResponse(const PaymentResponse& other); | 279 PaymentResponse(const PaymentResponse& other); |
| 370 ~PaymentResponse(); | 280 ~PaymentResponse(); |
| 371 | 281 |
| 372 bool operator==(const PaymentResponse& other) const; | 282 bool operator==(const PaymentResponse& other) const; |
| 373 bool operator!=(const PaymentResponse& other) const; | 283 bool operator!=(const PaymentResponse& other) const; |
| 374 | 284 |
| 375 // Populates |value| with the properties of this PaymentResponse. | 285 // Populates |value| with the properties of this PaymentResponse. |
| 376 std::unique_ptr<base::DictionaryValue> ToDictionaryValue() const; | 286 std::unique_ptr<base::DictionaryValue> ToDictionaryValue() const; |
| 377 | 287 |
| 378 // The same paymentRequestID present in the original PaymentRequest. | 288 // The same paymentRequestID present in the original PaymentRequest. |
| 379 base::string16 payment_request_id; | 289 base::string16 payment_request_id; |
| 380 | 290 |
| 381 // The payment method identifier for the payment method that the user selected | 291 // The payment method identifier for the payment method that the user selected |
| 382 // to fulfil the transaction. | 292 // to fulfil the transaction. |
| 383 base::string16 method_name; | 293 base::string16 method_name; |
| 384 | 294 |
| 385 // A credit card response object used by the merchant to process the | 295 // A credit card response object used by the merchant to process the |
| 386 // transaction and determine successful fund transfer. | 296 // transaction and determine successful fund transfer. |
| 387 BasicCardResponse details; | 297 payments::BasicCardResponse details; |
| 388 | 298 |
| 389 // If request_shipping was set to true in the PaymentOptions passed to the | 299 // If request_shipping was set to true in the PaymentOptions passed to the |
| 390 // PaymentRequest constructor, this will be the full and final shipping | 300 // PaymentRequest constructor, this will be the full and final shipping |
| 391 // address chosen by the user. | 301 // address chosen by the user. |
| 392 PaymentAddress shipping_address; | 302 payments::PaymentAddress shipping_address; |
| 393 | 303 |
| 394 // If the request_shipping flag was set to true in the PaymentOptions passed | 304 // If the request_shipping flag was set to true in the PaymentOptions passed |
| 395 // to the PaymentRequest constructor, this will be the id attribute of the | 305 // to the PaymentRequest constructor, this will be the id attribute of the |
| 396 // selected shipping option. | 306 // selected shipping option. |
| 397 base::string16 shipping_option; | 307 base::string16 shipping_option; |
| 398 | 308 |
| 399 // If the request_payer_name flag was set to true in the PaymentOptions passed | 309 // If the request_payer_name flag was set to true in the PaymentOptions passed |
| 400 // to the PaymentRequest constructor, this will be the name provided by the | 310 // to the PaymentRequest constructor, this will be the name provided by the |
| 401 // user. | 311 // user. |
| 402 base::string16 payer_name; | 312 base::string16 payer_name; |
| 403 | 313 |
| 404 // If the request_payer_email flag was set to true in the PaymentOptions | 314 // If the request_payer_email flag was set to true in the PaymentOptions |
| 405 // passed to the PaymentRequest constructor, this will be the email address | 315 // passed to the PaymentRequest constructor, this will be the email address |
| 406 // chosen by the user. | 316 // chosen by the user. |
| 407 base::string16 payer_email; | 317 base::string16 payer_email; |
| 408 | 318 |
| 409 // If the request_payer_phone flag was set to true in the PaymentOptions | 319 // If the request_payer_phone flag was set to true in the PaymentOptions |
| 410 // passed to the PaymentRequest constructor, this will be the phone number | 320 // passed to the PaymentRequest constructor, this will be the phone number |
| 411 // chosen by the user. | 321 // chosen by the user. |
| 412 base::string16 payer_phone; | 322 base::string16 payer_phone; |
| 413 }; | 323 }; |
| 414 | 324 |
| 415 } // namespace web | 325 } // namespace web |
| 416 | 326 |
| 417 #endif // IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ | 327 #endif // IOS_WEB_PUBLIC_PAYMENTS_PAYMENT_REQUEST_H_ |
| OLD | NEW |