Testing Settlement Requests

Test settlement quotes, same-currency and cross-currency settlement requests, pagination, idempotency, and cancellation in sandbox.

Use sandbox credentials and https://api-v2.honeycoin.app/api/sandbox/b2b/settlement-requests as {settlementRequestsBaseUrl}. Generate a sandbox bearer token at POST https://api-v2.honeycoin.app/api/sandbox/b2b/auth/generate-bearer-token.

Sandbox uses the exact same request and response contracts as production, completely isolated in the sandbox database, with two intentional differences for fast testing:

  1. No production feature-flag gate: Sandbox settlement request endpoints are open to all sandbox accounts without requiring production account activation.
  2. No balance checks: Sandbox accounts do not carry live treasury balances, so POST / does not enforce INSUFFICIENT_BALANCE in sandbox. All schema checks, currency/country resolution, destination validation, quote matching, quote expiry, single-use quote consumption, externalReference uniqueness, and X-Idempotency-Key rules are enforced identically to production.

End-to-End Checklist

All paths below are relative to {settlementRequestsBaseUrl}.

  1. Test same-currency bank/momo/SWIFT submission: Call POST / with senderCurrency === receiverCurrency, a valid matching destination, a unique externalReference, and no quoteId. Confirm 201 Created, exchangeRate: 1, quoteId: null, and expiresAt: null.
  2. Test cross-currency quote generation: Call POST /quotes with differing senderCurrency and receiverCurrency (for example, KES → USDC). Save data.id as quoteId and check data.expiresAt.
  3. Inspect the quote: Call GET /quotes/{quoteId} and confirm status: "active".
  4. Consume the quote on request creation: Call POST / with the matching senderAmount, currencies, settlementMethod: "crypto", destination.type: "crypto", quoteId, externalReference, and X-Idempotency-Key. Confirm 201 Created and a non-null expiresAt timestamp.
  5. Confirm single-use quote consumption: Call GET /quotes/{quoteId} and confirm status: "consumed" and settlementRequestId matches the request created in step 4.
  6. List & paginate requests: Call GET /?status=pending&limit=10 and verify filtering and pagination.nextCursor.
  7. Cancel a pending request: Call POST /{id}/cancel with { "reason": "Sandbox test cancel" } and X-Idempotency-Key, then confirm status: "cancelled" and cancelledAt.

Example: Cross-Currency Sandbox Flow

1. Generate a Sandbox Quote

curl --request POST \
  --url https://api-v2.honeycoin.app/api/sandbox/b2b/settlement-requests/quotes \
  --header 'Authorization: Bearer YOUR_SANDBOX_BEARER_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "senderAmount": 130000,
    "senderCurrency": "KES",
    "receiverCurrency": "USDC"
  }'

2. Submit the Sandbox Settlement Request

curl --request POST \
  --url https://api-v2.honeycoin.app/api/sandbox/b2b/settlement-requests \
  --header 'Authorization: Bearer YOUR_SANDBOX_BEARER_TOKEN' \
  --header 'Content-Type: application/json' \
  --header 'X-Idempotency-Key: sbx-sr-create-0194f1c2-7b3a' \
  --data '{
    "senderAmount": 130000,
    "senderCurrency": "KES",
    "receiverCurrency": "USDC",
    "settlementMethod": "crypto",
    "quoteId": "QUOTE_ID_FROM_STEP_1",
    "externalReference": "sbx-settle-001",
    "destination": {
      "type": "crypto",
      "walletAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "chain": "BASE"
    }
  }'

Scenarios to Verify

ScenarioSetupExpected Behavior
Same-currency settlementPOST / with KES → KES, settlementMethod: "bank", no quoteIdReturns 201 Created with exchangeRate: 1, quoteId: null, expiresAt: null
quoteId on same-currency requestPOST / with KES → KES and any quoteIdReturns 400 VALIDATION_ERROR
Missing quoteId on cross-currencyPOST / with KES → USDC and no quoteIdReturns 400 VALIDATION_ERROR
Quote parameter mismatchPOST / with a senderAmount or currency different from the quoteReturns 400 VALIDATION_ERROR
Reusing a consumed quoteSubmit a second POST / with the same quoteId and a new externalReferenceReturns 409 Conflict
Duplicate externalReferenceSubmit a second POST / with the same externalReference and a new X-Idempotency-KeyReturns 409 Conflict
Safe retry with X-Idempotency-KeyRe-send the identical POST / with the same X-Idempotency-KeyReplays the original 201 Created response without creating a duplicate
Cancel and re-cancelCall POST /{id}/cancel twice with different X-Idempotency-Key headersFirst returns 200 OK (status: "cancelled"); second returns 409 Conflict
Strict validationPass an unknown top-level field, unknown destination key, or query param on POST /Returns 400 VALIDATION_ERROR

Related Guides