Class: SolidusAfterpay::PaymentMethod
- Inherits:
-
Object
- Object
- SolidusAfterpay::PaymentMethod
- Defined in:
- app/models/solidus_afterpay/payment_method.rb
Instance Method Summary collapse
- #available_for_order?(order) ⇒ Boolean
- #excluded_product?(product) ⇒ Boolean
- #gateway_class ⇒ Object
- #partial_name ⇒ Object
- #payment_source_class ⇒ Object
- #try_void(payment) ⇒ Object
Instance Method Details
#available_for_order?(order) ⇒ 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
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_class ⇒ Object
11 12 13 |
# File 'app/models/solidus_afterpay/payment_method.rb', line 11 def gateway_class SolidusAfterpay::Gateway end |
#partial_name ⇒ Object
19 20 21 |
# File 'app/models/solidus_afterpay/payment_method.rb', line 19 def partial_name 'afterpay' end |
#payment_source_class ⇒ Object
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 |