> ## 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

> >-

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

1. **Checkout Session Creation:** Your backend calls our API to create a Checkout Session. You must include a `success_url` and a `cancel_url` in your request.
2. **Receiving the Redirect URL:** Our API responds with a session that contains a `redirect_url`. This URL is used to send your customer to our secure payment page.
3. **Customer Payment Flow:** Your customer is redirected to our payment page, where they complete their payment on the Fintoc Widget.
4. **Return Flow:** After the payment, your customer is automatically sent back to your site via the `success_url` or `cancel_url` provided.

***

## Create a Checkout Session

Using your Secret Key, create a `Checkout Session` on your server with the `success_url` and `cancel_url`:

```curl 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"
    }
}'
```

```node 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 of money that needs to be paid. It's represented **as an integer with no decimals** in the smallest possible unit of the currency you are using.<br /><br />An amount of MXN 24.76 is represented as 2476.<br /><br />For cash payments, the maximum allowed amount is 500000 (5,000 MXN). |
| `currency`       | `MXN`                            | Currency that is being used for the payment. We currently only support MXN for cash payments.                                                                                                                                                                                                     |
| `success_url`    | `https://merchant.com/success`   | URL to redirect the user in case of payment succeeded.                                                                                                                                                                                                                                            |
| `cancel_url`     | `https://merchant.com/987654321` | URL to redirect the user in case they decide to cancel the payment and return to your website.                                                                                                                                                                                                    |
| `customer_email` | `customer@example.com`           | Optional customer email linked to a Checkout Session. This is used to notify a user in case of a refund.                                                                                                                                                                                          |
| `metadata`       | `{"order": "987654321"}`         | Optional set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.                                                                                                                                  |

### Handling the API Response

After creating the checkout session, you’ll receive a response that includes a `redirect_url` along with other important parameters. 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"
}
```

### **Handling post-payment events**

Fintoc sends a `checkout_session.completed` event when the payment is complete. Use the [**webhook guide**](/v2023-11-15/docs/resources/webhooks-walkthrough) to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.

Listen for these events rather than waiting on a callback from the client. From the client side, On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response.

We recommend handling the following events:

| **Event**                       | **Description**                                                                                                              | **Action**                                                                                                             |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **`checkout_session.finished`** | Sent when a customer has completed a payment. The webhook contains information about the Payment including its final status. | Depending on the final status of the related payment, confirm the order to the customer or offer to retry the payment. |
| **`checkout_session.expired`**  | Triggers when a customer leaves the payment flow before finishing                                                            | Offer the customer another attempt to pay.                                                                             |

<Info>
  **Learn more about webhooks**

  To learn more about how to create your own webhook endpoint, test your webhook endpoint and security best practices read our [**Webhooks guide**](/v2023-11-15/docs/resources/webhooks-walkthrough)
</Info>
