# T&C Acceptance Flow

This document defines the **T&C (Terms & Conditions) acceptance redirect flow** required for card activation, in alignment with **RBI co‑branding guidelines**. It is intended for **backend and frontend developers** integrating the card activation and T&C gating flow in both **UAT** and **Production** environments.

### <span style="color:#7b2cbf">Purpose</span>

Wallet activation and usage are gated behind **explicit user acceptance** of the latest wallet T&C and, where applicable, **minimum KYC**.

A card may exist but must **not** be treated as active or usable until:
  - The user has accepted the **latest T&C**, and
  - **Minimum KYC** requirement is satisfied.
- The system of record for T&C status is the **card details API**, via the field `latestTncVersionAccepted`.

**This specification defines:**

- How to **detect** that T&C acceptance is pending.
- How to **construct and send** the T&C redirect.
- How to **handle** the post‑T&C redirect back to your application.
- **Security, validation, and test** considerations.


<Container>
  ### <span style="color:#7b2cbf">Preconditions</span>

Before implementing this flow, ensure, you have access to the **card Details API** that returns:
  - `latestTncVersionAccepted` (boolean)
  - `cardId`
- You can generate a **current access token** for the card/user context.
- You can define and control a **return URL** (in your application) where the user will be redirected after:
  - T&C acceptance, or
  - Minimum KYC completion.

</Container>


<Container>
  ### <span style="color:#7b2cbf">Trigger Condition</span>

You **must initiate** the T&C redirect flow when the **card Details API** returns:

```json
{
  "cardId": "<walletId>",
  "latestTncVersionAccepted": false,
  ...
}
```

#### <Icon icon="material-outline-numbers"color="#7b2cbf"/>*Trigger rule:*

- If `latestTncVersionAccepted === false`:
  - The user **must** be redirected to the **T&C URL**.
- If `latestTncVersionAccepted === true`:
  - Proceed with the **normal wallet flow**; no T&C redirect is required.

#### <Icon icon="material-outline-numbers"color="#7b2cbf"/>*This rule must be evaluated:*

- Whenever the user **opens or re‑opens** the wallet.
- The user previously navigated away without completing T&C acceptance, and later returns to the wallet screen.

</Container>


<Container>
  ### <span style="color:#7b2cbf">Environment‑Specific URLs</span>
Use the following base URLs for the T&C acceptance flow.

| Environment | URL |
| --- | --- |
| Production |   [`https://home.enkash.in/partner/tnc?WID={cardId}==&at={token}&returnUrl={returnUrl}`](https://home.enkash.in/partner/tnc?WID={cardId}==&at={token}&returnUrl={returnUrl})
| UAT |  [`https://invoice-uat.enkash.in/partner/tnc?WID={cardId}==&at={token}&returnUrl={returnUrl}`](https://invoice-uat.enkash.in/partner/tnc?WID={cardId}==&at={token}&returnUrl={returnUrl}) 
</Container>

    
<Container>
     ### <span style="color:#7b2cbf">URL Construction (Production Example)</span>
 
**Step 1:** Build the payload JSON

```json
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "walletId": "WALLET_12345",
  "returnUrl": "https://your-app.com/wallet/home"
}
```

**Step 2:** Base64 encode the JSON

```text
eyJ0b2tlbiI6ImV5SmhiR2NpT2lK...
```

**Step 3:** Construct the Production URL

```text
https://home.enkash.in/partner/tnc?WID={cardId}==&at={token}&returnUrl={returnUrl}
```

**Example (truncated for illustration):**

```text
https://invoice-uat.enkash.in/partner/tnc?WID={cardId}==&at={token}&returnUrl={returnUrl}
```

:::caution[]
Apply the **same construction** logic for the UAT base URL.
    Query parameters and payload format must be **consistent** across UAT and Production.
:::
    
</Container>
    
    
<Container>
### <span style="color:#7b2cbf">Redirect Flow</span>
    
    When `latestTncVersionAccepted = false`:
    
<Steps>
  <Step title="Detect Pending T&C:">
     - Call Card Details API.
   - Check `latestTncVersionAccepted`.
  </Step>
  <Step title="T&C Redirect URL">
    - Choose the correct **base URL** (UAT or Production).
   - Build a **Base64‑encoded JSON payload** containing:
     - Current access token
     - Wallet ID
     - Return URL
  </Step>
  <Step title="Partner App">
    Redirect the user to the T&C URL provided by EnKash.
  </Step>
    <Step title="User Completes">
   - T&C acceptance, and
   - Minimum KYC verification within Enkash’s platform
  </Step>
     <Step title="Redirect">
  EnKash redirects the user back to Partner's **returnUrl**. 
  </Step>
     <Step title="Recommended">
  - Call Card Details API again to confirm:
   `latestTncVersionAccepted === true`
   - Before enabling Card usage UI/features.
  </Step>
</Steps>

</Container>







