Sha256: 1247d38caf5d49aeebb9d5496a175ad5a41f1d299f0c2061aa4ece86f6c4d369

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require 'bigdecimal'
require 'time'

module Tikkie
  module Api
    module V1
      module Responses
        # Payment that is associated with a payment request.
        class Payment < Base
          def payment_token
            data[:paymentToken]
          end

          def counter_party_name
            data[:counterPartyName]
          end

          def amount
            decimal = BigDecimal(data[:amountInCents])
            decimal /= 100.0
            decimal
          end

          def currency
            data[:amountCurrency]
          end

          def description
            data[:description]
          end

          def created_at
            Time.parse(data[:created]) if data[:created]
          end

          # See PaymentStatus
          def online_payment_status
            data[:onlinePaymentStatus]
          end

          def paid?
            online_payment_status == Tikkie::Api::V1::Types::PaymentStatus::PAID
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tikkie-api-2.0.0 lib/tikkie/api/v1/responses/payment.rb