> ## Documentation Index
> Fetch the complete documentation index at: https://iso8583sim.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Card Networks

> iso8583sim supports multiple card networks with network-specific field definitions and validation rules.

## Supported Networks

| Network | PAN Prefixes | Documentation |
| - | - | - |
| VISA | 4xxx | [VISA Guide](./visa) |
| Mastercard | 51-55, 2221-2720 | [Mastercard Guide](./mastercard) |
| AMEX | 34, 37 | [Other Networks](./others) |
| Discover | 6011, 644-649, 65 | [Other Networks](./others) |
| JCB | 3528-3589 | [Other Networks](./others) |
| UnionPay | 62 | [Other Networks](./others) |

## Network Detection

Networks are automatically detected from the PAN (Primary Account Number):

```python theme={null}
from iso8583sim.core.parser import ISO8583Parser

parser = ISO8583Parser()
message = parser.parse(raw_message)

print(message.network)  # CardNetwork.VISA
```

### Detection Rules

```python theme={null}
from iso8583sim.core.types import detect_network

detect_network("4111111111111111")    # CardNetwork.VISA
detect_network("5500000000000004")    # CardNetwork.MASTERCARD
detect_network("378282246310005")     # CardNetwork.AMEX
detect_network("6011111111111117")    # CardNetwork.DISCOVER
detect_network("3530111333300000")    # CardNetwork.JCB
detect_network("6200000000000005")    # CardNetwork.UNIONPAY
```

## Manual Network Specification

Override auto-detection by specifying the network:

```python theme={null}
from iso8583sim.core.types import CardNetwork

# During parsing
message = parser.parse(raw_message, network=CardNetwork.MASTERCARD)

# In message object
message = ISO8583Message(
    mti="0100",
    network=CardNetwork.VISA,
    fields={...}
)
```

## Network-Specific Fields

Each network has specific field format requirements:

```python theme={null}
from iso8583sim.core.types import NETWORK_SPECIFIC_FIELDS

# Get VISA-specific field 62 definition
visa_field_62 = NETWORK_SPECIFIC_FIELDS[CardNetwork.VISA].get(62)
```

## Required Fields by Network

Different networks require different fields for authorization:

| Network | Required Fields |
| - | - |
| VISA | 2, 3, 4, 11, 14, 22, 24, 25 |
| Mastercard | 2, 3, 4, 11, 22, 24, 25 |
| AMEX | 2, 3, 4, 11, 22, 25 |
| Discover | 2, 3, 4, 11, 22 |
| JCB | 2, 3, 4, 11, 22, 25 |
| UnionPay | 2, 3, 4, 11, 22, 25, 49 |

## Network Validation

The validator checks network-specific requirements:

```python theme={null}
from iso8583sim.core.validator import ISO8583Validator
from iso8583sim.core.types import CardNetwork

validator = ISO8583Validator()

message.network = CardNetwork.VISA
errors = validator.validate_message(message)

# Checks:
# - Required fields are present
# - Network-specific field formats
# - Network-specific business rules
```

## Common Field Differences

### Field 22 - POS Entry Mode

Three digits: the first two are the **PAN entry mode** (how the card number was captured), the third is the terminal's **PIN entry capability**. For example, `051` is a chip read at a terminal that accepts PINs, and `812` is e-commerce with no PIN entry.

| PAN entry mode | Meaning |
| - | - |
| 00 | Unknown |
| 01 | Manual entry |
| 02 | Magnetic stripe |
| 03 | Barcode |
| 04 | OCR |
| 05 | Chip (ICC) |
| 06 | Contactless, mapping service applied |
| 07 | Contactless chip |
| 09 | E-commerce with DSRP cryptogram |
| 10 | Credential on file |
| 51 | Chip plus PIN at ATM |
| 71 | Contactless chip plus PIN at ATM |
| 79 | Chip fallback, hybrid terminal failure |
| 80 | Chip fallback to magnetic stripe |
| 81 | E-commerce |
| 82 | Auto entry via server |
| 90 | Magnetic stripe, full track read |
| 91 | Contactless magnetic stripe |
| 95 | Chip with unreliable CVV (Visa only) |

| PIN capability | Meaning |
| - | - |
| 0 | Unknown |
| 1 | Terminal can accept PINs |
| 2 | Terminal cannot accept PINs |
| 3 | Software-based PIN entry (mPOS) |
| 8 | PIN pad not working |

For VISA and Mastercard messages the validator checks field 22 against these codes, and reports `95` on a Mastercard message as a Visa-only code. Other networks use their own field 22 schemes, so their values aren't checked.

Source: the DE022 code reference aligned to the Mastercard Customer Interface Specification and Visa VisaNet Authorization-Only Online Messages ([link](https://docs.tech.sofi.com/pro/reference/api-reference-de022-codes)).

### Field 39 - Response Codes

| Code | VISA | Mastercard |
| - | - | - |
| 00 | Approved | Approved |
| 05 | Do Not Honor | Do Not Honor |
| 51 | Insufficient Funds | Insufficient Funds |
| 14 | Invalid Card | Invalid Card Number |

### Field 55 - EMV Data

EMV (chip card) data format is consistent across networks, but specific tags may vary in interpretation.

## Next Steps

* [VISA Specifics](./visa)
* [Mastercard Specifics](./mastercard)
* [Other Networks](./others)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.