> ## 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.

# Checkout mandates

# Subscriptions Checkout & Mandate Authorizations

Fype handles the complexity of registering recurring mandates (UPI Autopay, Card Mandates, eNACH/eMandates) across payment providers via its unified **Hosted Checkout** page.

***

## The Subscription Mandate Flow

Unlike one-time payments, subscriptions require the customer to authorize a gateway mandate. The mandate gives permission to charge the customer's account automatically in subsequent billing cycles.

```mermaid theme={null}
sequenceDiagram
    participant App as Merchant Application
    participant Fype as Fype Billing
    participant Checkout as Hosted Checkout (pay.fype.dev)
    participant Customer as Customer
    participant Gateway as Razorpay / Cashfree / Simulator
    
    App->>Fype: POST /subscriptions (plan_id, price_id, customer)
    Fype->>Gateway: Create Subscription Intent
    Gateway-->>Fype: Gateway Subscription ID & Tokens
    Fype-->>App: Return checkout_url
    App->>Customer: Redirect to checkout_url
    Customer->>Checkout: Loads checkout page
    Checkout->>Gateway: Initialize SDK with Gateway Subscription ID
    Customer->>Checkout: Input Payment Details (UPI, Card, NetBanking)
    Checkout->>Customer: Trigger bank OTP / UPI App Autopay Approval
    Customer->>Gateway: Complete Bank Authorization
    Gateway-->>Checkout: Confirm Mandate Registration
    Checkout->>Fype: Finalize State Machine
    Fype-->>App: Redirect customer back to success_url
```

***

## Supported Mandate Instruments

Fype dynamically filters the payment instruments shown to the customer depending on the selected provider and mandate requirements:

1. **UPI Autopay (Recommended)**:
   * Customers authorize the mandate using UPI apps (PhonePe, Google Pay, Paytm, BHIM).
   * Ideal for low-friction checkouts with limits up to ₹15,000 per transaction without OTP.
2. **Card Mandates (Credit & Debit)**:
   * Supports 3D-Secure authentication during checkout.
   * Subsequent cycles process automatically without recurring 3D-Secure prompts.
3. **eNACH / eMandate**:
   * Authorized via NetBanking or Debit Card credentials.
   * Used primarily for high-value business transactions.

***

## Interactive Simulator

For development and test environments, Fype provides an **Interactive Sandbox Simulator**. When using a test API key with the provider set to `simulator`, Fype bypasses real banking networks and loads a mockup checkout console.

> \[!NOTE]
> The sandbox simulator allows you to test:
>
> * **Mandate Success**: Simulates a customer authorizing UPI Autopay.
> * **Decline/Failure**: Simulates a customer canceling the checkout or the bank rejecting the mandate.
> * **State Resiliency**: Confirms that your webhook listener correctly receives and processes the `subscription.authenticated` and `subscription.activated` events.

***

## Integration Example

### 1. Server-Side: Create a Subscription

Create the subscription intent. Use the `checkout_url` returned in the response to redirect the customer.

```python theme={null}
# Python SDK Example
from fype import Fype

fype = Fype(api_key="fype_test_...")

subscription = fype.subscriptions.create(
    customer_id="customer_uuid",
    plan_id="plan_uuid",
    price_id="price_uuid",
    quantity=1,
    metadata={"source": "marketing_campaign"}
)

# Redirect customer to checkout
print(subscription["checkout_url"])
```

### 2. Success URL Placeholders

When creating a subscription, you can pass placeholders in the `success_url` parameter. Fype will dynamically replace these placeholders with session and subscription IDs when redirecting the customer back to your site:

* `{CHECKOUT_SESSION_ID}`: The Fype checkout session UUID.
* `{SUBSCRIPTION_ID}`: The Fype subscription UUID.

**Example success\_url configuration**:

```
https://your-app.com/dashboard/welcome?sub_id={SUBSCRIPTION_ID}&session={CHECKOUT_SESSION_ID}
```
