Class: Gateway::Payway
- Inherits:
-
PaymentMethod
- Object
- PaymentMethod
- Gateway::Payway
- Defined in:
- app/models/spree/gateway/payway.rb
Instance Method Summary collapse
-
#auto_capture? ⇒ Boolean
force to purchase instead of authorize.
-
#available_for_order?(_order) ⇒ Boolean
Custom PaymentMethod/Gateway can redefine this method to check method availability for concrete order.
- #cancel(_response_code, _gateway_options) ⇒ Object
- #card_type ⇒ Object
-
#method_type ⇒ Object
partial to render the gateway.
- #payment_profiles_supported? ⇒ Boolean
-
#payment_source_class ⇒ Object
Only enable one-click payments if spree_auth_devise is installed def self.allow_one_click_payments? Gem.loaded_specs.key?(‘spree_auth_devise’) end.
- #process(_money, _source, gateway_options) ⇒ Object
Instance Method Details
#auto_capture? ⇒ Boolean
force to purchase instead of authorize
47 48 49 |
# File 'app/models/spree/gateway/payway.rb', line 47 def auto_capture? true end |
#available_for_order?(_order) ⇒ Boolean
Custom PaymentMethod/Gateway can redefine this method to check method availability for concrete order.
42 43 44 |
# File 'app/models/spree/gateway/payway.rb', line 42 def available_for_order?(_order) true end |
#cancel(_response_code, _gateway_options) ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/models/spree/gateway/payway.rb', line 58 def cancel(_response_code, ) # we can use this to send request to payment gateway api to cancel the payment ( void ) # currently Payway does not support to cancel the gateway # in our case don't do anything ActiveMerchant::Billing::Response.new(true, 'Payway order has been cancelled.') end |
#card_type ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/spree/gateway/payway.rb', line 27 def card_type if Vpago::Payway::CARD_TYPES.index(preferences[:payment_option]).nil? Vpago::Payway::CARD_TYPE_ABAPAY else preferences[:payment_option] end end |
#method_type ⇒ Object
partial to render the gateway.
36 37 38 |
# File 'app/models/spree/gateway/payway.rb', line 36 def method_type 'payment_payway' end |
#payment_profiles_supported? ⇒ Boolean
23 24 25 |
# File 'app/models/spree/gateway/payway.rb', line 23 def payment_profiles_supported? false end |
#payment_source_class ⇒ Object
Only enable one-click payments if spree_auth_devise is installed def self.allow_one_click_payments?
Gem.loaded_specs.key?('spree_auth_devise')
end
19 20 21 |
# File 'app/models/spree/gateway/payway.rb', line 19 def payment_source_class Spree::VpagoPaymentSource end |
#process(_money, _source, gateway_options) ⇒ Object
51 52 53 54 55 56 |
# File 'app/models/spree/gateway/payway.rb', line 51 def process(_money, _source, ) Rails.logger.debug { "About to create payment for order #{[:order_id]}" } # First of all, invalidate all previous tranx orders to prevent multiple paid orders # source.save! ActiveMerchant::Billing::Response.new(true, 'Order created') end |