Sha256: 323c4f0437d23b7e977fbee27560fdcf6a38e69058304a7d0b303b9fc5ffbace

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

module Gateway

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

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

      boleto_transaction = BoletoTransactionReportFile.new
      boleto_transaction.Order.OrderKey = elements[1]
      boleto_transaction.Order.OrderReference = elements[2]
      boleto_transaction.Order.MerchantKey = elements[3]
      boleto_transaction.Order.MerchantName = elements[4]

      boleto_transaction.TransactionKey = elements[5]
      boleto_transaction.TransactionReference = elements[6]
      boleto_transaction.Status = elements[7]
      boleto_transaction.NossoNumero = elements[8]
      boleto_transaction.BankNumber = elements[9]
      boleto_transaction.Agency = elements[10]
      boleto_transaction.Account = elements[11]
      boleto_transaction.BarCode = elements[12]
      boleto_transaction.ExpirationDate = DateTime.strptime(elements[13], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT)
      boleto_transaction.AmountInCents = elements[14].to_i
      boleto_transaction.AmountPaidInCents = (elements[15].to_s == '') == false ? elements[15].to_i : 0
      boleto_transaction.PaymentDate = (elements[16].to_s == '') == false ? DateTime.strptime(elements[16], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
      boleto_transaction.CreditDate = (elements[17].chomp.to_s == '') == false ? DateTime.strptime(elements[17], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil

      return boleto_transaction
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

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