Class: Gateway::Acleda

Inherits:
PaymentMethod
  • Object
show all
Defined in:
app/models/spree/gateway/acleda.rb

Constant Summary collapse

TYPES =
%w[KHQR XPAY-MPGS].freeze

Instance Method Summary collapse

Instance Method Details

#auto_capture?Boolean

force to purchase instead of authorize

Returns:

  • (Boolean)


44
45
46
# File 'app/models/spree/gateway/acleda.rb', line 44

def auto_capture?
  true
end

#available_for_order?(_order) ⇒ Boolean

Custom PaymentMethod/Gateway can redefine this method to check method availability for concrete order.

Returns:

  • (Boolean)


39
40
41
# File 'app/models/spree/gateway/acleda.rb', line 39

def available_for_order?(_order)
  true
end

#cancel(_response_code) ⇒ Object



55
56
57
58
59
60
61
# File 'app/models/spree/gateway/acleda.rb', line 55

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, 'Acleda order has been cancelled.')
end

#khqr?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/models/spree/gateway/acleda.rb', line 25

def khqr?
  preferred_acleda_type == 'KHQR'
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/spree/gateway/acleda.rb', line 33

def payment_profiles_supported?
  false
end

#payment_source_classObject



29
30
31
# File 'app/models/spree/gateway/acleda.rb', line 29

def payment_source_class
  Spree::VpagoPaymentSource
end

#process(_money, _source, gateway_options) ⇒ Object



48
49
50
51
52
53
# File 'app/models/spree/gateway/acleda.rb', line 48

def process(_money, _source, gateway_options)
  Rails.logger.debug { "About to create payment for order #{gateway_options[: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

#xpay_mpgs?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/spree/gateway/acleda.rb', line 21

def xpay_mpgs?
  preferred_acleda_type == 'XPAY-MPGS'
end