Sha256: d8e2ea395f058b713af491264355f1cbb38fb2d5cbed020aa73004fa326e393d

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

module Epaybg
  module Recurring
    class Payment

      RESPONSE_STATUS_CODES = {
        ok: '00',
        err: '96',
        duplicate: '94'
      }

      attr_accessor :xtype, :idn, :tid, :amount, :secondid, :ref, :aid, :tdate, :clientid

      def initialize(params = {})
        params.each do |k, v|
          instance_variable_set("@#{k}", v)
        end

        yield self if block_given?
      end

      def respond_with(symbol)
        raise 'Invalid symbol' unless RESPONSE_STATUS_CODES.keys.include?(symbol)

        code = RESPONSE_STATUS_CODES[symbol]
        @response = "XTYPE=RBC\nSTATUS=#{code}\n"
      end

      def response_array
        @response.split("\n")
      end

      def tdate
        Date.parse(@tdate)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
epaybg-1.0.0 lib/epaybg/recurring/payment.rb