Skip to content

Sandbox Testing

PayDunya provides a complete sandbox environment where you can test every payment flow without real money, cards, or mobile money accounts.

Fictitious Customers

The sandbox uses fictitious customer accounts (comptes fictifs) to simulate payments. Each fictitious customer has a name, email, phone number, and a virtual balance. When a payment is made in the sandbox, PayDunya debits the fictitious balance — no real funds move.

Creating a fictitious customer

  1. Log in to your PayDunya account
  2. Go to Integration API in the left menu
  3. Click the Fictitious customers tab
  4. Fill in the name, email address, and initial balance
  5. Click Create

You can create multiple fictitious customers and reload their balance manually at any time from the same tab.

Making a Test Payment

  1. Create a checkout invoice with your test API keys and mode="test":

    ```python from paydunya import Invoice, InvoiceItem, PaydunyaClient, Store

    client = PaydunyaClient( master_key="your-master-key", private_key="test_private_...", token="your-token", mode="test", )

    store = Store(name="Test Shop") invoice = Invoice(client, store) invoice.set_total_amount(5000) invoice.set_description("Sandbox test")

    response = invoice.create() print(response["response_text"]) # sandbox payment page URL ```

  2. Open the URL in your browser. You'll see the sandbox payment page.

  3. Choose any payment method (card, Orange Money, Wave, etc.) — they all work in the sandbox without real accounts.

  4. Enter your fictitious customer's email or phone number when prompted.

  5. Complete the payment. Your fictitious balance is debited.

Debugging Your Requests

PayDunya provides a debugging tool called Fictitious Internal Data:

  1. Go to Integration APIFictitious internal data
  2. You'll see a list of all test transactions transmitted to the server
  3. Click details next to any entry to see the exact JSON payload your code sent, plus the full server response

This is extremely useful when debugging payload shapes or checking whether optional fields (customer, channels, custom_data) are correctly transmitted.

Automated End-to-End Script

The SDK includes an interactive sandbox E2E script at examples/sandbox_e2e.py.

Running it

export PAYDUNYA_MASTER_KEY="your-test-master-key"
export PAYDUNYA_PRIVATE_KEY="test_private_..."
export PAYDUNYA_TOKEN="your-test-token"

python examples/sandbox_e2e.py

The script: 1. Creates a checkout invoice in test mode 2. Prints the sandbox payment URL and instructions 3. Polls every 5 seconds (up to 3 minutes) until the payment is completed 4. Displays the confirmation result (status, customer info, receipt URL)

CI / Automated Testing

For continuous integration and automated tests, use pytest-httpx to mock all HTTP calls — no network access, no API keys required. The SDK's own test suite (43+ tests) runs entirely offline this way. See the tests/ directory for examples of mock-based test patterns.

Transitioning to Production

When you're ready: 1. Update your application to Enable production mode in the dashboard 2. Replace test API keys with your production keys 3. Set mode="live" in PaydunyaClient 4. Perform one or two small real transactions to verify everything works 5. Remove any hardcoded keys from your source code — use environment variables