Class: SolidusAfterpay::PaymentMethod

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_afterpay/payment_method.rb

Instance Method Summary collapse

Instance Method Details

#available_for_order?(order) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'app/models/solidus_afterpay/payment_method.rb', line 33

def available_for_order?(order)
  return false if order.line_items.any?{ |item| excluded_product_ids.include? item.variant.product_id }

  available_payment_currency == order.currency && available_payment_range.include?(order.total)
end

#excluded_product?(product) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/solidus_afterpay/payment_method.rb', line 39

def excluded_product?(product)
  excluded_product_ids.include? product.id
end

#gateway_classObject



11
12
13
# File 'app/models/solidus_afterpay/payment_method.rb', line 11

def gateway_class
  SolidusAfterpay::Gateway
end

#partial_nameObject



19
20
21
# File 'app/models/solidus_afterpay/payment_method.rb', line 19

def partial_name
  'afterpay'
end

#payment_source_classObject



15
16
17
# File 'app/models/solidus_afterpay/payment_method.rb', line 15

def payment_source_class
  SolidusAfterpay::PaymentSource
end

#try_void(payment) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'app/models/solidus_afterpay/payment_method.rb', line 23

def try_void(payment)
  return false unless payment.payment_source.can_void?(payment)

  response = void(payment.response_code, { originator: payment, currency: payment.currency })

  return false unless response.success?

  response
end