# YSP Processor Compilation Fixes

## Issue Fixed

**Error**: `cannot invoke remote function Keyword.get/3 inside a guard`

**Location**: `lib/da_product_app/acquirer/ysp/ysp_processor.ex:1047:44`

## Root Cause

The `process_with_hex_debug/3` function was using `Keyword.get/3` calls inside guard clauses:

```elixir
# PROBLEMATIC CODE:
case result do
  {:ok, response_message} when Keyword.get(opts, :print_response, true) ->
    # ... processing
```

Guard clauses in Elixir can only use a limited set of functions, and `Keyword.get/3` is not allowed.

## Solution Applied

Extracted the keyword option values before the pattern matching:

```elixir
def process_with_hex_debug(message, context \\ %{}, opts \\ []) do
  # Extract options early to avoid guard clause issues
  print_request = Keyword.get(opts, :print_request, true)
  print_response = Keyword.get(opts, :print_response, true)
  print_errors = Keyword.get(opts, :print_errors, true)

  # ... processing

  case result do
    {:ok, response_message} ->
      if print_response do
        # ... print response
      end
      result
  end
end
```

## Additional Fixes Applied

1. **Fixed ISOMsg API calls**:
   - `ISOMsg.set(message, "0220")` → `ISOMsg.set(message, 0, "0220")`
   - `ISOMsg.set(message, "0400")` → `ISOMsg.set(message, 0, "0400")`

2. **Fixed deprecated Logger calls**:
   - `Logger.warn/1` → `Logger.warning/1`

3. **Fixed syntax issues**:
   - Corrected malformed `with` statement in `create_temp_transaction/2`
   - Added proper variable naming for unused parameters

## Status

✅ **Critical compilation error fixed**  
✅ **Additional API mismatches corrected**  
⚠️ **Remaining warnings** (non-blocking):
- Unused aliases and functions (normal for work-in-progress code)
- Missing modules (expected in larger system)
- @doc attributes on private functions (cosmetic)

## Testing

The hex printing functionality should now compile successfully. You can test with:

```elixir
# Basic hex printing
YspMessageFraming.print_hex_with_header(iso_data)

# Process with debug output (now works without guard clause errors)
YspProcessor.process_with_hex_debug(message, context)
```

## Files Modified

- `/lib/da_product_app/acquirer/ysp/ysp_processor.ex` - Fixed guard clause and API issues

The implementation is now ready for use and should compile without the critical errors that were blocking development.