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

# Redirect page

> Configure the redirect page shown after a customer completes or cancels a payment on Fintoc's legacy v2023-11-15 hosted checkout experience.

When your customers choose to pay with Fintoc, the process works as follows:

1. **Create a checkout session:** Your backend calls the Fintoc API to create a Checkout Session. Include `success_url` and `cancel_url` in your request.
2. **Receive the redirect URL:** The API returns a session that contains `redirect_url`. Use this URL to send your customer to the Fintoc payment page.
3. **Complete the payment:** Your customer completes the payment in the Fintoc Widget.
4. **Return to your site:** Fintoc sends your customer to the provided `success_url` or `cancel_url` after the payment flow.

***

## Create a Checkout Session

Use your secret key to create a Checkout Session on your server. Include `success_url` and `cancel_url` in the request:

```bash theme={null}
curl --request POST \
     --url https://api.fintoc.com/v1/checkout_sessions \
     --header 'Authorization: YOUR_TEST_SECRET_API_KEY' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data-raw '{
  "amount": 1000,
  "currency": "CLP",
  "cancel_url": "https://merchant.com/987654321",
  "success_url": "https://merchant.com/success",
  "customer_email": "customer@example.com",
  "metadata": {
      "order": "987654321"
    }
}'
```

```javascript Node theme={null}
// You need to install Fintoc's Node SDK first: https://docs.fintoc.com/docs/accept-a-payment-copy#optional-install-our-backend-sdk

const checkoutSession = await fintoc.checkoutSessions.create({
	amount: 1000,
  currency: 'clp',
  customer_email: 'name@example.com',
  cancel_url: 'https://merchant.com/987654321',
  success_url: 'https://merchant.com/success',
  metadata: {
    order: '987654321'
  }
});
```

```python Python theme={null}
# You need to install Fintoc's Python SDK first: https://docs.fintoc.com/docs/accept-a-payment-copy#optional-install-our-backend-sdk

checkout_session = client.checkout_sessions.create(
    amount=1000,
    currency='clp',
    customer_email='name@example.com',
    cancel_url='https://merchant.com/987654321',
    success_url='https://merchant.com/success',
    metadata={
        order: '987654321'
    }
)
```

| Parameter        | Example                          | Explanation                                                                                                                                                                 |
| :--------------- | :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `amount`         | `2476`                           | Amount to pay in the smallest currency unit.<br /><br />For example, MXN 24.76 is represented as `2476`.<br /><br />For cash payments, the maximum is `500000` (MXN 5,000). |
| `currency`       | `MXN`                            | Currency used for the payment. Cash payments support only `MXN`.                                                                                                            |
| `success_url`    | `https://merchant.com/success`   | URL Fintoc redirects your customer to after a successful payment.                                                                                                           |
| `cancel_url`     | `https://merchant.com/987654321` | URL Fintoc redirects your customer to if they cancel the payment.                                                                                                           |
| `customer_email` | `customer@example.com`           | Customer email associated with the Checkout Session. Fintoc uses this address to notify your customer about a refund.                                                       |
| `metadata`       | `{"order": "987654321"}`         | Set of key-value pairs for storing structured information about the object.                                                                                                 |

### Handle the API response

The API returns the checkout session with its `redirect_url`. For example:

```json theme={null}
{
  "id": "cs_li5531onlFDi235",
  "created_at": "2025-02-06T18:42:51Z",
  "object": "checkout_session",
  "currency":"CLP",
  "amount": "1000",
  "customer_email":"customer@example.com",
  "expires_at": "2025-02-06T18:52:51Z",
  "mode": "live",
  "status":"created",
  "session_token": "cs_li5531onlFDi235_sec_a4xK32BanKWYn",
  "cancel_url": "https://merchant.com/987654321",
  "success_url": "https://merchant.com/success",
  "metadata": {
      "order": "987654321"
    },
  "business_profile": {},
  "redirect_url": "https://pay.fintoc.com/payment?checkout_sesion=cs_li5531onlFDi235"
}
```

### Handle post-payment events

Fintoc sends a `checkout_session.completed` event when the payment is complete. Use the [webhook guide](/v2023-11-15/guides/resources/webhooks-walkthrough) to receive these events. You can then send an order confirmation email, log the sale, or start a shipping workflow.

Listen for these events instead of waiting for a client-side callback. Your customer might close the browser or app before the callback runs. A malicious client could also manipulate the response.

We recommend handling the following events:

| **Event**                       | **Description**                                                                                     | **Action**                                                                         |
| ------------------------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **`checkout_session.finished`** | Sent when your customer completes a payment. The webhook contains the payment and its final status. | Confirm the order or offer another payment attempt, depending on the final status. |
| **`checkout_session.expired`**  | Sent when your customer leaves the payment flow before finishing.                                   | Offer your customer another payment attempt.                                       |

<Info>
  **Learn more about webhooks**

  Read the [webhooks guide](/v2023-11-15/guides/resources/webhooks-walkthrough) to create and test your webhook endpoint and follow security best practices.
</Info>
