---
page_title: Test Page
product: Juspay Billing
page_source: https://juspay.io/in/docs/juspay-billing/docs/billing/test-page
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/juspay-billing/llms.txt
---


# Welcome to GUI editor!




# Session API



The Session API provides an alternative to the Order API for all subscription flows. Instead 

of a raw API response, it returns a hosted Juspay payment page URL that the merchant redirects 

the customer to. The underlying `payment_rules` structure is identical across both APIs — only 

the wrapper fields differ.

---


## Order API vs Session API




|  | Order API | Session API |
|---|---|---|
| **Endpoint** | POST /ecr/orders | POST /session |
| **Payment UI** | Merchant-hosted | Juspay-hosted payment page |
| **Routing** | Merchant specifies gateway_id | Juspay handles routing |
| **Mandate field** | mandate.max_amount | mandate_max_amount |
| **`payment_rules`** | Identical | Identical |
| **Use when** | Custom checkout UI | Standard hosted checkout |


---


## Common Request Parameters



These fields are present across all Session API subscription flows.


| Parameter | Type | Required | Description |
|---|---|---|---|
| `order_id` | string | Yes | Unique identifier for this order |
| `amount` | string | Yes | Authorization amount (typically "1.0" for mandate registration) |
| `customer_id` | string | Yes | Juspay customer identifier |
| `payment_page_client_id` | string | Yes | Merchant's Juspay checkout client ID |
| `action` | string | Yes | Must be paymentPage |
| `return_url` | string | Yes | Redirect URL after payment completion |
| `description` | string | No | Payment description shown on the checkout page |
| `first_name` | string | No | Customer's first name |
| `last_name` | string | No | Customer's last name |
| `options.get_upi_deep_links` | boolean | No | Set to true to enable UPI deep links on the payment page |
| `options.create_mandate` | string | Yes | Must be REQUIRED for all subscription registration flows |
| `mandate_max_amount` | string | Yes | Maximum amount permitted per execution under this mandate |
| `metadata.auto_refund_post_success` | string | Yes | Set to "true" to auto-refund the ₹1 auth after successful mandate registration |
| `payment_rules` | string (JSON) | Yes | Encodes the billing flow — same structure as Order API |


---


## Flow 1: Plan Registration (Dynamic Billing Start Date)



Registers a mandate and schedules the first billing cycle to begin at a merchant-defined 

future date. The introductory period is the gap between registration and `billing_start_date`.


### `payment_rules` Structure




#### json Code Snippet:

```json
{
  "payment_flows": {
    "billing_creation": {
      "status": "REQUIRED",
      "info": {
        "plan_id": "<plan_id>",
        "plan_amount": <plan_amount>,
        "billing_start_date": <unix_timestamp>
      }
    }
  }
}

```



### Sample Request



<!-- INSERT CURL HERE -->

---


## Flow 2: Plan Registration (Fixed Introductory Days / Introductory Cycles)



Registers a mandate for plans where the introductory period is already configured on the plan 

definition (`introductory_days` or `introductory_cycles`). No additional `payment_rules`

parameters are required — the billing engine reads the plan configuration automatically.


### `payment_rules` Structure




#### json Code Snippet:

```json
{
  "payment_flows": {
    "billing_creation": {
      "status": "REQUIRED",
      "info": {
        "plan_id": "<plan_id>"
      }
    }
  }
}

```



### Sample Request



<!-- INSERT CURL HERE -->

---


## Flow 3: Plan Change (Upgrade)



Initiates a prorated payment to upgrade a customer's plan mid-cycle. The `billing_execution_info_id`

and `request_id` must match the values returned from the preceding Preview Prorated Amount 

API call.

> **Note**
> customer before creating this session. The session `amount` must equal the `prorated_amount`
> 
> from the preview response. The session expires at `preview_expires_at` — create it before
> 
> that timestamp.




### `payment_rules` Structure




#### json Code Snippet:

```json
{
  "payment_flows": {
    "billing_plan_change": {
      "status": "REQUIRED",
      "info": {
        "billing_execution_info_id": "<from preview response>",
        "request_id": "<from preview response>"
      }
    }
  }
}

```



### Sample Request



<!-- INSERT CURL HERE -->

---

## See Also

- [Setting up Introductory Days / Cycle](https://juspay.io/in/docs/juspay-billing/docs/billing/setting-up-introductory-days-cycle)
