# Test your integration (/docs/testing)



> Use the sandbox to test requests, customer responses and callbacks without moving money or sending messages to real phones. It simulates the documented APIs; some operations return example data rather than processing a complete workflow.
## Sandbox keys [#keys]

Your sandbox API ID and key are in **Workbench → Test keys**. Send them with HTTP Basic authentication, exactly as you would your production credentials. In the sandbox, the same key also authenticates SMS requests.

To call the sandbox, put `https://developers.hubtel.com/sandbox/v1/` and the first part of the production host in front of the production path:

| Production                                        | Sandbox                                                                 |
| ------------------------------------------------- | ----------------------------------------------------------------------- |
| `https://rmp.hubtel.com/merchantaccount/…`        | `https://developers.hubtel.com/sandbox/v1/rmp/merchantaccount/…`        |
| `https://api-txnstatus.hubtel.com/transactions/…` | `https://developers.hubtel.com/sandbox/v1/api-txnstatus/transactions/…` |

```bash
curl https://developers.hubtel.com/sandbox/v1/rmp/merchantaccount/merchants/YOUR_COLLECTION_ACCOUNT/receive/mobilemoney \
  -u "YOUR_API_ID:YOUR_TEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"CustomerMsisdn":"233240000001","Channel":"mtn-gh","Amount":45.00,"Description":"Order #1042","ClientReference":"order-1042","PrimaryCallbackUrl":"https://example.com/hubtel/callback"}'
```

Your API ID, test key and collection account number are in **Workbench → API keys**.

## Test numbers [#test-numbers]

For supported simulations, use these numbers to select an outcome. Check the operation’s sandbox metadata in the [OpenAPI spec](/docs/tools/openapi) before relying on a simulated result:

| Customer number | What happens | Final state |
|---|---|---|
| `233240000001` | **Approved.** Customer approves the prompt. One callback arrives about 3 seconds later. | success |
| `233240000002` | **Insufficient funds.** The wallet balance is too low. The callback reports a failure. | failed |
| `233240000003` | **Declined.** Customer declines the prompt on their phone. | failed |
| `233240000004` | **No response.** The customer does not respond. The prompt expires after 5 minutes of sandbox time. | expired |
| `233240000005` | **Callback lost.** The payment succeeds but no callback is delivered. Reconcile with the Status Check API. | success |
| `233240000006` | **Duplicate callback.** Sandbox drill: the same successful callback is delivered twice. Production sends one final callback per payment, but your handler must still fulfil the order once. | success |
| `233240000007` | **Out of order.** Sandbox drill: a pending callback arrives after the success callback. Production only sends final results, but keep the order marked as paid either way. | success |
| `233240000008` | **Not a wallet.** The number is not registered for mobile money. Rejected immediately with a validation error. | failed |
| Any other number | **You decide.** Any other number shows the prompt on the Virtual Phone. Approve or decline it yourself. | You decide |

For any other valid number, approve or decline the prompt yourself on the Workbench **Virtual Phone**.

**Cards**

  | Card number | Result |
  |---|---|
  | `4000 0000 0000 0002` | Visa, approved. |
  | `4000 0000 0000 0010` | Visa, declined by issuer. |
  | `5200 0000 0000 0007` | Mastercard, asks for 3-D Secure (use code 123456). |

**Payouts**

  | Recipient | Type | What happens |
  |---|---|---|
  | `233240000101` | Wallet | **Paid out.** The payout succeeds and a callback confirms the result. |
  | `233240000102` | Wallet | **Wrong recipient.** Recipient wallet does not exist. |
  | `233240000103` | Wallet | **Insufficient disbursement balance.** The payout is accepted, then fails with a 4075 callback because your disbursement balance can't cover the amount and fees. |
  | `233240000105` | Wallet | **Callback lost.** The payout succeeds, but no callback is delivered. Check the payout status to reconcile it. |
  | `0000000001` | Bank account | **Bank credited.** Bank transfer succeeds after 10 seconds. |
  | `0000000002` | Bank account | **Name mismatch.** Account exists but the name does not match. |

**SMS**

  | Recipient | Delivery status |
  |---|---|
  | `233240000201` | delivered. Delivered to handset. |
  | `233240000202` | undelivered. The phone is switched off and the network could not deliver the message. |
  | `233240000203` | rejected. Network rejected the sender ID. |
  | `233240000204` | expired. Message expired before delivery. |
  | Any other number | delivered |

**Wallet verification**

  | Wallet | Result |
  |---|---|
  | `233240000301` | Name on wallet matches. Name: Kofi Mensah. |
  | `233240000302` | Wallet exists under a different name. Name: Ama Owusu. |
  | `233240000303` | Number is not a registered wallet. |

