Sha256: 7333c3d964aac3e2fd9f804ba8fdad346de7f0696298aad985367332c6fb12c9

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

module Workarea
  decorate Payment::Refund, with: :cim do
    decorated { validate :has_refundable_transactions }

    private

    def has_refundable_transactions
      amounts_with_tenders.each do |tender, _amount|
        next unless tender.slug == :credit_card

        tender.transactions.successful.not_canceled.captures_or_purchased.each do |transaction|
          if transaction.created_at >= Time.now - 24.hours
            errors.add(:credit_card, "This transaction hasn't been settled yet, and isn't eligble for refunding")
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-authorize_cim-2.1.3 app/models/workarea/payment/refund.decorator
workarea-authorize_cim-2.1.2 app/models/workarea/payment/refund.decorator
workarea-authorize_cim-2.1.1 app/models/workarea/payment/refund.decorator