Class: GimmeGimme::FakeCimServer::Transaction

Inherits:
Object
  • Object
show all
Includes:
RequestParser
Defined in:
lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb

Direct Known Subclasses

AuthOnlyTransaction, CaptureOnlyTransaction

Defined Under Namespace

Classes: NotImplementedError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestParser

#at

Constructor Details

#initialize(customer_profiles, customer_payment_profiles, document, transactions) ⇒ Transaction

Returns a new instance of Transaction.



247
248
249
250
251
252
253
254
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 247

def initialize(customer_profiles, customer_payment_profiles, document, transactions)
  @document = document
  @amount                      = at("amount").to_f
  @customer_profile_id         = at("customerProfileId")
  @customer_profile_payment_id = at("customerPaymentProfileId")
  @customer_profile            = customer_profiles[@customer_profile_id.to_i]
  @customer_payment_profile    = customer_payment_profiles[@customer_profile_payment_id.to_i]
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



237
238
239
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 237

def amount
  @amount
end

#customer_payment_profileObject (readonly)

Returns the value of attribute customer_payment_profile.



237
238
239
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 237

def customer_payment_profile
  @customer_payment_profile
end

#customer_profileObject (readonly)

Returns the value of attribute customer_profile.



237
238
239
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 237

def customer_profile
  @customer_profile
end

#customer_profile_idObject (readonly)

Returns the value of attribute customer_profile_id.



237
238
239
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 237

def customer_profile_id
  @customer_profile_id
end

#transactionsObject (readonly)

Returns the value of attribute transactions.



237
238
239
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 237

def transactions
  @transactions
end

Class Method Details

.create(customer_profiles, customer_payment_profiles, document, transactions) ⇒ Object



239
240
241
242
243
244
245
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 239

def self.create(customer_profiles, customer_payment_profiles, document, transactions)
  if document.at("profileTransAuthOnly").present?
    AuthOnlyTransaction.new(customer_profiles, customer_payment_profiles, document, transactions)
  elsif document.at("profileTransCaptureOnly").present?
    CaptureOnlyTransaction.new(customer_profiles, customer_payment_profiles, document, transactions)
  end
end

Instance Method Details

#card_numberObject



256
257
258
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 256

def card_number
  customer_payment_profile.card_number
end

#extra_response_optsObject



265
266
267
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 265

def extra_response_opts
  raise NotImplementedError
end

#success?Boolean

Returns:

  • (Boolean)


260
261
262
263
# File 'lib/generators/gimme_gimme/test_support/templates/testing/fake_cim_server.rb', line 260

def success?
  !customer_profile.nil? &&
    customer_profile.customer_payment_profile_id == @customer_profile_payment_id.to_i
end