Class: Vantiv::TestCard
- Inherits:
-
Object
- Object
- Vantiv::TestCard
- Defined in:
- lib/vantiv/test_card.rb
Defined Under Namespace
Classes: CardNotFound
Constant Summary collapse
- CARDS =
[ { name: "valid_account", card_number: "4457010000000009", expiry_month: "01", expiry_year: "21", cvv: "349", mocked_sandbox_payment_account_id: "1111111111110009", network: "VI" }, { name: "invalid_card_number", card_number: "4457010010900010", expiry_month: "01", expiry_year: "21", cvv: "349", mocked_sandbox_payment_account_id: nil, network: "VI" }, { name: "invalid_account_number", card_number: "5112001600000006", expiry_month: "01", expiry_year: "20", cvv: "349", mocked_sandbox_payment_account_id: "1111111111130006", network: "MC" }, { name: "insufficient_funds", card_number: "4457002100000005", expiry_month: "01", expiry_year: "20", cvv: "349", mocked_sandbox_payment_account_id: "1111111111120005", network: "VI" }, { name: "expired_card", card_number: "5112001900000003", expiry_month: "01", expiry_year: "20", cvv: "349", mocked_sandbox_payment_account_id: "1111111111140003", network: "MC" }, { name: "account_updater", card_number: "4457000300000007", expiry_month: "01", expiry_year: "15", cvv: "123", mocked_sandbox_payment_account_id: "1111111111120007", network: "VI" }, { name: "account_updater_account_closed", card_number: "5112000101110009", expiry_month: "11", expiry_year: "99", cvv: "123", mocked_sandbox_payment_account_id: "1111111111160009", network: "MC" }, { name: "account_updater_contact_cardholder", card_number: "4457000301100004", expiry_month: "11", expiry_year: "99", cvv: "123", mocked_sandbox_payment_account_id: "1111111111130004", network: "VI" }, ]
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.
-
#temporary_token ⇒ Object
readonly
Returns the value of attribute temporary_token.
Class Method Summary collapse
Instance Method Summary collapse
- #!=(other_object) ⇒ Object
- #==(other_object) ⇒ Object
-
#initialize(card_number:, expiry_month:, expiry_year:, cvv:, mocked_sandbox_payment_account_id:, network:, name:, temporary_token:) ⇒ TestCard
constructor
A new instance of TestCard.
- #tokenizable? ⇒ Boolean
Constructor Details
#initialize(card_number:, expiry_month:, expiry_year:, cvv:, mocked_sandbox_payment_account_id:, network:, name:, temporary_token:) ⇒ TestCard
Returns a new instance of TestCard.
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/vantiv/test_card.rb', line 116 def initialize(card_number:, expiry_month:, expiry_year:, cvv:, mocked_sandbox_payment_account_id:, network:, name:, temporary_token:) @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 @temporary_token = temporary_token end |
Instance Attribute Details
#card_number ⇒ Object (readonly)
Returns the value of attribute card_number.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def card_number @card_number end |
#cvv ⇒ Object (readonly)
Returns the value of attribute cvv.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def cvv @cvv end |
#expiry_month ⇒ Object (readonly)
Returns the value of attribute expiry_month.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def expiry_month @expiry_month end |
#expiry_year ⇒ Object (readonly)
Returns the value of attribute expiry_year.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def expiry_year @expiry_year end |
#mocked_sandbox_payment_account_id ⇒ Object (readonly)
Returns the value of attribute mocked_sandbox_payment_account_id.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def mocked_sandbox_payment_account_id @mocked_sandbox_payment_account_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def name @name end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def network @network end |
#temporary_token ⇒ Object (readonly)
Returns the value of attribute temporary_token.
114 115 116 |
# File 'lib/vantiv/test_card.rb', line 114 def temporary_token @temporary_token end |
Class Method Details
.all ⇒ Object
86 87 88 89 90 |
# File 'lib/vantiv/test_card.rb', line 86 def self.all CARDS.map do |raw_card| new(raw_card) end end |
.find(card_number) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/vantiv/test_card.rb', line 98 def self.find(card_number) card = CARDS.find do |card_data| card_data[:card_number] == card_number end raise CardNotFound.new("No card with account number #{card_number}") unless card new(card) end |
.find_by_payment_account_id(payment_account_id) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/vantiv/test_card.rb', line 106 def self.find_by_payment_account_id(payment_account_id) card = CARDS.find do |card_data| card_data[:mocked_sandbox_payment_account_id] == payment_account_id end raise CardNotFound.new("No card with mocked sandbox payment account id #{payment_account_id}") unless card new(card) end |
Instance Method Details
#!=(other_object) ⇒ Object
135 136 137 |
# File 'lib/vantiv/test_card.rb', line 135 def !=(other_object) !(self == other_object) end |
#==(other_object) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/vantiv/test_card.rb', line 127 def ==(other_object) if other_object.is_a?(TestCard) name == other_object.name else super end end |
#tokenizable? ⇒ Boolean
139 140 141 |
# File 'lib/vantiv/test_card.rb', line 139 def tokenizable? self != TestCard.invalid_card_number end |