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

Side by Side Diff: components/autofill/core/browser/validation.h

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Components Unittests fix Created 3 years, 7 months 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_AUTOFILL_CORE_BROWSER_VALIDATION_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector>
10 11
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "base/strings/string_piece_forward.h" 13 #include "base/strings/string_piece_forward.h"
13 #include "components/autofill/core/browser/field_types.h" 14 #include "components/autofill/core/browser/field_types.h"
14 15
15 namespace base { 16 namespace base {
16 class Time; 17 class Time;
17 } // namespace base 18 } // namespace base
18 19
19 namespace autofill { 20 namespace autofill {
20 21
21 class CreditCard; 22 class CreditCard;
23 class AutofillProfile;
22 24
23 // Constants for the length of a CVC. 25 // Constants for the length of a CVC.
24 static const size_t GENERAL_CVC_LENGTH = 3; 26 static const size_t GENERAL_CVC_LENGTH = 3;
25 static const size_t AMEX_CVC_LENGTH = 4; 27 static const size_t AMEX_CVC_LENGTH = 4;
26 28
27 // Used to express the completion status of a credit card. 29 // Used to express the completion status of a credit card.
28 typedef uint32_t CreditCardCompletionStatus; 30 typedef uint32_t CreditCardCompletionStatus;
29 static const CreditCardCompletionStatus CREDIT_CARD_COMPLETE = 0; 31 static const CreditCardCompletionStatus CREDIT_CARD_COMPLETE = 0;
30 static const CreditCardCompletionStatus CREDIT_CARD_EXPIRED = 1 << 0; 32 static const CreditCardCompletionStatus CREDIT_CARD_EXPIRED = 1 << 0;
31 static const CreditCardCompletionStatus CREDIT_CARD_NO_CARDHOLDER = 1 << 1; 33 static const CreditCardCompletionStatus CREDIT_CARD_NO_CARDHOLDER = 1 << 1;
32 static const CreditCardCompletionStatus CREDIT_CARD_NO_NUMBER = 1 << 2; 34 static const CreditCardCompletionStatus CREDIT_CARD_NO_NUMBER = 1 << 2;
35 static const CreditCardCompletionStatus CREDIT_CARD_NO_BILLING_ADDRESS = 1 << 3;
33 36
34 // Returns true if |year| and |month| describe a date later than |now|. 37 // Returns true if |year| and |month| describe a date later than |now|.
35 // |year| must have 4 digits. 38 // |year| must have 4 digits.
36 bool IsValidCreditCardExpirationDate(int year, 39 bool IsValidCreditCardExpirationDate(int year,
37 int month, 40 int month,
38 const base::Time& now); 41 const base::Time& now);
39 42
40 // Returns true if |text| looks like a valid credit card number. 43 // Returns true if |text| looks like a valid credit card number.
41 // Uses the Luhn formula to validate the number. 44 // Uses the Luhn formula to validate the number.
42 bool IsValidCreditCardNumber(const base::string16& text); 45 bool IsValidCreditCardNumber(const base::string16& text);
43 46
44 // Returns true if |code| looks like a valid credit card security code 47 // Returns true if |code| looks like a valid credit card security code
45 // for the given credit card type. 48 // for the given credit card type.
46 bool IsValidCreditCardSecurityCode(const base::string16& code, 49 bool IsValidCreditCardSecurityCode(const base::string16& code,
47 const base::StringPiece card_type); 50 const base::StringPiece card_type);
48 51
49 // Returns true if |text| is a supported card type and a valid credit card 52 // Returns true if |text| is a supported card type and a valid credit card
50 // number. |error_message| can't be null and will be filled with the appropriate 53 // number. |error_message| can't be null and will be filled with the appropriate
51 // error message. 54 // error message.
52 bool IsValidCreditCardNumberForBasicCardNetworks( 55 bool IsValidCreditCardNumberForBasicCardNetworks(
53 const base::string16& text, 56 const base::string16& text,
54 const std::set<std::string>& supported_basic_card_networks, 57 const std::set<std::string>& supported_basic_card_networks,
55 base::string16* error_message); 58 base::string16* error_message);
56 59
57 // Returns the credit card's completion status. If equal to 60 // Returns the credit card's completion status. If equal to
58 // CREDIT_CARD_COMPLETE, then the card is ready to be used for Payment Request. 61 // CREDIT_CARD_COMPLETE, then the card is ready to be used for Payment Request.
59 // TODO(crbug.com/709776): Check for billing address association.
60 CreditCardCompletionStatus GetCompletionStatusForCard( 62 CreditCardCompletionStatus GetCompletionStatusForCard(
61 const CreditCard& credit_card, 63 const CreditCard& credit_card,
62 const std::string& app_locale); 64 const std::string& app_locale,
65 const std::vector<AutofillProfile*> billing_addresses);
63 66
64 // Return the message to be displayed to the user, indicating what's missing 67 // Return the message to be displayed to the user, indicating what's missing
65 // to make the credit card complete for payment. If more than one thing is 68 // to make the credit card complete for payment. If more than one thing is
66 // missing, the message will be a generic "more information required". 69 // missing, the message will be a generic "more information required".
67 base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status); 70 base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status);
68 71
69 // Returns true if |text| looks like a valid e-mail address. 72 // Returns true if |text| looks like a valid e-mail address.
70 bool IsValidEmailAddress(const base::string16& text); 73 bool IsValidEmailAddress(const base::string16& text);
71 74
72 // Returns true if |text| is a valid US state name or abbreviation. It is case 75 // Returns true if |text| is a valid US state name or abbreviation. It is case
(...skipping 22 matching lines...) Expand all
95 // Returns the expected CVC length based on the |card_type|. 98 // Returns the expected CVC length based on the |card_type|.
96 size_t GetCvcLengthForCardType(const base::StringPiece card_type); 99 size_t GetCvcLengthForCardType(const base::StringPiece card_type);
97 100
98 // Returns true if |value| appears to be a UPI Virtual Payment Address. 101 // Returns true if |value| appears to be a UPI Virtual Payment Address.
99 // https://upipayments.co.in/virtual-payment-address-vpa/ 102 // https://upipayments.co.in/virtual-payment-address-vpa/
100 bool IsUPIVirtualPaymentAddress(const base::string16& value); 103 bool IsUPIVirtualPaymentAddress(const base::string16& value);
101 104
102 } // namespace autofill 105 } // namespace autofill
103 106
104 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_ 107 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698