Sha256: 4f0e2c4c4512b4111befafbfcca48c1f06979297b6be6c483888e2103f60ecec

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

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

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mundipagg_sdk-1.0.2 lib/gateway/Parsers/online_debit_transaction_parser.rb
mundipagg_sdk-1.0.1 lib/gateway/Parsers/online_debit_transaction_parser.rb
mundipagg_sdk-1.0.0 lib/gateway/Parsers/online_debit_transaction_parser.rb
mundipagg_api-1.3.1 lib/mundipagg/Parsers/online_debit_transaction_parser.rb
mundipagg_api-1.3.0 lib/mundipagg/Parsers/online_debit_transaction_parser.rb
mundipagg_api-1.1.1 lib/mundipagg/Parsers/online_debit_transaction_parser.rb
mundipagg_api-1.1.0 lib/mundipagg/Parsers/online_debit_transaction_parser.rb
mundipagg_api-1.0.1 lib/mundipagg/Parsers/online_debit_transaction_parser.rb
mundipagg_api-1.0.0 lib/mundipagg/Parsers/online_debit_transaction_parser.rb