Class: ActiveMerchant::Billing::NexioApmGateway

Inherits:
NexioBaseGateway show all
Defined in:
lib/active_merchant/billing/gateways/nexio_apm_gateway.rb

Defined Under Namespace

Classes: OneTimeToken

Instance Method Summary collapse

Methods inherited from NexioBaseGateway

#capture, #get_transaction, #initialize, #refund, #scrub, #set_secret, #setup_webhooks, #supports_scrubbing?, #void

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::NexioBaseGateway

Instance Method Details

#authorize(money, payment, options = {}) ⇒ Object



43
44
45
# File 'lib/active_merchant/billing/gateways/nexio_apm_gateway.rb', line 43

def authorize(money, payment, options = {})
  purchase(money, payment, options.merge(is_auth_only: true))
end

#generate_token(money, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_merchant/billing/gateways/nexio_apm_gateway.rb', line 14

def generate_token(money, options = {})
  post = build_payload(options)
  add_invoice(post, money, options)
  post[:data][:paymentMethod] = options[:payment_method] if options[:payment_method].present?
  add_order_data(post, options)
  post[:customerRedirectUrl] = options[:callback_url] if options[:callback_url].present?
  post[:processingOptions][:saveRecurringToken] = true if options[:save_token]
  post[:isAuthOnly] = true if options[:is_auth_only]
  resp = commit('token', post)
  return unless resp.success?

  OneTimeToken.new(
    resp.params['token'],
    resp.params['expressIFrameUrl'],
    resp.params['scriptUrl'],
    map_urls(resp.params['redirectUrls']),
    map_urls(resp.params['buttonIFrameUrls'])
  )
end

#purchase(money, payment, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/active_merchant/billing/gateways/nexio_apm_gateway.rb', line 34

def purchase(money, payment, options = {})
  post = build_payload(options)
  add_invoice(post, money, options)
  post[:apm] = { token: payment.is_a?(Spree::PaymentSource) ? payment.gateway_payment_profile_id : payment }
  add_order_data(post, options)
  post[:isAuthOnly] = true if options[:is_auth_only]
  commit('process', post)
end