| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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_FULL_WALLET_H_ | |
| 6 #define CHROME_BROWSER_AUTOFILL_WALLET_FULL_WALLET_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/gtest_prod_util.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "chrome/browser/autofill/wallet/required_action.h" | |
| 15 #include "chrome/browser/autofill/wallet/wallet_address.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class DictionaryValue; | |
| 19 } | |
| 20 | |
| 21 namespace autofill { | |
| 22 namespace wallet { | |
| 23 | |
| 24 class FullWalletTest; | |
| 25 | |
| 26 // FullWallet contains all the information a merchant requires from a user for | |
| 27 // that user to make a purchase. This includes: | |
| 28 // - billing information | |
| 29 // - shipping information | |
| 30 // - a proxy card for the backing card selected from a user's wallet items | |
| 31 class FullWallet { | |
| 32 public: | |
| 33 ~FullWallet(); | |
| 34 | |
| 35 // Returns an empty scoped_ptr if the input invalid, an empty wallet with | |
| 36 // required actions if there are any, or a valid wallet. | |
| 37 static scoped_ptr<FullWallet> | |
| 38 CreateFullWallet(const base::DictionaryValue& dictionary); | |
| 39 | |
| 40 // Decrypts and returns the primary account number (PAN) using the generated | |
| 41 // one time pad, |one_time_pad_|. | |
| 42 const std::string& GetPan(); | |
| 43 | |
| 44 // Decrypts and returns the card verification number (CVN) using the generated | |
| 45 // one time pad, |one_time_pad_|. | |
| 46 const std::string& GetCvn(); | |
| 47 | |
| 48 // Whether or not |action| is in |required_actions_|. | |
| 49 bool HasRequiredAction(RequiredAction action) const; | |
| 50 | |
| 51 bool operator==(const FullWallet& other) const; | |
| 52 bool operator!=(const FullWallet& other) const; | |
| 53 | |
| 54 // If there are required actions |billing_address_| might contain NULL. | |
| 55 const Address* billing_address() const { return billing_address_.get(); } | |
| 56 | |
| 57 // If there are required actions or shipping address is not required | |
| 58 // |shipping_address_| might contain NULL. | |
| 59 const Address* shipping_address() const { return shipping_address_.get(); } | |
| 60 | |
| 61 const std::vector<RequiredAction>& required_actions() const { | |
| 62 return required_actions_; | |
| 63 } | |
| 64 int expiration_month() const { return expiration_month_; } | |
| 65 int expiration_year() const { return expiration_year_; } | |
| 66 | |
| 67 void set_one_time_pad(const std::vector<uint8>& one_time_pad) { | |
| 68 one_time_pad_ = one_time_pad; | |
| 69 } | |
| 70 | |
| 71 private: | |
| 72 friend class FullWalletTest; | |
| 73 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWallet); | |
| 74 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWalletWithRequiredActions); | |
| 75 FullWallet(int expiration_month, | |
| 76 int expiration_year, | |
| 77 const std::string& iin, | |
| 78 const std::string& encrypted_rest, | |
| 79 scoped_ptr<Address> billing_address, | |
| 80 scoped_ptr<Address> shipping_address, | |
| 81 const std::vector<RequiredAction>& required_actions); | |
| 82 void DecryptCardInfo(); | |
| 83 | |
| 84 // The expiration month of the proxy card. It should be 1-12. | |
| 85 int expiration_month_; | |
| 86 | |
| 87 // The expiration year of the proxy card. It should be a 4-digit year. | |
| 88 int expiration_year_; | |
| 89 | |
| 90 // Primary account number (PAN). Its format is \d{16}. | |
| 91 std::string pan_; | |
| 92 | |
| 93 // Card verification number (CVN). Its format is \d{3}. | |
| 94 std::string cvn_; | |
| 95 | |
| 96 // Issuer identification number (IIN). Its format is \d{6}. | |
| 97 std::string iin_; | |
| 98 | |
| 99 // Encrypted concatentation of CVN and PAN without IIN | |
| 100 std::string encrypted_rest_; | |
| 101 | |
| 102 // The billing address of the backing instrument. | |
| 103 scoped_ptr<Address> billing_address_; | |
| 104 | |
| 105 // The shipping address for the transaction. | |
| 106 scoped_ptr<Address> shipping_address_; | |
| 107 | |
| 108 // Actions that must be completed by the user before a FullWallet can be | |
| 109 // issued to them by the Online Wallet service. | |
| 110 std::vector<RequiredAction> required_actions_; | |
| 111 | |
| 112 // The one time pad used for FullWallet encryption. | |
| 113 std::vector<uint8> one_time_pad_; | |
| 114 | |
| 115 DISALLOW_COPY_AND_ASSIGN(FullWallet); | |
| 116 }; | |
| 117 | |
| 118 } // namespace wallet | |
| 119 } // namespace autofill | |
| 120 | |
| 121 #endif // CHROME_BROWSER_AUTOFILL_WALLET_FULL_WALLET_H_ | |
| OLD | NEW |