Class: SolidusNexio::AlternativePaymentMethod

Inherits:
Spree::PaymentMethod
  • Object
show all
Includes:
NexioPaymentCommons
Defined in:
app/models/solidus_nexio/alternative_payment_method.rb

Instance Method Summary collapse

Methods included from NexioPaymentCommons

#authorize, #cancel, #purchase

Instance Method Details

#generate_token(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/solidus_nexio/alternative_payment_method.rb', line 20

def generate_token(options)
  order = Spree::Order.find_by(number: options.dig(:order, :number))
  return unless order

  amount = order.respond_to?(:order_total_after_store_credit) ? order.order_total_after_store_credit : order.total
  params = {
    payment_method: preferred_payment_method,
    save_token: preferred_save_token,
    is_auth_only: !auto_capture?
  }.merge!(description_payload(order, options), request_domain_payload(options), options)

  gateway.generate_token(amount.to_money.cents, params)
end

#partial_nameObject Also known as: method_type



15
16
17
# File 'app/models/solidus_nexio/alternative_payment_method.rb', line 15

def partial_name
  'nexio_apm'
end

#payment_source_classObject



34
35
36
# File 'app/models/solidus_nexio/alternative_payment_method.rb', line 34

def payment_source_class
  ApmSource
end

#try_void(payment) ⇒ Object



38
39
40
# File 'app/models/solidus_nexio/alternative_payment_method.rb', line 38

def try_void(payment)
  cancel(payment.response_code)
end