class Vantiv::MockedSandbox::CardforFixtureGeneration
The similarities between this and Vantiv::TestAccount are too great.
They ought to be cleaned up and merged
Attributes
card[R]
Public Class Methods
new(card)
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 173 def initialize(card) @card = card end
Public Instance Methods
card_number()
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 181 def card_number card.card_number end
cvv()
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 193 def cvv card.cvv end
expiry_month()
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 185 def expiry_month card.expiry_month end
expiry_year()
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 189 def expiry_year card.expiry_year end
mocked_sandbox_payment_account_id()
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 197 def mocked_sandbox_payment_account_id card.mocked_sandbox_payment_account_id end
payment_account_id()
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 177 def payment_account_id @payment_account_id ||= get_payment_account_id end
Private Instance Methods
get_payment_account_id(attempts=0)
click to toggle source
# File lib/vantiv/mocked_sandbox/fixture_generator.rb, line 205 def get_payment_account_id(attempts=0) tokenization = Vantiv.tokenize_by_direct_post( card_number: card.card_number, expiry_month: card.expiry_month, expiry_year: card.expiry_year, cvv: card.cvv ) if tokenization.success? tokenization.payment_account_id elsif attempts < 3 attempts += 1 get_payment_account_id(attempts) else raise "Tried and failed to get payment account id" end end