## Online Checkout in the sandbox [#online-checkout]

A sandbox `checkoutUrl` opens the portal’s simulated checkout page. Use it to test the payment flow; it is not the production payment service.

### Create a checkout [#create-a-checkout]

Send the request with your test key, or create the checkout from your own server:

```bash
curl https://developers.hubtel.com/sandbox/v1/payproxyapi/items/initiate \
  -u "YOUR_API_ID:YOUR_TEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"totalAmount":45.00,"description":"Order #1042","callbackUrl":"https://example.com/hubtel/callback","returnUrl":"https://example.com/orders/1042","cancellationUrl":"https://example.com/cart","merchantAccountNumber":"YOUR_COLLECTION_ACCOUNT","clientReference":"order-'"$(date +%s)"'"}'
```

Your API ID, test key and collection account number are in **Workbench → API keys**.

### Pay on the page [#pay-on-the-page]

Open the `checkoutUrl` from the response and pay:

* **Mobile Money:** use a [test number](#test-numbers). For any other number, approve or decline the prompt on the Workbench **Virtual Phone**.
* **Card:** use a test card from the **Cards** tab above. The 3-D Secure card opens a sandbox issuer page; enter `123456` to pass, or any other code to fail.

Wallet, GHQR, PaySmallSmall and Bank Pay appear on the page but aren't available in the sandbox.

### Handle the result [#handle-the-result]

Your `callbackUrl` receives the documented callback shape, with `PaymentDetails.PaymentType` set to `mobilemoney` or `card`. When the customer finishes, the page sends them to your `returnUrl` with `checkoutid` added to the query string. Confirm the payment from the callback or a status check before you fulfil the order, as in production.

To embed the page, load the `checkoutDirectUrl` in an iframe. The mobile and JavaScript [Checkout SDKs](/docs/guides/checkout-sdk) always run against production, so test them with production keys and small amounts.

## Simulate errors and time [#errors]

Add a `Hubtel-Simulate` header to a sandbox request to test how your client handles failures: `timeout`, `500`, `503`, `rate_limit` (the simulated per-number limit) or `slow:4000`.

The sandbox implements these behaviours:

* A reused `ClientReference` is rejected for an hour of sandbox time with `Duplicate Client Reference`.
* A customer number gets at most 4 payment requests a minute. Advance the clock to reset the limit.
* Callbacks are retried 30 seconds and then 60 seconds after a failed attempt, 3 attempts in all, each allowed 30 seconds.
* A payout your disbursement balance can't cover is accepted, then fails with a `4075` callback. Payout callbacks are sent once, without retries.
* A reused payout `ClientReference` is rejected for 48 hours, and an Online Checkout `clientReference` for 7 days, across every merchant. The example above adds the time to its reference so you can run it again.
* Where production's answer gives no reason, the sandbox explains in a `Hubtel-Sandbox-Note` response header.

The hosted sandbox only sends callbacks to public addresses. To receive them on your own machine, expose your local server with a tunnel and use its public URL as the callback URL:

```bash
cloudflared tunnel --url http://localhost:3000
# or
ngrok http 3000
```

To test the 5-minute reconciliation window without waiting, ask your AI agent to move the sandbox clock forward with the MCP `advance_sandbox_clock` tool (300 seconds).

## Integration checks [#integration-checks]

Run the checks from **Workbench → Webhooks → Integration checks**, or use `run_certification` through the [Hubtel MCP server](/docs/ai).

Use a public test deployment of your handler with test data and real-world delivery disabled. The checks send synthetic callbacks, including references that are not real orders. Keep your production sender checks in place; sandbox requests come from the sandbox, not the production callback addresses.

The checks cover:

* Acknowledgement of a success callback, a duplicate and a late pending notification.
* Sandbox activity showing a failed payment and a status lookup for a payment with a lost callback (`233240000005`). These observations do not prove that your application updated its own records correctly.
* An optional lookup of your fulfilment record after the repeated callbacks.

To enable the fulfilment lookup, add this route on the same host as your test callback URL. Return the actual stored result for the requested reference, not a hardcoded response:

```text
GET /hubtel/certification/orders/:reference
```

```json
{ "fulfilments": 1, "status": "paid" }
```

Without this route, the exactly-once check reports **not checked**. A passing report is sandbox evidence, not production approval. Also verify your own order records for success, failure, duplicate delivery and a lost callback.

Normal sandbox deliveries include a `Hubtel-Signature` header; integration-check callbacks do not.
