Sha256: d88fb60144f821423c8e30a012dd8cd8ddf1795608ac965fe86b7d995ced31ab

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module SolidusAfterpay
  class PaymentSource < SolidusSupport.payment_source_parent_class
    self.table_name = 'solidus_afterpay_payment_sources'

    validates :token, presence: true

    def actions
      %w[capture void credit]
    end

    def can_void?(payment)
      payment_method = payment.payment_method

      return false if payment_method.auto_capture

      payment_state = payment_method.gateway.find_payment(order_id: payment.response_code).try(:[], :paymentState)

      ::SolidusAfterpay::Gateway::VOIDABLE_STATUSES.include?(payment_state)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_afterpay-0.3.0 app/models/solidus_afterpay/payment_source.rb
solidus_afterpay-0.2.0 app/models/solidus_afterpay/payment_source.rb