Sha256: bd6eb6ad962111a5f4d4f980b359a6426fadc9b3f6a03ffbf8f965ea963c5749

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

module Gateway

  class OnlineDebitTransactionParser
    def Parse(elements)
      @@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'

      if elements.length < 16
        throw('The expected parameter count is 16')
      end

      online_debit_transaction = OnlineDebitTransactionReportFile.new

      online_debit_transaction.Order.OrderKey = elements[1]
      online_debit_transaction.Order.OrderReference = elements[2]
      online_debit_transaction.Order.MerchantKey = elements[3]
      online_debit_transaction.Order.MerchantName = elements[4]

      online_debit_transaction.TransactionKey = elements[5]
      online_debit_transaction.TransactionReference = elements[6]
      online_debit_transaction.Bank = elements[7]
      online_debit_transaction.Status = elements[8]
      online_debit_transaction.AmountInCents = elements[9].to_i
      online_debit_transaction.AmountPaidInCents = (elements[10].to_s == '') == false ? elements[10].to_i : 0
      online_debit_transaction.PaymentDate = (elements[11].to_s == '') == false ? DateTime.strptime(elements[11], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
      online_debit_transaction.BankReturnCode = elements[12]
      online_debit_transaction.BankPaymentDate = elements[13]
      online_debit_transaction.Signature = elements[14]
      online_debit_transaction.TransactionKeyToBank = elements[15].chomp

      return online_debit_transaction
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
mundipagg_sdk-1.4.1 lib/gateway/Parsers/online_debit_transaction_parser.rb
stone_ecommerce-1.4.0 lib/gateway/Parsers/online_debit_transaction_parser.rb
mundipagg_sdk-1.4.0 lib/gateway/Parsers/online_debit_transaction_parser.rb
stone_ecommerce-1.3.0 lib/gateway/Parsers/online_debit_transaction_parser.rb
stone_ecommerce-1.2.3 lib/gateway/Parsers/online_debit_transaction_parser.rb