> For the complete documentation index, see [llms.txt](https://docs.payr.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payr.com/environments.md).

# Environments

Payr provides separate sandbox and production environments for testing and live payments.

***

### API and Iframe URLs

<table><thead><tr><th>Environment</th><th width="329.44140625">API Base URL</th><th width="271.29296875">Iframe URL</th></tr></thead><tbody><tr><td><strong>Sandbox</strong></td><td><code>https://sandbox-api.mypayr.co.uk/thirdparty</code></td><td><code>https://sandbox.mypayr.co.uk</code></td></tr><tr><td><strong>Production</strong></td><td><code>https://api.mypayr.co.uk/thirdparty</code></td><td><code>https://mypayr.co.uk</code></td></tr></tbody></table>

> **Recommendation:** Always test thoroughly in sandbox before moving to production.

***

### SDK Configuration

To switch between sandbox and production environments in the SDK, you need to update two configuration parameters:

1. **`apiBaseUrl`** - The Payr API endpoint
2. **`environment`** - The environment mode

#### Environment Configuration Table

| Environment           | `apiBaseUrl`                       | `environment`  |
| --------------------- | ---------------------------------- | -------------- |
| **Sandbox (Testing)** | `https://sandbox-api.mypayr.co.uk` | `'sandbox'`    |
| **Production (Live)** | `https://api.mypayr.co.uk`         | `'production'` |

**SDK Script URL (same for both):**

```
https://cdn.mypayr.co.uk/payr-sdk.js
```

***

#### Sandbox Example

```javascript
PAYR.init({
  apiBaseUrl: 'https://sandbox-api.mypayr.co.uk',  // Sandbox API
  environment: 'sandbox',                          // Sandbox environment
  authToken: tokenFromYourBackend,
  container: '#payr-payment-form'
});
```

***

#### Production Example

```javascript
PAYR.init({
  apiBaseUrl: 'https://api.mypayr.co.uk',  // Production API
  environment: 'production',               // Production environment
  authToken: tokenFromYourBackend,
  container: '#payr-payment-form'
});
```

***

### Important Notes

**Match your environment:**

* Always use sandbox `apiBaseUrl` with `environment: 'sandbox'`
* Always use production `apiBaseUrl` with `environment: 'production'`
* Use tokens issued from the same environment (sandbox tokens for sandbox API, production tokens for production API)

**Security:**

* Never hardcode production tokens in your frontend code
* Issue tokens from your backend after user authentication

**Before going live:**

* Test thoroughly in sandbox first
* Remove any `debug: true` flags from production code
* Verify your `apiBaseUrl` and `environment` are set to production values

***

### Support

Need help with environment configuration? Contact **<support@mypayr.co.uk>**
