Skip to main content

Payment Simulation

The simulation endpoint allows you to test payment flows in the staging environment without making actual payments. This is useful for testing your integration and webhook handlers.
The simulation endpoint is only available in the staging environment: https://staging.api.mavapay.co/api/v1

Endpoint

How It Works

  1. Create a quote using the Create Quote endpoint
  2. Use the quoteId (or orderId if you don’t have the quote) from the response
  3. Call the simulation endpoint to simulate payment
  4. Your webhook will receive payment.received event
  5. If autopayout is enabled, you’ll also receive payment.sent event

Nigerian Naira (NGN) Simulation

Request

Response

Parameters

*Either quoteId or orderId is required.

Bitcoin (BTC) Simulation

Request

Response

Parameters

*Either quoteId or orderId is required.
For BTC simulations, the amount parameter is not required as it’s determined by the Lightning invoice.
For Payment Links (including on-chain Bitcoin purchases), you need to first retrieve the order ID.

Step 1: Get the Order ID

Retrieve the order ID associated with your payment link:

Step 2: Simulate Payment

Use the order ID to simulate the bank transfer:
For Payment Link simulations, use orderId instead of quoteId. The amount should match the payment link amount in kobo.

Complete Testing Flow

Step 1: Create a Quote

Step 2: Simulate Payment

Step 3: Receive Webhook

Your registered webhook endpoint will receive a payment.received event:
If autopayout is enabled, you’ll also receive a payment.sent event shortly after.

Testing Different Scenarios

Test Successful Payment

Use the simulation endpoint as shown above to test successful payment flows.

Using Order ID Instead of Quote ID

If you don’t have access to the quote ID, you can use the order ID instead:

Test Different Currency Pairs

Create quotes for different currency pairs and simulate payments:

Test Webhook Handling

  1. Set up a webhook endpoint using webhook.site or ngrok
  2. Register your webhook in staging
  3. Create a quote and simulate payment
  4. Verify your webhook receives and processes the events correctly

Common Errors

Best Practices

  1. Fresh Quotes: Create new quotes for each test to avoid “already paid” errors
  2. Webhook Testing: Test both payment.received and payment.sent events
  3. Error Handling: Test how your system handles different payment statuses
  4. Idempotency: Verify your webhook handler processes duplicate events correctly
  5. Timing: Test scenarios where webhooks arrive out of order

Integration Checklist

  • Create quotes successfully
  • Simulate NGN payments
  • Simulate BTC payments
  • Receive payment.received webhooks
  • Receive payment.sent webhooks
  • Handle webhook signature verification
  • Implement idempotent webhook processing
  • Test error scenarios
  • Verify beneficiary payouts work correctly

Next Steps

Always thoroughly test your integration in staging before moving to production!