# Environments

With our Direct Debit product, you have access to two environments for testing and real-world payments:

## Sandbox

Start in Sandbox and Use our Postman Collection
We really recommend that while you're integrating with Belvo, you start with the Sandbox environment and then proceed to Production.

We have a dedicated Mexico Direct Debit Postman Collection that you can use to explore and test our Direct Debit API endpoints quickly and easily. Make sure to follow the instructions (especially regarding forking the Environment variables and authentication) in the collection description to get started.

Sanbox URL:

```shell Sandbox URL (Direct Debit)
https://api.sandbox.directdebit.belvo.com
```

Available for:

- 🟢 Payments (Direct Debit Mexico)


Use our Sandbox environment to build your integration. In this environment, you can:

- Use our no-code Bulk Imports tool to mock batch payments.
- Use our API to create Customers, Payment Methods, Generate Agreements, and Payment Requests.
- Use our Reporting tools to see how the reconciliation process works.


All you need to get started with the Sandbox environment is to sign up in the Sandbox portal and verify your email address. After that, depending on your needs you can:

1. Follow our dedicated Bulk Import Direct Debit Payments (No Code) guide to get started with mock payments.
2. Generate some sandbox API keys and Set Up a Direct Debit (API).


### Sandbox status updates

To mimic real-world situations, we've provided the following flows for payment methods and requests:

**Payment Methods**

When creating a payment method, set the `bank` to `mx_santander`.

**Payment requests**

When making payment requests, depending on the flow you want to test, you will need to provide different keywords as the value for the `reference` field.

| Flow  | Reference  | Result |
|  --- | --- | --- |
| Success | `successful`, random string, or blank | The payment request follows these statuses: `initial` -> `processing` -> `successful`. |
| Failed | `failed` | The payment request follows these statuses: `initial` -> `processing` -> `failed`. |
| Chargeback | `chargeback` | The payment request follows these statuses: `initial` -> `processing` -> `successful`->`chargeback`. |


**Penny validation**

Merchants can simulate Penny validation outcomes for payment methods by setting specific values for the `reference` field:

| Reference  | Result |
|  --- | --- |
| `failed` | The Penny validation fails and the payment method status transitions: `pending_validation` -> `failed`. |
| Any other value (including `null`, empty, or custom values) | The Penny validation succeeds and the payment method status transitions: `pending_validation` -> `active`. |


**Consent KYC outcome**

Merchants can simulate different consent KYC outcomes by using specific file name prefixes when uploading consent documents:

| File name prefix  | Resulting consent status  | Example file name |
|  --- | --- | --- |
| `reject_` | `rejected` | `reject_id_front.png` |
| `incomplete_` | `incomplete_information` | `incomplete_selfie.jpg` |
| No prefix | `confirmed` | `id_front.png` |


## Production

Production URL:

```shell Production URL (Direct Debit)
https://api.directdebit.belvo.com
```

Available for:

- 🟢 Payments (Direct Debit Mexico)


Our Production environment will give you access to real payments to and from accounts using the Direct Debit platform.

After you have tested your integration in the Sandbox environment and are ready to go live, you'll need to reach out to our support team to access to our Production environment. Our support team will get in contact with you to schedule a meeting just to make sure your needs are satisfied, and then you'll just need to go through a certification process with one of our engineers to make sure that your integration is running optimally.

Once your integration is certified, all you'll need to do is sign up in the Production portal and verify your email. After this, if you're using our API you'll need to:

1. Generate some production API keys.
2. Change your Sandbox API keys in your code to the Production API keys.
3. Change the base URL that you make requests to from `api.sandbox.directdebit.belvo.com` to `api.directdebit.belvo.com`.
4. Set up your production webhook URL.


# API keys and Authentication

## Generate API Keys

To get your API keys:

1. Log in to your Direct Debit Portal. (Sandbox Login | Production Login)
2. Go to Developers -> API Keys. (Sandbox API Keys | Production API Keys)
3. Click **Generate API Keys**.
4. Save your **Secret Key** and **Secret Password** (they will only be displayed once).
5. After saving and downloading your secret key and password, click **Done**.


✅ You're API keys are successfully generated.

Try Our Postman Collection
We have a dedicated Mexico Direct Debit Postman Collection that you can use to explore and test our Direct Debit API endpoints quickly and easily. Make sure to follow the instructions (especially regarding forking the Environment variables and authentication) in the collection description to get started.

## Authentication

After generating your Secret Key ID and Secret Password, provide them in the corresponding headers whenever making a request to a protected endpoint.

```shell
curl --request <the_method> \
  --url https://api.sandbox.directdebit.belvo.com/<the_endpoint> \
  --header 'api-key-id: <Your-Secret-Key-Id>' \
  --header 'api-key-secret: <Your-Secret-Password>'
```