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

# Payment Flow & Redirection

> Learn how to redirect users to the Cashii payment page and handle the callback.

After you have successfully created a [Remote Payment](./core-concepts) using the API and received a `paymentId` back, the next step is to guide the user to complete the payment.

## Redirecting Users to the Payment Page

Your application (typically the frontend) needs to redirect the user's browser to the Cashii payment page. Construct the URL as follows:

```
https://cashii.app/payment?code={paymentId}&redirect={redirectUrl}
```

**Parameters:**

* **`code`** (Required): The 16-digit `paymentId` you received when creating the Remote Payment.
* **`redirect`** (Required): The URL within your application where Cashii should redirect the user *after* they attempt the payment (whether successful or not). This URL **must be URL-encoded**.

**Example Redirect URL:**

```
https://cashii.app/payment?code=1234567890123456&redirect=https%3A%2F%2Fyourapp.com%2Fpayment%2Fcallback
```

## User Experience on the Payment Page

* A web-based payment page is displayed.
* It shows a **QR code** that can be scanned by the Cashii app.
* It allows payment via **bank cards** integrated with the Cashii network.
* Users can manually enter the **16-digit payment code** if needed.
* On some devices (like certain Samsung models using the default browser), universal links might not work reliably. In such cases, the user might see tabs and need to manually tap the **"Cashii App"** tab to trigger the app launch.

<video controls className="w-full aspect-video" src="https://f003.backblazeb2.com/file/cashii-docs/videos/payment-gateway-demo.mov" />

## Handling the Redirect Back to Your App

Once the user completes (or cancels) the payment attempt on the Cashii page/app, Cashii will redirect their browser back to the `redirectUrl` you provided.

Cashii appends query parameters to this URL to inform your application about the outcome:

**Example Redirect Back:**

```
https://yourapp.com/payment/callback?transaction_id=TRX987654321&status=paid&signature=a_secure_signature_hash
```

**Query Parameters:**

* **`transaction_id`**: The unique identifier for the transaction record within Cashii (distinct from the initial `paymentId`).
* **`status`**: The resulting status of the payment attempt (e.g., `paid`, `rejected`, `canceled`). See [Core Concepts](./core-concepts#payment-statuses) for possible values.
* **`signature`**: A security signature hash (details forthcoming - used to verify the redirect came from Cashii).

<Warning>Client-Side Status is Informational Only</Warning>

While the `status` parameter in the redirect URL provides immediate feedback to the user, **do not rely solely on this client-side information** to confirm the payment for fulfilling orders or providing services.

**Always verify the final payment status server-side.**

## Verifying Payment Status (Server-Side)

Your `redirectUrl` should point to a page or endpoint in your application that triggers a server-side verification process:

1. Your frontend receives the redirect with `transaction_id`, `status`, and `signature`.
2. Your frontend informs your backend, passing along the original `paymentId` (which you should associate with the user's session or the order).
3. Your backend uses the `paymentId` to call the **Retrieve Remote Payment Information** endpoint ([API Reference](/api-reference/endpoint/Retrieve%20Remote%20Payment%20Information) or see [Quickstart](./quickstart#retrieve-remote-payment-information)).
4. The API response contains the definitive, trusted `status` of the payment.
5. Your backend updates your order status in your database based on the verified API response.
6. Your backend informs the frontend, which then displays the appropriate confirmation or error message to the user.

This server-side check ensures payment integrity even if the client-side redirect is manipulated or fails.
