Sha256: f4d9b7efa532af9482c8ba1205546632411740983e69b9e7ae1e15326771cc1d

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

require 'bigdecimal'
require 'time'

module Tikkie
  module Api
    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.new(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::Types::PaymentStatus::PAID
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tikkie-api-0.1.1 lib/tikkie/api/responses/payment.rb
tikkie-api-0.1.0 lib/tikkie/api/responses/payment.rb