# Test YSP Transaction Processor with Real Upstream Routing alias DaProductApp.Acquirer.YSP.TransactionProcessor alias DaProductApp.MercuryISO8583.Packagers.ISOMsg # Create test ISO message for YSP routing (DE24=782) test_message = %ISOMsg{ mti: "0200", fields: %{ 2 => "4854980600736740", 3 => "000000", 4 => "000000002600", 11 => "000454", 12 => "144505", 13 => "0924", 22 => "051", 23 => "000", 24 => "782", # YSP NII - should route to ysp_plain network 25 => "00", 35 => "4854980600736740=31052060011790", 37 => "25267144339", 41 => "12345671", 42 => "123456789012345" } } IO.puts "=== Testing YSP Transaction Processor with Real Upstream Routing ===" IO.puts "Message MTI: #{test_message.mti}" IO.puts "YSP NII (DE24): #{Map.get(test_message.fields, 24)}" IO.puts "STAN (DE11): #{Map.get(test_message.fields, 11)}" IO.puts "Amount (DE4): #{Map.get(test_message.fields, 4)}" IO.puts "" # Test the transaction processor with real upstream routing IO.puts "Calling TransactionProcessor.process_sale/2..." result = TransactionProcessor.process_sale(test_message, %{transaction_trace_id: "TEST_UPSTREAM_001"}) case result do {:ok, switch_response, final_txn} -> IO.puts "✅ Transaction completed successfully!" IO.puts "Response MTI: #{switch_response.mti}" IO.puts "Response Code: #{ISOMsg.get(switch_response, 39)}" IO.puts "Auth Code: #{ISOMsg.get(switch_response, 38)}" IO.puts "Reference Number: #{ISOMsg.get(switch_response, 37)}" IO.puts "Final Transaction ID: #{final_txn.id}" IO.puts "Final Transaction Status: #{final_txn.response_code}" {:error, reason} -> IO.puts "❌ Transaction failed: #{inspect(reason)}" other -> IO.puts "Unexpected result: #{inspect(other)}" end IO.puts "\n=== Test Complete ==="