Skip to main content

Overview

The Test Users API allows you to create test user accounts for Mercado Pago’s sandbox environment. Test users are essential for testing payment flows without processing real transactions or using real money.
This endpoint is only available in local and testing environments when MERCADOPAGO_ENABLE_DEMO_ROUTES=true. It is automatically disabled in production.
Test users created through this endpoint can be used to obtain test credentials and simulate complete payment flows in Mercado Pago’s sandbox environment.

Create Test User

Creates a new test user for a specific Mercado Pago site/country.

Endpoint

POST /api/mercadopago/test-users

Request Parameters

site_id
string
required
Mercado Pago site/country identifier. Must be one of:
  • MLA - Argentina
  • MLB - Brazil
  • MLC - Chile
  • MLM - Mexico
  • MLU - Uruguay
  • MCO - Colombia
  • MPE - Peru
description
string
Optional description to identify the test user (e.g., “QA Testing User”, “Buyer Account”)

Request Example

{
  "site_id": "MLA",
  "description": "Usuario de prueba para QA"
}

Response

ok
boolean
Indicates if the request was successful
data
object
The test user object returned by Mercado Pago
meta
array
Additional metadata (typically empty)

Response Example

{
  "ok": true,
  "data": {
    "id": 123456789,
    "nickname": "TESTUSER123456",
    "password": "qatest123",
    "site_status": "active",
    "site_id": "MLA",
    "email": "[email protected]",
    "date_created": "2024-03-10T10:30:00.000-04:00",
    "description": "Usuario de prueba para QA"
  },
  "meta": []
}

cURL Example

curl --request POST \
  --url http://localhost:8000/api/mercadopago/test-users \
  --header 'Content-Type: application/json' \
  --data '{
    "site_id": "MLA",
    "description": "Usuario de prueba para QA"
  }'

Error Response

{
  "ok": false,
  "message": "The site_id field must be one of: MLA, MLB, MLC, MLM, MLU, MCO, MPE."
}

Supported Countries

Test users can be created for the following Mercado Pago markets:
Site IDCountryCurrency
MLAArgentinaARS (Argentine Peso)
MLBBrazilBRL (Brazilian Real)
MLCChileCLP (Chilean Peso)
MLMMexicoMXN (Mexican Peso)
MLUUruguayUYU (Uruguayan Peso)
MCOColombiaCOP (Colombian Peso)
MPEPeruPEN (Peruvian Sol)

Use Cases

Creating Test Users for Different Scenarios

Create multiple test users for comprehensive testing:
# Create seller/merchant test user
curl -X POST http://localhost:8000/api/mercadopago/test-users \
  -H 'Content-Type: application/json' \
  -d '{"site_id": "MLA", "description": "Seller Account"}'

# Create buyer test user
curl -X POST http://localhost:8000/api/mercadopago/test-users \
  -H 'Content-Type: application/json' \
  -d '{"site_id": "MLA", "description": "Buyer Account"}'

Obtaining Test Credentials

After creating a test user:
  1. Use the returned email and password to log into the Mercado Pago Developers dashboard
  2. Navigate to Your integrationsCredentials
  3. Copy the test access_token and public_key
  4. Use these credentials in your local/testing environment

Automated QA Setup

use Fitodac\LaravelMercadoPago\Services\TestUserService;

// In your test setup
class MercadoPagoTestCase extends TestCase
{
    protected string $testUserId;
    
    protected function setUp(): void
    {
        parent::setUp();
        
        $testUserService = app(TestUserService::class);
        $testUser = $testUserService->create([
            'site_id' => 'MLA',
            'description' => 'Automated test user'
        ]);
        
        $this->testUserId = $testUser['id'];
        
        // Use test user credentials for testing
    }
}

Implementation Notes

Availability

This endpoint is protected by the mercadopago.demo middleware and only responds when:
  • MERCADOPAGO_ENABLE_DEMO_ROUTES=true in configuration
  • Application environment is local or testing
In production or when demo routes are disabled, this endpoint returns 404.

Validation Rules

The endpoint validates:
  • site_id is required and must be one of: MLA, MLB, MLC, MLM, MLU, MCO, MPE
  • description is optional and must be a string

Controller Reference

Implemented in: src/Http/Controllers/Api/TestUserController.php:13 Request validation: src/Http/Requests/CreateTestUserRequest.php:17

Best Practices

Multiple Users: Create separate test users for different roles (buyer, seller) to test complete payment flows.
Sandbox Only: Test users are only for sandbox/testing. Never use test credentials in production environments.
Credential Management: Save the returned test user credentials securely. You’ll need them to obtain test access tokens from Mercado Pago’s dashboard.

Testing Workflow

  1. Create test users for your target country
  2. Log in to Mercado Pago with test user credentials
  3. Obtain test credentials (access token, public key)
  4. Configure your application with test credentials
  5. Run test transactions using test cards
  6. Verify webhooks and payment flows

Example Production Controller

use Fitodac\LaravelMercadoPago\Services\TestUserService;

final class TestUserManagementController
{
    public function store(
        Request $request,
        TestUserService $testUserService
    ): JsonResponse {
        // Restrict to authorized users only
        if (!$request->user()->isAdmin()) {
            abort(403, 'Unauthorized');
        }
        
        $payload = $request->validate([
            'site_id' => ['required', 'string', Rule::in([
                'MLA', 'MLB', 'MLC', 'MLM', 'MLU', 'MCO', 'MPE'
            ])],
            'description' => ['sometimes', 'string'],
        ]);

        $testUser = $testUserService->create($payload);
        
        // Log test user creation for audit
        activity()
            ->by($request->user())
            ->log("Created test user: {$testUser['email']}");

        return response()->json($testUser, 201);
    }
}

Testing Different Scenarios

Success Payment Flow

  1. Create a test user
  2. Use test cards that simulate successful payments
  3. Verify payment status is approved

Rejected Payment Flow

  1. Create a test user
  2. Use test cards that simulate rejections
  3. Verify appropriate error handling

Pending Payment Flow

  1. Create a test user
  2. Use payment methods that require manual approval
  3. Test webhook notifications for status changes

Test Cards by Country

After creating a test user, use these test cards for simulating different payment scenarios. Refer to Mercado Pago’s official documentation for complete test card lists.

Common Test Cards

Card NetworkNumberCVVExpiry
Visa4509 9535 6623 370412311/25
Mastercard5031 7557 3453 060412311/25
Amex3711 803032 57522123411/25

Troubleshooting

Invalid site_id Error

Error: The site_id field must be one of: MLA, MLB, MLC, MLM, MLU, MCO, MPE. Solution: Ensure you’re using a valid site ID. Check the Supported Countries section.

Endpoint Returns 404

Cause: Demo routes are disabled or environment is production. Solution:
  • Set MERCADOPAGO_ENABLE_DEMO_ROUTES=true
  • Ensure APP_ENV is local or testing
  • Run php artisan config:clear

Cannot Access Test Credentials

Issue: Can’t find test credentials in Mercado Pago dashboard. Solution:
  1. Log in to Mercado Pago with the test user email and password
  2. Navigate to DevelopersYour integrations
  3. Select your application
  4. Go to Production and test credentials
  5. Copy the Test credentials

Build docs developers (and LLMs) love