Class: Vantiv::TestCard
- Inherits:
-
Object
- Object
- Vantiv::TestCard
- Defined in:
- lib/vantiv/test_card.rb
Defined Under Namespace
Classes: CardNotFound
Constant Summary collapse
- CARDS =
[ { access_method_name: "valid_account", attrs: { card_number: "4457010000000009", expiry_month: "01", expiry_year: "16", cvv: "349", mocked_sandbox_payment_account_id: "1111111111110009", network: "VI" } }, { access_method_name: "invalid_card_number", attrs: { card_number: "4457010010900010", expiry_month: "01", expiry_year: "16", cvv: "349", mocked_sandbox_payment_account_id: nil, network: "VI" } }, { access_method_name: "invalid_account_number", attrs: { card_number: "5112001600000006", expiry_month: "01", expiry_year: "20", cvv: "349", mocked_sandbox_payment_account_id: "1111111111130006", network: "MC" } }, { access_method_name: "insufficient_funds", attrs: { card_number: "4457002100000005", expiry_month: "01", expiry_year: "20", cvv: "349", mocked_sandbox_payment_account_id: "1111111111120005", network: "VI" } }, { access_method_name: "expired_card", attrs: { card_number: "5112001900000003", expiry_month: "01", expiry_year: "20", cvv: "349", mocked_sandbox_payment_account_id: "1111111111140003", network: "MC" } } ]
Instance Attribute Summary collapse
-
#card_number ⇒ Object
readonly
Returns the value of attribute card_number.
-
#cvv ⇒ Object
readonly
Returns the value of attribute cvv.
-
#expiry_month ⇒ Object
readonly
Returns the value of attribute expiry_month.
-
#expiry_year ⇒ Object
readonly
Returns the value of attribute expiry_year.
-
#mocked_sandbox_payment_account_id ⇒ Object
readonly
Returns the value of attribute mocked_sandbox_payment_account_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(card_number:, expiry_month:, expiry_year:, cvv:, mocked_sandbox_payment_account_id:, network:, name:) ⇒ TestCard
constructor
A new instance of TestCard.
Constructor Details
#initialize(card_number:, expiry_month:, expiry_year:, cvv:, mocked_sandbox_payment_account_id:, network:, name:) ⇒ TestCard
Returns a new instance of TestCard.
84 85 86 87 88 89 90 91 92 |
# File 'lib/vantiv/test_card.rb', line 84 def initialize(card_number:, expiry_month:, expiry_year:, cvv:, mocked_sandbox_payment_account_id:, network:, name:) @card_number = card_number @expiry_month = expiry_month @expiry_year = expiry_year @cvv = cvv @mocked_sandbox_payment_account_id = mocked_sandbox_payment_account_id @network = network @name = name end |
Instance Attribute Details
#card_number ⇒ Object (readonly)
Returns the value of attribute card_number.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def card_number @card_number end |
#cvv ⇒ Object (readonly)
Returns the value of attribute cvv.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def cvv @cvv end |
#expiry_month ⇒ Object (readonly)
Returns the value of attribute expiry_month.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def expiry_month @expiry_month end |
#expiry_year ⇒ Object (readonly)
Returns the value of attribute expiry_year.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def expiry_year @expiry_year end |
#mocked_sandbox_payment_account_id ⇒ Object (readonly)
Returns the value of attribute mocked_sandbox_payment_account_id.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def mocked_sandbox_payment_account_id @mocked_sandbox_payment_account_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def name @name end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
82 83 84 |
# File 'lib/vantiv/test_card.rb', line 82 def network @network end |
Class Method Details
.all ⇒ Object
62 63 64 65 66 |
# File 'lib/vantiv/test_card.rb', line 62 def self.all CARDS.map do |raw_card| new(raw_card[:attrs].merge(name: raw_card[:access_method_name])) end end |
.find(card_number) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/vantiv/test_card.rb', line 74 def self.find(card_number) card = CARDS.find do |card_data| card_data[:attrs][:card_number] == card_number end raise CardNotFound.new("No card with account number #{card_number}") unless card new(card[:attrs]) end |