blob: d479b492c7fedb4d1d1223bc32952bacaed6fffc [file] [log] [blame]
[email protected]ce63d6b2012-12-20 02:46:281// 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
[email protected]e4b2fa32013-03-09 22:56:565#ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_FULL_WALLET_H_
6#define COMPONENTS_AUTOFILL_BROWSER_WALLET_FULL_WALLET_H_
[email protected]ce63d6b2012-12-20 02:46:287
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"
[email protected]e4b2fa32013-03-09 22:56:5614#include "components/autofill/browser/wallet/required_action.h"
15#include "components/autofill/browser/wallet/wallet_address.h"
[email protected]ce63d6b2012-12-20 02:46:2816
17namespace base {
18class DictionaryValue;
19}
20
[email protected]345175642013-02-20 19:25:5221namespace autofill {
[email protected]ce63d6b2012-12-20 02:46:2822namespace wallet {
23
24class FullWalletTest;
25
26// FullWallet contains all the information a merchant requires from a user for
[email protected]7a97aa82013-01-07 21:34:5327// 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
[email protected]ce63d6b2012-12-20 02:46:2831class 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
[email protected]1a43a90d2013-03-15 09:13:2740 // Returns corresponding data for |type|.
41 string16 GetInfo(AutofillFieldType type);
[email protected]ce63d6b2012-12-20 02:46:2842
[email protected]ab6601f2013-03-02 19:11:5843 // Whether or not |action| is in |required_actions_|.
44 bool HasRequiredAction(RequiredAction action) const;
45
[email protected]ce63d6b2012-12-20 02:46:2846 bool operator==(const FullWallet& other) const;
47 bool operator!=(const FullWallet& other) const;
48
49 // If there are required actions |billing_address_| might contain NULL.
50 const Address* billing_address() const { return billing_address_.get(); }
51
52 // If there are required actions or shipping address is not required
53 // |shipping_address_| might contain NULL.
54 const Address* shipping_address() const { return shipping_address_.get(); }
55
[email protected]7a97aa82013-01-07 21:34:5356 const std::vector<RequiredAction>& required_actions() const {
[email protected]ce63d6b2012-12-20 02:46:2857 return required_actions_;
58 }
59 int expiration_month() const { return expiration_month_; }
60 int expiration_year() const { return expiration_year_; }
61
[email protected]345175642013-02-20 19:25:5262 void set_one_time_pad(const std::vector<uint8>& one_time_pad) {
63 one_time_pad_ = one_time_pad;
64 }
65
[email protected]ce63d6b2012-12-20 02:46:2866 private:
67 friend class FullWalletTest;
68 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWallet);
69 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWalletWithRequiredActions);
70 FullWallet(int expiration_month,
71 int expiration_year,
72 const std::string& iin,
73 const std::string& encrypted_rest,
74 scoped_ptr<Address> billing_address,
75 scoped_ptr<Address> shipping_address,
[email protected]7a97aa82013-01-07 21:34:5376 const std::vector<RequiredAction>& required_actions);
[email protected]1a43a90d2013-03-15 09:13:2777
78 // Decrypts both |pan_| and |cvn_|.
[email protected]345175642013-02-20 19:25:5279 void DecryptCardInfo();
[email protected]f8a02362013-02-15 20:28:5580
[email protected]1a43a90d2013-03-15 09:13:2781 // Decrypts and returns the primary account number (PAN) using the generated
82 // one time pad, |one_time_pad_|.
83 const std::string& GetPan();
84
85 // Decrypts and returns the card verification number (CVN) using the generated
86 // one time pad, |one_time_pad_|.
87 const std::string& GetCvn();
88
[email protected]f8a02362013-02-15 20:28:5589 // The expiration month of the proxy card. It should be 1-12.
[email protected]ce63d6b2012-12-20 02:46:2890 int expiration_month_;
[email protected]f8a02362013-02-15 20:28:5591
92 // The expiration year of the proxy card. It should be a 4-digit year.
[email protected]ce63d6b2012-12-20 02:46:2893 int expiration_year_;
[email protected]f8a02362013-02-15 20:28:5594
[email protected]ce63d6b2012-12-20 02:46:2895 // Primary account number (PAN). Its format is \d{16}.
96 std::string pan_;
[email protected]f8a02362013-02-15 20:28:5597
[email protected]ce63d6b2012-12-20 02:46:2898 // Card verification number (CVN). Its format is \d{3}.
99 std::string cvn_;
[email protected]f8a02362013-02-15 20:28:55100
[email protected]ce63d6b2012-12-20 02:46:28101 // Issuer identification number (IIN). Its format is \d{6}.
102 std::string iin_;
[email protected]f8a02362013-02-15 20:28:55103
[email protected]ce63d6b2012-12-20 02:46:28104 // Encrypted concatentation of CVN and PAN without IIN
105 std::string encrypted_rest_;
[email protected]f8a02362013-02-15 20:28:55106
107 // The billing address of the backing instrument.
[email protected]ce63d6b2012-12-20 02:46:28108 scoped_ptr<Address> billing_address_;
[email protected]f8a02362013-02-15 20:28:55109
110 // The shipping address for the transaction.
[email protected]ce63d6b2012-12-20 02:46:28111 scoped_ptr<Address> shipping_address_;
[email protected]f8a02362013-02-15 20:28:55112
[email protected]ce63d6b2012-12-20 02:46:28113 // Actions that must be completed by the user before a FullWallet can be
114 // issued to them by the Online Wallet service.
[email protected]7a97aa82013-01-07 21:34:53115 std::vector<RequiredAction> required_actions_;
[email protected]f8a02362013-02-15 20:28:55116
[email protected]345175642013-02-20 19:25:52117 // The one time pad used for FullWallet encryption.
118 std::vector<uint8> one_time_pad_;
119
[email protected]ce63d6b2012-12-20 02:46:28120 DISALLOW_COPY_AND_ASSIGN(FullWallet);
121};
122
123} // namespace wallet
[email protected]345175642013-02-20 19:25:52124} // namespace autofill
[email protected]ce63d6b2012-12-20 02:46:28125
[email protected]e4b2fa32013-03-09 22:56:56126#endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_FULL_WALLET_H_