Class: Spree::Gateway::BogusSimple

Inherits:
Bogus show all
Defined in:
app/models/spree/gateway/bogus_simple.rb

Constant Summary

Constants inherited from Bogus

Spree::Gateway::Bogus::TEST_AMEX, Spree::Gateway::Bogus::TEST_DISC, Spree::Gateway::Bogus::TEST_MC, Spree::Gateway::Bogus::TEST_VISA, Spree::Gateway::Bogus::VALID_CCS

Constants inherited from PaymentMethod

PaymentMethod::DISPLAY

Instance Attribute Summary

Attributes inherited from Bogus

#test

Instance Method Summary collapse

Methods inherited from Bogus

#actions, #create_profile, #credit, #preferences, #provider_class, #test?, #void

Methods inherited from Spree::Gateway

current, #method_missing, #method_type, #options, #payment_source_class, #provider, #supports?

Methods inherited from PaymentMethod

active?, #auto_capture?, available, find_with_destroyed, #method_type, #payment_source_class, #provider_class, providers, #source_required?, #supports?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spree::Gateway

Instance Method Details

#authorize(money, credit_card, options = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'app/models/spree/gateway/bogus_simple.rb', line 17

def authorize(money, credit_card, options = {})
  if VALID_CCS.include? credit_card.number
    ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345', :avs_result => { :code => 'A' })
  else
    ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', { :message => 'Bogus Gateway: Forced failure' }, :test => true)
  end
end

#capture(money, response_code, options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'app/models/spree/gateway/bogus_simple.rb', line 9

def capture(money, response_code, options = {})
  if response_code == '12345'
    ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '67890')
  else
    ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', :error => 'Bogus Gateway: Forced failure', :test => true)
  end
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/models/spree/gateway/bogus_simple.rb', line 5

def payment_profiles_supported?
  false
end

#purchase(money, credit_card, options = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'app/models/spree/gateway/bogus_simple.rb', line 25

def purchase(money, credit_card, options = {})
  if VALID_CCS.include? credit_card.number
    ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345', :avs_result => { :code => 'A' })
  else
    ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', :message => 'Bogus Gateway: Forced failure', :test => true)
  end
end