| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_INSTRUMENT_H_ | |
| 6 #define CHROME_BROWSER_AUTOFILL_WALLET_INSTRUMENT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/string16.h" | |
| 12 | |
| 13 namespace base { | |
| 14 class DictionaryValue; | |
| 15 } | |
| 16 | |
| 17 namespace autofill { | |
| 18 namespace wallet { | |
| 19 | |
| 20 class Address; | |
| 21 | |
| 22 // This class contains all the data necessary to save a new instrument to a | |
| 23 // user's Google Wallet using WalletClient::SaveInstrument or | |
| 24 // WalletClient::SaveInstrumentAndAddress. | |
| 25 class Instrument { | |
| 26 public: | |
| 27 enum FormOfPayment { | |
| 28 UNKNOWN, | |
| 29 VISA, | |
| 30 MASTER_CARD, | |
| 31 AMEX, | |
| 32 DISCOVER, | |
| 33 JCB, | |
| 34 }; | |
| 35 | |
| 36 Instrument(const string16& primary_account_number, | |
| 37 const string16& card_verification_number, | |
| 38 int expiration_month, | |
| 39 int expiration_year, | |
| 40 FormOfPayment form_of_payment, | |
| 41 scoped_ptr<Address> address); | |
| 42 Instrument(const Instrument& instrument); | |
| 43 ~Instrument(); | |
| 44 | |
| 45 scoped_ptr<base::DictionaryValue> ToDictionary() const; | |
| 46 | |
| 47 // Users of this class should call IsValid to check that the inputs provided | |
| 48 // in the constructor were valid for use with Google Wallet. | |
| 49 bool IsValid() const; | |
| 50 | |
| 51 const string16& primary_account_number() const { | |
| 52 return primary_account_number_; | |
| 53 } | |
| 54 const string16& card_verification_number() const { | |
| 55 return card_verification_number_; | |
| 56 } | |
| 57 int expiration_month() const { return expiration_month_; } | |
| 58 int expiration_year() const { return expiration_year_; } | |
| 59 const Address& address() const { return *address_; } | |
| 60 FormOfPayment form_of_payment() const { return form_of_payment_; } | |
| 61 const string16& last_four_digits() { return last_four_digits_; } | |
| 62 | |
| 63 private: | |
| 64 void Init(); | |
| 65 | |
| 66 // |primary_account_number_| is expected to be \d{12-19}. | |
| 67 string16 primary_account_number_; | |
| 68 | |
| 69 // |card_verification_number_| is expected to be \d{3-4}. | |
| 70 string16 card_verification_number_; | |
| 71 | |
| 72 // |expiration month_| should be 1-12. | |
| 73 int expiration_month_; | |
| 74 | |
| 75 // |expiration_year_| should be a 4-digit year. | |
| 76 int expiration_year_; | |
| 77 | |
| 78 // The payment network of the instrument, e.g. Visa. | |
| 79 FormOfPayment form_of_payment_; | |
| 80 | |
| 81 // The billing address of the instrument. | |
| 82 scoped_ptr<Address> address_; | |
| 83 | |
| 84 // The last four digits of |primary_account_number_|. | |
| 85 string16 last_four_digits_; | |
| 86 | |
| 87 DISALLOW_ASSIGN(Instrument); | |
| 88 }; | |
| 89 | |
| 90 } // namespace wallet | |
| 91 } // namespace autofill | |
| 92 | |
| 93 #endif // CHROME_BROWSER_AUTOFILL_WALLET_INSTRUMENT_H_ | |
| OLD | NEW |