Class: Gateway::Samurai
- Inherits:
-
Gateway
- Object
- Gateway
- Gateway::Samurai
- Defined in:
- app/models/spree/gateway/samurai.rb
Instance Method Summary collapse
- #authorize(money, creditcard, gateway_options) ⇒ Object
- #capture(authorization, creditcard, gateway_options) ⇒ Object
- #create_profile(payment) ⇒ Object
- #credit(money, creditcard, response_code, gateway_options) ⇒ Object
- #payment_profiles_supported? ⇒ Boolean
- #provider_class ⇒ Object
- #purchase(money, creditcard, gateway_options) ⇒ Object
- #void(response_code, gateway_options) ⇒ Object
Instance Method Details
#authorize(money, creditcard, gateway_options) ⇒ Object
24 25 26 27 28 29 |
# File 'app/models/spree/gateway/samurai.rb', line 24 def (money, creditcard, ) [:billing_reference] = [:order_id] [:customer_reference] = [:customer] [:description] = "Spree Order" provider.(money, creditcard.gateway_customer_profile_id, ) end |
#capture(authorization, creditcard, gateway_options) ⇒ Object
31 32 33 34 35 36 |
# File 'app/models/spree/gateway/samurai.rb', line 31 def capture(, creditcard, ) [:billing_reference] = [:order_id] [:customer_reference] = [:customer] [:description] = "Spree Order" provider.capture(nil, .response_code, {}) end |
#create_profile(payment) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/spree/gateway/samurai.rb', line 46 def create_profile(payment) return unless payment.source.gateway_customer_profile_id.nil? = {} [:email] = payment.order.email [:address] = {} [:address][:address1] = payment.order.bill_address.address1 [:address][:address2] = payment.order.bill_address.address2 [:address][:city] = payment.order.bill_address.city [:address][:state] = payment.order.bill_address.state.abbr [:address][:zip] = payment.order.bill_address.zipcode response = provider.store(payment.source, ) if response.success? payment.source.update_attributes!(:gateway_customer_profile_id => response.params['payment_method_token']) else payment.send(:gateway_error, response.) end end |
#credit(money, creditcard, response_code, gateway_options) ⇒ Object
38 39 40 |
# File 'app/models/spree/gateway/samurai.rb', line 38 def credit(money, creditcard, response_code, ) provider.credit(money, response_code, {}) end |
#payment_profiles_supported? ⇒ Boolean
13 14 15 |
# File 'app/models/spree/gateway/samurai.rb', line 13 def payment_profiles_supported? true end |
#provider_class ⇒ Object
9 10 11 |
# File 'app/models/spree/gateway/samurai.rb', line 9 def provider_class ActiveMerchant::Billing::SamuraiGateway end |
#purchase(money, creditcard, gateway_options) ⇒ Object
17 18 19 20 21 22 |
# File 'app/models/spree/gateway/samurai.rb', line 17 def purchase(money, creditcard, ) [:billing_reference] = [:order_id] [:customer_reference] = [:customer] [:description] = "Spree Order" provider.purchase(money, creditcard.gateway_customer_profile_id, ) end |
#void(response_code, gateway_options) ⇒ Object
42 43 44 |
# File 'app/models/spree/gateway/samurai.rb', line 42 def void(response_code, ) provider.void(response_code, {}) end |