Class: Gateway::AuthorizeNetCim
- Inherits:
-
Gateway
- Object
- Gateway
- Gateway::AuthorizeNetCim
- Defined in:
- app/models/spree/gateway/authorize_net_cim.rb
Instance Method Summary collapse
- #authorize(amount, creditcard, gateway_options) ⇒ Object
- #capture(authorization, creditcard, gateway_options) ⇒ Object
-
#create_profile(payment) ⇒ Object
Create a new CIM customer profile ready to accept a payment.
-
#create_profile_from_card(card) ⇒ Object
simpler form.
- #credit(amount, creditcard, response_code, gateway_options) ⇒ Object
- #options ⇒ Object
- #payment_profiles_supported? ⇒ Boolean
- #provider_class ⇒ Object
- #purchase(amount, creditcard, gateway_options) ⇒ Object
- #void(response_code, creditcard, gateway_options) ⇒ Object
Instance Method Details
#authorize(amount, creditcard, gateway_options) ⇒ Object
29 30 31 32 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 29 def (amount, creditcard, ) = { :order => {:invoice_number => [:order_id] } } create_transaction( amount, creditcard, :auth_only, ) end |
#capture(authorization, creditcard, gateway_options) ⇒ Object
38 39 40 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 38 def capture(, creditcard, ) create_transaction((.amount * 100).round, creditcard, :prior_auth_capture, :trans_id => .response_code) end |
#create_profile(payment) ⇒ Object
Create a new CIM customer profile ready to accept a payment
55 56 57 58 59 60 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 55 def create_profile(payment) if payment.source.gateway_customer_profile_id.nil? profile_hash = create_customer_profile(payment) payment.source.update_attributes(:gateway_customer_profile_id => profile_hash[:customer_profile_id], :gateway_payment_profile_id => profile_hash[:customer_payment_profile_id]) end end |
#create_profile_from_card(card) ⇒ Object
simpler form
63 64 65 66 67 68 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 63 def create_profile_from_card(card) if card.gateway_customer_profile_id.nil? profile_hash = create_customer_profile(card) card.update_attributes(:gateway_customer_profile_id => profile_hash[:customer_profile_id], :gateway_payment_profile_id => profile_hash[:customer_payment_profile_id]) end end |
#credit(amount, creditcard, response_code, gateway_options) ⇒ Object
42 43 44 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 42 def credit(amount, creditcard, response_code, ) create_transaction(amount, creditcard, :refund, :trans_id => response_code) end |
#options ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 18 def # add :test key in the options hash, as that is what the ActiveMerchant::Billing::AuthorizeNetGateway expects if self.preferred_test_mode self.class.preference :test, :boolean, :default => true else self.class.remove_preference :test end super end |
#payment_profiles_supported? ⇒ Boolean
50 51 52 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 50 def payment_profiles_supported? true end |
#provider_class ⇒ Object
14 15 16 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 14 def provider_class self.class end |
#purchase(amount, creditcard, gateway_options) ⇒ Object
34 35 36 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 34 def purchase(amount, creditcard, ) create_transaction(amount, creditcard, :auth_capture) end |
#void(response_code, creditcard, gateway_options) ⇒ Object
46 47 48 |
# File 'app/models/spree/gateway/authorize_net_cim.rb', line 46 def void(response_code, creditcard, ) create_transaction(nil, creditcard, :void, :trans_id => response_code) end |