Class: Spree::PaymentMethod::SimpleBogusCreditCard

Inherits:
BogusCreditCard show all
Defined in:
app/models/spree/payment_method/simple_bogus_credit_card.rb

Overview

Bogus Gateway that doesn’t support payment profiles.

Direct Known Subclasses

Gateway::BogusSimple

Constant Summary

Constants inherited from BogusCreditCard

BogusCreditCard::TEST_AMEX, BogusCreditCard::TEST_DISC, BogusCreditCard::TEST_MC, BogusCreditCard::TEST_VISA, BogusCreditCard::VALID_CCS

Instance Attribute Summary

Attributes inherited from BogusCreditCard

#test

Instance Method Summary collapse

Methods inherited from BogusCreditCard

#actions, #capture, #create_profile, #credit, #gateway_class, #test?, #try_void, #void

Methods inherited from CreditCard

#partial_name, #payment_source_class, #reusable_sources, #reusable_sources_by_order, #supports?

Methods inherited from Spree::PaymentMethod

active?, #auto_capture?, available, const_missing, #deprecated_method_type_override, #display_on, #display_on=, find_with_destroyed, #gateway, #method_type, model_name, #options, #partial_name, #payment_source_class, providers, #reusable_sources, #source_required?, #store_credit?, #supports?, #try_void

Methods included from Spree::Preferences::StaticallyConfigurable

#preference_source=, #preferences, #preferences=

Methods included from Spree::ParanoiaDeprecations

#paranoia_delete, #paranoia_destroy

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Spree::Preferences::Preferable

#admin_form_preference_names, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#authorize(_money, credit_card, _options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'app/models/spree/payment_method/simple_bogus_credit_card.rb', line 10

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

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/models/spree/payment_method/simple_bogus_credit_card.rb', line 6

def payment_profiles_supported?
  false
end

#purchase(_money, credit_card, _options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'app/models/spree/payment_method/simple_bogus_credit_card.rb', line 18

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