Guides
Getting started

Quickstart

Activate the sandbox, get the credentials, create a deposit intent, pay as the customer and receive the Success webhook.

This guide takes a few minutes: you activate the simulator, get a token, create a deposit intent with a dynamic QR Code, pay as the test payer and wait for the webhook.

Prerequisites

  • A Mimicr organization and a write API key (mk_…), created in the organization settings, "Chaves de API" tab.
  • curl, or any HTTP client, and Node 18+ if you want the CLI.
  • A public URL to receive webhooks (optional; without one, Mimicr records the notification as not sent and you can still look it up).

1. Activate the Pay4Fun sandbox

In the console, open the organization at https://app.mimicr.dev, go to Pay4Fun and activate it. Or through the control API:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/pay4fun/activate \
  --header 'Authorization: Bearer mk_...'

Each organization has one Pay4Fun sandbox, which stands for a merchant with its own credentials and two accounts. If it is already active, the call answers 409 pay4fun_already_active.

2. Get the credentials

bash
curl --url https://api.mimicr.dev/v1/pay4fun \
  --header 'Authorization: Bearer mk_...'
json
{
  "active": true,
  "host": "https://pay4fun.mimicr.dev",
  "credentials": { "client_id": "<client_id>", "client_secret": "<client_secret>" },
  "merchant": { "name": "Sua Org LTDA", "document": "37065435000124", "pix_key": "404dc4c2-806e-4f61-ba02-ccfd317f2a0e" },
  "balances": {
    "transactional": { "balance": 1000000, "blocked": 0, "available": 1000000 },
    "owner": { "balance": 50000, "blocked": 0, "available": 50000 }
  },
  "homolog": { "autoProcessPayments": true }
}

Control API balances are in cents: the transactional account starts with R$ 10,000.00. With the CLI: npx mimicr login mk_... once, then npx mimicr status pay4fun.

3. Get a token

bash
curl --request POST \
  --url https://pay4fun.mimicr.dev/auth \
  --header 'Content-Type: application/json' \
  --data '{
    "clientId": "<client_id>",
    "clientSecret": "<client_secret>"
  }'
json
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIi...",
  "expires_in": 300,
  "refresh_expires_in": 0,
  "refresh_token": null,
  "token_type": "Bearer",
  "not-before-policy": 0,
  "session_state": null,
  "scope": "payment-gateway"
}

The token lasts 5 minutes. Send access_token in the Authorization: Bearer <token> header of every following call. See Authentication.

4. Create a deposit intent

bash
curl --request POST \
  --url https://pay4fun.mimicr.dev/deposit/api/v1/intents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "externalId": "deposito-456",
    "webhookUrl": "https://seu-servidor.example.com/webhooks/deposit",
    "deposits": [
      { "method": "Pix-QrDynamic", "amount": 200.00, "data": { "expiration": 600 } }
    ]
  }'
json
{
  "externalId": "deposito-456",
  "id": "596a71a0-72de-4f09-8b5f-05b0e9230adc",
  "intentId": "596a71a0-72de-4f09-8b5f-05b0e9230adc",
  "url": "https://pay4fun.mimicr.dev/checkout/596a71a0-72de-4f09-8b5f-05b0e9230adc",
  "status": "Pending",
  "deposits": [
    {
      "id": "c87b5495-ae90-4a24-8ae4-fe9fa326e459",
      "method": "Pix-QrDynamic",
      "reference": "00020101021226830014br.gov.bcb.pix2561pay4fun.mimicr.dev/qr/v2/c87b5495...6304D58F",
      "amount": 200,
      "status": "Pending"
    }
  ],
  "tags": []
}

The response is 201 with the header Location: /deposit/api/v1/intents/{id}. reference is the copy-and-paste code you show the customer.

5. Pay as the customer

Open the url in a browser: it is Mimicr's hosted checkout. Pick a test payer (Ana pays normally) and click pay. Or do the same through the control API:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/pay4fun/actions/deposit.pay \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "intentId": "deposito-456", "payer": "ana" }'
json
{
  "ok": true,
  "action": "deposit.pay",
  "message": "Intent 596a71a0-72de-4f09-8b5f-05b0e9230adc: Released. Webhook de depósito enviado.",
  "data": { "id": "596a71a0-72de-4f09-8b5f-05b0e9230adc", "externalId": "deposito-456", "status": "Released" }
}

Or: npx mimicr action pay4fun deposit.pay intentId=deposito-456 payer=ana.

6. Wait for the webhook

bash
npx mimicr wait pay4fun delivery kind=deposit event=Success ref=596a71a0-72de-4f09-8b5f-05b0e9230adc

The command returns as soon as the notification exists. Your webhookUrl receives:

json
{
  "id": "596a71a0-72de-4f09-8b5f-05b0e9230adc",
  "externalId": "deposito-456",
  "status": "Success",
  "deposit": {
    "id": "c87b5495-ae90-4a24-8ae4-fe9fa326e459",
    "method": "Pix-QrDynamic",
    "status": "Success",
    "endToEndId": "E60746948202610230117mDeBJvX51cI",
    "amountOriginal": "200.00",
    "amountConverted": "200.00",
    "currencyOriginal": "BRL",
    "currencyConverted": "BRL",
    "payer": { "document": "12345678909", "name": "Ana Souza", "birthdate": "1900-01-01", "branch": "0001", "account": "123456", "accountType": "CC", "pspId": "60746948", "pspName": "Banco Bradesco S.A." }
  },
  "createdAt": "2026-10-23T01:17:19Z",
  "processedAt": "2026-10-23T01:17:19Z"
}

The webhook is not signed: treat it as a signal and confirm with Get a deposit intent, which now shows APPROVED and the providerEndToEnd. The amount landed in the transactional account:

bash
curl --url https://pay4fun.mimicr.dev/account/api/v1/transactional/balance \
  --header 'Authorization: Bearer <token>'

Next steps