# Redirect User

After successfully creating an order using the Create Order API, KwikPaisa returns a hosted checkout URL in the:

```
payment_link
```

parameter.

You must redirect the customer to this payment link to complete the payment securely using the KwikPaisa hosted checkout page.

## Payment Flow

1. Merchant creates payment order
2. KwikPaisa returns `payment_link`
3. Merchant redirects customer to hosted checkout
4. Customer completes payment
5. KwikPaisa redirects customer back to merchant `return_url`
6. Merchant verifies payment using Order Status API or Webhook

***

## Example Create Order Response

```json
{
  "code": "200",
  "status": "success",
  "message": "API authentication successful!",
  "return_data": {
    "kwikX_order_id": "kp_40dec464-7155-43a3-855d-c95c5ab1be71",
    "created_at": "13-05-2026 08:34 AM",
    "order_id": 6116229263036,
    "order_status": "UN_PAID",
    "payment_link": "https://sandbox.kwikpaisa.com/payment/checkout/..."
  }
}
```

***

## Redirect Customer

Redirect the customer to:

```
payment_link
```

returned in the API response.

***

## JavaScript Redirect Example

```javascript
window.location.href = response.return_data.payment_link;
```

***

## PHP Redirect Example

```php
header(
    "Location: " . $response['return_data']['payment_link']
);
exit;
```

***

## Successful Payment Redirection

After the customer completes the payment successfully, KwikPaisa redirects the customer back to the merchant `return_url`.

The redirect is sent as a GET request with:

```http
?order_id={merchant_order_id}
```

appended automatically.

***

## Example Redirect URL

```http
https://merchant.in/process_return.php?order_id=6116229263036
```

***

## Important Notes

* The `return_url` must be publicly accessible
* Always use HTTPS URLs
* `order_id` returned in redirect is the merchant order ID
* Frontend redirects should not be used as final payment confirmation
* Always verify payment using:
  * Order Status API
  * Webhook notifications

***

## Recommended Verification Flow

After receiving the redirect:

1. Extract `order_id`
2. Call Order Status API
3. Verify payment status server-side
4. Update transaction status in your system

***

## Why Verification is Important

Customer redirects may fail due to:

* Browser interruptions
* Network issues
* User closing the page
* Device crashes

For reliable payment confirmation, always validate transactions server-side.

***

## Recommended Integration Flow

1. Create Order
2. Redirect customer to `payment_link`
3. Customer completes payment
4. Receive redirect on `return_url`
5. Verify transaction using APIs/webhooks
6. Mark order as successful

***

## Best Practices

* Always verify payment status server-side
* Do not trust frontend redirects alone
* Store merchant `order_id` securely
* Use unique order IDs for every transaction
* Enable webhook handling for real-time updates


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.kwikpaisa.com/v3-guide/payment-gateway-integration/redirect-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
