| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
| 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
| 7 | 7 |
| 8 #include <set> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 12 | 13 |
| 13 namespace autofill { | 14 namespace autofill { |
| 14 class AutofillProfile; | 15 class AutofillProfile; |
| 15 class CreditCard; | 16 class CreditCard; |
| 16 } // namespace autofill | 17 } // namespace autofill |
| 17 | 18 |
| 18 namespace payments { | 19 namespace payments { |
| 19 | 20 |
| 20 struct BasicCardResponse; | 21 struct BasicCardResponse; |
| 21 struct PaymentAddress; | 22 struct PaymentAddress; |
| 23 class PaymentMethodData; |
| 22 | 24 |
| 23 namespace data_util { | 25 namespace data_util { |
| 24 | 26 |
| 25 // Helper function to get an instance of web::PaymentAddress from an autofill | 27 // Helper function to get an instance of web::PaymentAddress from an autofill |
| 26 // profile. | 28 // profile. |
| 27 PaymentAddress GetPaymentAddressFromAutofillProfile( | 29 PaymentAddress GetPaymentAddressFromAutofillProfile( |
| 28 const autofill::AutofillProfile& profile, | 30 const autofill::AutofillProfile& profile, |
| 29 const std::string& app_locale); | 31 const std::string& app_locale); |
| 30 | 32 |
| 31 // Helper function to get an instance of web::BasicCardResponse from an autofill | 33 // Helper function to get an instance of web::BasicCardResponse from an autofill |
| 32 // credit card. | 34 // credit card. |
| 33 BasicCardResponse GetBasicCardResponseFromAutofillCreditCard( | 35 BasicCardResponse GetBasicCardResponseFromAutofillCreditCard( |
| 34 const autofill::CreditCard& card, | 36 const autofill::CreditCard& card, |
| 35 const base::string16& cvc, | 37 const base::string16& cvc, |
| 36 const std::vector<autofill::AutofillProfile*>& billing_profiles, | 38 const std::vector<autofill::AutofillProfile*>& billing_profiles, |
| 37 const std::string& app_locale); | 39 const std::string& app_locale); |
| 38 | 40 |
| 41 // Parse the supported card networks from supportedMethods and "basic-card"'s |
| 42 // supportedNetworks. |out_supported_networks| is filled with list of networks |
| 43 // in the order that they were specified by the merchant. |
| 44 // |out_basic_card_supported_networks| is a subset of |out_supported_networks| |
| 45 // that includes all networks that were specified as part of "basic-card". This |
| 46 // is used to know whether to return the card network name (e.g., "visa") or |
| 47 // "basic-card" in the PaymentResponse. Returns true on success, false on |
| 48 // invalid data specified. |method_data.supported_networks| is expected to only |
| 49 // contain basic-card card network names (the list is at |
| 50 // https://www.w3.org/Payments/card-network-ids). |
| 51 bool ParseBasicCardSupportedNetworks( |
| 52 const std::vector<PaymentMethodData>& method_data, |
| 53 std::vector<std::string>* out_supported_networks, |
| 54 std::set<std::string>* out_basic_card_supported_networks); |
| 55 |
| 39 } // namespace data_util | 56 } // namespace data_util |
| 40 } // namespace payments | 57 } // namespace payments |
| 41 | 58 |
| 42 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 59 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
| OLD | NEW |