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

# PSP Routing

Intelligent payment routing with automatic failover to maximize approval rates.

## How Routing Works

Atlas intelligently routes payments to the best PSP based on your configuration. When a payment fails, Atlas automatically retries with alternative PSPs.

### Features

| Feature             | Description                                                     |
| ------------------- | --------------------------------------------------------------- |
| **Smart Selection** | Routes based on card type, currency, and historical performance |
| **Auto Failover**   | Automatically retries soft declines with backup PSPs            |
| **Cascade Rules**   | Configure retry behavior based on failure codes                 |

## Routing Profiles

Create routing profiles to customize PSP selection for different scenarios:

```bash theme={null}
# Use a specific routing profile
curl -X POST https://api.atlas.co/functions/v1/confirm-payment/sess_xxx \
  -H "Authorization: Bearer cs_client_secret_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_method_type": "card",
    "token_id": "tok_abc123",
    "routing_profile_id": "rp_high_value"
  }'
```

### Force Specific PSP

Bypass routing and use a specific PSP:

```bash theme={null}
curl -X POST https://api.atlas.co/functions/v1/confirm-payment/sess_xxx \
  -H "Authorization: Bearer cs_client_secret_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_method_type": "card",
    "token_id": "tok_abc123",
    "psp": "stripe"
  }'
```

## Failover Behavior

When a payment is declined, Atlas analyzes the failure code to determine if a retry is appropriate.

### Retryable (Soft Decline)

These failures trigger automatic retry with backup PSPs:

* Insufficient funds (temporary)
* PSP timeout or network error
* Issuer unavailable
* Generic decline (no specific reason)

### Non-Retryable (Hard Decline)

These failures do NOT trigger retry:

* Invalid card number
* Expired card
* Lost or stolen card
* Fraud block by issuer

> **Note:** Atlas attempts up to 3 PSPs per transaction by default. The final result reflects the last attempt's status.

## Supported PSPs

Atlas integrates with leading payment processors:

| PSP           | Card | Apple Pay | Google Pay | ACH |
| ------------- | ---- | --------- | ---------- | --- |
| Stripe        | ✓    | ✓         | ✓          | ✓   |
| Adyen         | ✓    | ✓         | ✓          | -   |
| Checkout.com  | ✓    | ✓         | ✓          | -   |
| Braintree     | ✓    | ✓         | ✓          | -   |
| Authorize.net | ✓    | -         | -          | ✓   |
| Chase         | ✓    | ✓         | ✓          | -   |
| Nuvei         | ✓    | ✓         | ✓          | -   |
| dLocal        | ✓    | -         | -          | -   |
| Airwallex     | ✓    | ✓         | ✓          | -   |
| Windcave      | ✓    | ✓         | ✓          | -   |
| PayPal        | -    | -         | -          | ✓   |

Contact support to enable additional PSPs for your account.

## Routing Rules

Configure rules in the dashboard based on:

* **Card brand** - Visa, Mastercard, Amex, etc.
* **Card type** - Credit, debit, prepaid
* **BIN range** - Specific issuing banks
* **Currency** - Route EUR to European PSPs
* **Amount** - High-value transactions to specific PSPs
* **Geography** - Customer or merchant country
* **Time** - Peak hours routing

## Cascade Configuration

Define retry behavior:

```json theme={null}
{
  "name": "Default Cascade",
  "rules": [
    {
      "primary_psp": "stripe",
      "fallback_psps": ["adyen", "checkout"],
      "retry_on": ["insufficient_funds", "timeout", "generic_decline"],
      "max_attempts": 3
    }
  ]
}
```

## Monitoring

Track routing performance in the dashboard:

* Approval rates by PSP
* Failover success rates
* Latency by PSP
* Cost analysis

## Webhooks

Payment events include routing information:

```json theme={null}
{
  "type": "payment.captured",
  "data": {
    "id": "pay_abc123",
    "psp": "adyen",
    "psp_transaction_id": "8835...",
    "routing": {
      "profile_id": "rp_default",
      "attempts": [
        { "psp": "stripe", "status": "declined", "code": "insufficient_funds" },
        { "psp": "adyen", "status": "captured" }
      ]
    }
  }
}
```
