# T&C Acceptance Flow 

This document defines the **T&C (Terms & Conditions) acceptance redirect flow** required for wallet activation, in alignment with **RBI co‑branding guidelines**. It is intended for **backend and frontend developers** integrating the wallet 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 wallet 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 **wallet 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 **Wallet Details API** that returns:
  - `latestTncVersionAccepted` (boolean)
  - `walletId`
- You can generate a **current access token** for the wallet/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 **Wallet Details API** returns:

```json
{
  "walletId": "<walletId>",
  "latestTncVersionAccepted": false,
    "minKycOtpVerified":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.com/partner/tnc?WID=base64encodedWalletId&at=base64encodedAccessToken&returnUrl=base64encodedReturnUrl
| UAT |   https://invoice-uat.enkash.in/partner/tnc?WID=base64encodedWalletId&at=base64encodedAccessToken&returnUrl=base64encodedReturnUrl
</Container>

    
<Container>
     ### <span style="color:#7b2cbf">URL Construction (Production Example)</span>
 
**Step 1:** Replace Placeholder Values
| Field  | Value |
| --- | --- |
| {base64encodedWalletId} |  Wallet ID encoded in Base64 format
| {base64encodedAccessToken} |  Access Token encoded in Base64 format
| {base64encodedReturnUrl} | Return URL encoded in Base64 format


**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 Wallet 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 Wallet Details API again to confirm:
   `latestTncVersionAccepted === true`
   - Before enabling wallet usage UI/features.
  </Step>
</Steps>

</Container>







