Sha256: 4f11bc8ffeb9f34a19505d85298b12562d6d63d74e4fd8ff77bc4aec33def5c2

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

module Mollie
  class Refund < Base
    STATUS_QUEUED     = "queued"
    STATUS_PENDING    = "pending"
    STATUS_PROCESSING = "processing"
    STATUS_REFUNDED   = "refunded"
    STATUS_FAILED     = "failed"

    attr_accessor :id,
                  :amount,
                  :settlement_amount,
                  :status,
                  :payment_id,
                  :description,
                  :created_at,
                  :_links

    alias_method :links, :_links

    def queued?
      status == STATUS_QUEUED
    end

    def pending?
      status == STATUS_PENDING
    end

    def processing?
      status == STATUS_PROCESSING
    end

    def refunded?
      status == STATUS_REFUNDED
    end

    def failed?
      status == STATUS_FAILED
    end

    def amount=(amount)
      @amount = Amount.new(amount)
    end

    def settlement_amount=(settlement_amount)
      @settlement_amount = Amount.new(settlement_amount)
    end

    def created_at=(created_at)
      @created_at = Time.parse(created_at) rescue nil
    end

    def payment(options = {})
      Payment.get(payment_id, options)
    end

    def settlement(options = {})
      settlement_id = Util.extract_id(links, "settlement")
      return if settlement_id.nil?
      Settlement.get(settlement_id, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mollie-api-ruby-4.0.0.pre.alpha.2 lib/mollie/refund.rb
mollie-api-ruby-4.0.0 lib/mollie/refund.rb
mollie-api-ruby-4.0.0.pre.alpha.1 lib/mollie/refund.rb