#!/usr/bin/env elixir # Simple test to verify ISO8583 message encoding Mix.install([]) defmodule ISOTest do def run do # Load the application modules Code.require_file("lib/da_product_app.ex") # Start the application Application.ensure_all_started(:da_product_app) # Create a test message alias DaProductApp.MercuryISO8583.Packagers.{ISOMsg, ISO87BPackager} alias DaProductApp.Switch.ISO8583BMessageHandler IO.puts("Creating test ISO8583 message...") # Create message with packager msg = ISOMsg.new("0410") msg = ISOMsg.set_packager(msg, ISO87BPackager) # Add some fields msg = ISOMsg.set(msg, 2, "4854980600736740") msg = ISOMsg.set(msg, 3, "8000") msg = ISOMsg.set(msg, 4, "600") msg = ISOMsg.set(msg, 39, "96") IO.puts("Message created with fields: #{inspect(ISOMsg.get_all_fields(msg))}") # Test encoding case ISO8583BMessageHandler.encode(msg) do {:ok, encoded_data} -> IO.puts("✅ Message encoded successfully!") IO.puts("Encoded length: #{byte_size(encoded_data)} bytes") IO.puts("Encoded hex: #{Base.encode16(encoded_data) |> String.slice(0, 100)}...") {:error, reason} -> IO.puts("❌ Encoding failed: #{inspect(reason)}") end end end ISOTest.run()