> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fype.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulator guide

# Fype Sandbox Simulator

The Fype Simulator is a powerful internal sandbox environment that allows you to test your entire payment flow—from order creation to webhook fulfillment—instantly and without needing real credentials from gateways like Razorpay or Cashfree.

## When to Use the Simulator

* **Prototyping**: Test your SDK integration in minutes.
* **CI/CD**: Automate end-to-end payment tests in your build pipelines.
* **Error Handling**: Simulate edge cases like UPI timeouts and card declines that are difficult to trigger in real gateway sandboxes.
* **Disconnected Development**: The simulator is purely internal to Fype and doesn't require an active connection to an external payment provider.

## How it Works

When you use a Fype **Test API Key** (`fype_test_...`), Fype automatically flags the checkout session as a sandbox transaction. Instead of loading an external gateway SDK, Fype renders the **Interactive Simulator Console**.

### Simulation Options

#### One-Time Payments

| Action                    | Resulting Fype Event | Description                                                                                                      |
| :------------------------ | :------------------- | :--------------------------------------------------------------------------------------------------------------- |
| **Simulate Success**      | `payment.succeeded`  | Mocks a successful bank capture. Redirects the user to your `success_url`.                                       |
| **Simulate Card Decline** | `payment.failed`     | Mocks a 504 Authorization failure. Redirects the user to your `cancel_url`.                                      |
| **Simulate UPI Timeout**  | None / Abandonment   | Triggers a 5-second countdown on the checkout page. If the user doesn't act, the session is marked as abandoned. |

#### Subscriptions

| Action                    | Resulting Fype Event          | Description                                                                                                                  |
| :------------------------ | :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| **Simulate Success**      | `subscription.authenticated`  | Mocks successful mandate authorization (and transition to `trialing` or `active`). Redirects the user to your `success_url`. |
| **Simulate Card Decline** | `subscription.payment_failed` | Mocks a mandate setup decline (transitions subscription to `cancelled`). Redirects the user to your `cancel_url`.            |
| **Simulate UPI Timeout**  | None / Abandonment            | Triggers a 5-second countdown on the checkout page. If the user doesn't act, the setup is abandoned.                         |

## Webhook Signatures in Sandbox

Even in sandbox mode, Fype sends cryptographically signed webhooks to your server.

* **Key Verification**: Use the same signature verification logic as in production.
* **Behavior**: The simulator generates identical event payloads and webhooks as a real payment gateway (like Razorpay or Cashfree), allowing you to verify your integration end-to-end.
* **Trigger Test Webhook**: You can also trigger sandbox subscription webhook events manually using sandbox APIs or via the Developer Portal.

## Automated Testing (API)

You can also trigger simulator checkout completions programmatically for automated testing:

`POST /v1/checkout/sessions/{session_id}/simulate`

**Request Body for Payments/Subscriptions**:

```json theme={null}
{
 "status": "succeeded"
}
```

*(Use `succeeded` or `failed` to simulate success/failure outcomes).*

*Note: This endpoint is only available for sessions created with test API keys.*
