# Mock responses

KwikPaisa Sandbox environment provides mock responses to help merchants simulate different transaction scenarios during integration and testing.

Mock responses allow developers to:

* Test successful transactions
* Simulate failed payments
* Validate payout failures
* Test webhook handling
* Verify retry mechanisms
* Build reconciliation workflows safely

Mock responses are available only in the Sandbox environment.

***

## Why Mock Responses are Important

During development, merchants need to test:

* Success scenarios
* Failure handling
* Timeout workflows
* Retry mechanisms
* Webhook processing
* Edge cases

Mock responses help simulate these situations without real money movement.

***

## Supported Mock Scenarios

### Payment Gateway

| Scenario           | Description                       |
| ------------------ | --------------------------------- |
| Payment Success    | Simulates successful payment      |
| Payment Failed     | Simulates failed transaction      |
| Payment Processing | Simulates delayed payment         |
| Payment Expired    | Simulates expired payment session |

***

### Payout APIs

| Scenario             | Description                    |
| -------------------- | ------------------------------ |
| Payout Success       | Simulates successful payout    |
| Payout Failed        | Simulates payout failure       |
| Insufficient Balance | Simulates wallet balance error |
| Processing Payout    | Simulates delayed settlement   |

***

## Example Payment Gateway Response

{% tabs %}
{% tab title="Success" %}

```json
{
  "code": "200",
  "status": "success",
  "message": "Payment completed successfully.",
  "return_data": {
    "kwikX_order_id": "kp_40dec464",
    "order_id": "6116229263036",
    "order_status": "PAID",
    "transaction_id": "TXN938482920",
    "amount": "105.00",
    "currency": "INR"
  }
}
```

{% endtab %}

{% tab title="Failed" %}

```json
{
  "code": "200",
  "status": "failed",
  "message": "Payment failed.",
  "return_data": {
    "kwikX_order_id": "kp_40dec464",
    "order_id": "6116229263036",
    "order_status": "FAILED",
    "transaction_id": null,
    "amount": "105.00",
    "currency": "INR"
  }
}
```

{% endtab %}

{% tab title="Processing" %}

```json
{
  "code": "200",
  "status": "processing",
  "message": "Payment is under processing.",
  "return_data": {
    "kwikX_order_id": "kp_40dec464",
    "order_id": "6116229263036",
    "order_status": "PROCESSING"
  }
}
```

{% endtab %}
{% endtabs %}

## Example Payout Response

{% tabs %}
{% tab title="Success" %}

```json
{
  "status": true,
  "code": 200,
  "message": "Payout status fetched successfully.",
  "data": {
    "payout_id": "payout_b7c9d4d780db71e8",
    "payout_order_id": "1778761897",
    "status": "FAILED",
    "amount": "9999999999",
    "currency": "INR",
    "utr_number": "NA",
    "message": "Txn failed due to insufficient funds"
  }
}
```

{% endtab %}

{% tab title="Failed" %}

```json
{
  "status": true,
  "code": 200,
  "message": "Payout status fetched successfully.",
  "data": {
    "payout_id": "payout_b7c9d4d780db71e8",
    "payout_order_id": "1778761897",
    "status": "FAILED",
    "amount": "9999999999",
    "currency": "INR",
    "utr_number": "NA",
    "message": "Txn failed due to insufficient funds"
  }
}
```

{% endtab %}

{% tab title="Insufficient Funds" %}

```json
{
  "status": false,
  "code": 422,
  "message": "Insufficient wallet balance."
}
```

{% endtab %}

{% tab title="Transaction Not Found" %}

```json
{
  "status": false,
  "code": 404,
  "message": "Payout transaction not found."
}
```

{% endtab %}
{% endtabs %}

## Webhook Mock Testing

Sandbox webhooks can also simulate:

* Payment success events
* Payment failures
* Payout success notifications
* Payout failures
* Duplicate webhook events

Merchants should test:

* Signature verification
* Retry handling
* Idempotent processing
* Webhook logging

***

## Recommended Testing Checklist

Before production deployment, verify:

* Payment success handling
* Payment failure handling
* Processing state retries
* Payout success flow
* Payout failure flow
* Insufficient balance handling
* Webhook verification
* Retry workflows
* Duplicate transaction protection

***

## Important Notes

* Mock responses are for testing only
* Sandbox responses do not represent real settlements
* UTR numbers in Sandbox are simulated
* Banking confirmations are mocked in test mode

***

## Best Practices

* Test both success and failure scenarios
* Validate retry handling properly
* Verify webhook security
* Handle all API status codes safely
* Maintain test transaction logs

***

## Security Recommendations

* Never expose Sandbox credentials publicly
* Validate webhook signatures even in test mode
* Use separate environments for testing and production
* Avoid mixing Sandbox and production credentials


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.kwikpaisa.com/v3-guide/testing-and-sandbox/mock-responses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
