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

# Accept card payments with Checkout Fields

> Accept card payments from your own checkout with Fintoc's secure fields.

Fintoc provides the card number, expiry date, and card verification value (CVV) fields as iframes. You build the rest of the interface and confirm the payment from your backend, without handling card data. Checkout Fields is available for organizations in Chile.

## When to use Checkout Fields

Compare the options by who controls the interface and the integration effort:

| Integration | Who controls the interface | Integration effort |
| - | - | - |
| [Redirect checkout](https://docs.fintoc.com/guides/payments/accept-a-payment/index.md) | Fintoc | Low |
| [Fintoc Widget](https://docs.fintoc.com/guides/resources/widget/web-integration.md), bank transfer payments only | Fintoc | Medium |
| Checkout Fields | You | Medium–high |

Use Checkout Fields if you already have your own checkout (payment method selector, installments, promotions) and want to keep it.

Checkout Fields uses the same objects as the current API: [Checkout Sessions](https://docs.fintoc.com/api/payments-api/checkout-sessions/checkout-session-object.md), [Payment Intents](https://docs.fintoc.com/api/payments-api/payment-intents/payment-intents-object.md), and [Payment Methods](https://docs.fintoc.com/api/payments-api/payment-methods/payment-method-object.md). You confirm the payment on the Checkout Session, and Fintoc creates the Payment Intent for you.

## How it works

The following diagram shows how Fintoc interacts with your frontend and backend:

```mermaid theme={null}
sequenceDiagram
    participant F as Your frontend
    participant E as Checkout Fields
    participant B as Your backend
    participant X as Fintoc
    B->>X: 1. Create Checkout Session
    X-->>B: 2. Return session_token
    B-->>F: 3. Pass the session_token
    F->>E: 4. Mount the fields
    E-->>F: 5. Field state while the customer types
    F->>E: 6. Submit the card
    E->>X: 7. Number, expiry, and CVV
    X-->>F: 8. 3DS challenge in a modal, if the issuer requires it
    X-->>F: 9. Return the status and the card details, without sensitive data
    F->>B: 10. Call your backend (without card data)
    B->>X: 11. Confirm the Checkout Session
    X-->>B: 12. Send payment_intent.succeeded
```

If the issuer requires 3-D Secure (3DS) authentication, Fintoc shows the challenge in a modal over your page before the submit resolves. Fintoc charges the card only when your backend confirms the Checkout Session.

Your server never handles card data (step 7): it only handles the `session_token`, the confirm call, and the webhook.

## Create a Checkout Session

When the customer reaches the payment step, your backend [creates a Checkout Session](https://docs.fintoc.com/api/payments-api/checkout-sessions/checkout-sessions-create.md) with `ui_mode: "fields"` using your [Secret Key](https://docs.fintoc.com/guides/home/api-keys.md). The session stores the order (amount, currency, allowed methods) and passes only its `session_token` to the frontend.

With `ui_mode: "fields"`, `payment_method_types` is required and must be `["card"]`. You can't send `success_url`, `cancel_url`, or `payment_method`.

**Server: create a Checkout Session**

```bash cURL theme={null}
curl -X POST https://api.fintoc.com/v2/checkout_sessions \
  -H "Authorization: YOUR_TEST_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 26677,
    "currency": "CLP",
    "ui_mode": "fields",
    "payment_method_types": ["card"],
    "customer": "cus_456789abcdef",
    "save_payment_method": "enabled",
    "metadata": { "order_id": "ORD-98765" }
  }'
```

```javascript Node theme={null}
const { Fintoc } = require('fintoc');

const fintoc = new Fintoc('YOUR_TEST_SECRET_KEY');
const checkoutSession = await fintoc.v2.checkoutSessions.create({
  amount: 26677,
  currency: 'CLP',
  ui_mode: 'fields',
  payment_method_types: ['card'],
  customer: 'cus_456789abcdef',
  save_payment_method: 'enabled',
  metadata: { order_id: 'ORD-98765' },
});
```

```python Python theme={null}
from fintoc import Fintoc

client = Fintoc('YOUR_TEST_SECRET_KEY')
checkout_session = client.v2.checkout_sessions.create(
    amount=26677,
    currency='CLP',
    ui_mode='fields',
    payment_method_types=['card'],
    customer='cus_456789abcdef',
    save_payment_method='enabled',
    metadata={'order_id': 'ORD-98765'},
)
```

Response (abbreviated):

```json Response theme={null}
{
  "id": "cs_test_a1b2c3d4e5f6g7h8i9j0",
  "object": "checkout_session",
  "status": "created",
  "amount": 26677,
  "currency": "CLP",
  "session_token": "cs_test_a1b2c3d4e5f6g7h8i9j0_token_k1l2m3n4o5p6q7r8s9t0",
  "expires_at": "2026-10-28T19:30:00Z"
}
```

> [!NOTE]
>
> `customer` is optional; it is required to save cards. See the [Customer object](https://docs.fintoc.com/api/payments-api/customers/customer-object.md).

### Restrict the accepted cards

To accept only some cards, send `payment_method_options.card` when you create the Checkout Session:

* `kinds`: card kinds to accept. Possible values are `credit`, `debit`, and `prepaid`.
* `bins`: bank identification numbers (BINs) to accept, with 6 or 8 digits each. The card number must start with one of them.

```json theme={null}
{
  "payment_method_options": {
    "card": {
      "kinds": ["credit"],
      "bins": ["401082"]
    }
  }
}
```

If a card doesn't meet the restriction, the card number field returns an error when the customer leaves it: `card_kind_not_permitted` for the kind, or `card_bin_not_permitted` for the BIN. The customer sees the error before submitting the card.

## Load the secure fields

Load Fintoc.js and initialize it with your [Public Key](https://docs.fintoc.com/guides/home/api-keys.md) and the session's `session_token`. Each sensitive field mounts inside your container as an iframe served from `wizard.fintoc.com`; your JavaScript cannot read its contents.

**Client**

```html checkout.html theme={null}
<script src="https://js.fintoc.com/v1/"></script>

<form id="payment-form">
  <input id="cardholder-name" placeholder="Name on card" />
  <div id="card-number"></div>
  <div id="card-expiry"></div>
  <div id="card-cvc"></div>
  <button type="submit">Pay</button>
</form>
```

```javascript checkout.js theme={null}
const cardFields = Fintoc.create({
  publicKey: 'YOUR_TEST_PUBLIC_KEY',
  sessionToken: 'cs_test_a1b2c3d4e5f6g7h8i9j0_token_k1l2m3n4o5p6q7r8s9t0',
  cardFields: {
    number: { selector: '#card-number' },
    expiry: { selector: '#card-expiry' },
    cvc: { selector: '#card-cvc' },
    style: {
      base: { fontFamily: 'Open Sans', fontSize: '16px', color: '#333' },
      placeholder: { color: '#bbb' },
      invalid: { color: '#d32f2f' },
    },
  },
  onChange: ({ field, empty, complete, error }) => {
    // Show your own error message for the field when error is not null
  },
});
```

You collect the cardholder name with your own input because it is not card data. Fintoc sets the placeholder of each field. `Fintoc.create` returns an object with `submit()`, to submit the card, and `destroy()`, to remove the fields from your page.

### Read the state of the fields while the customer types

Fintoc calls the `onChange` function that you pass to `Fintoc.create` when the state of a field changes. The data never includes the value the customer types, only the following data:

| Data | Description |
| - | - |
| `field` | Field that changed: `number`, `expiry`, or `cvc`. |
| `empty` | If `true`, the field is empty. |
| `complete` | If `true`, the field has a complete, valid value. |
| `error` | Validation error of the field, as an object with a `code`, or `null`. Includes `card_kind_not_permitted` and `card_bin_not_permitted` when the card doesn't meet the session's restrictions. |

Use this data to show your own error messages before the customer pays. `onChange` doesn't include the card brand, kind, or installments.

## Submit the card data

When the customer clicks **Pay**, call `cardFields.submit()`. The card number field collects the number, expiry date, and CVV from the three iframes and sends them to Fintoc in one request. If the issuer requires 3DS, Fintoc shows the challenge in a modal over your page. Fintoc doesn't charge the card yet.

**Client**

```javascript checkout.js theme={null}
const { status, card, error } = await cardFields.submit({
  holderName,
  holderTaxId: { type: 'cl_rut', value: '11.111.111-1' },
  installments: 3,
});
// status === 'ready' → call your backend to confirm the payment, without card data
```

`holderName` is required. `holderTaxId` is optional: the tax ID of the cardholder, which can be different from the `tax_id` of the [Customer](https://docs.fintoc.com/api/payments-api/customers/customer-object.md). Send it as an object with `type` and `value`. For `type`, use `cl_rut` for a Chilean tax ID (RUT), `mx_rfc` for a Mexican tax ID (RFC), or `custom` for any other ID. `installments` is optional and defaults to `1`. If `holderTaxId` doesn't have this shape, or the RUT isn't valid, `cardFields.submit()` returns the `invalid_holder_tax_id` error.

The promise never includes sensitive card data. It resolves with the following data:

```javascript theme={null}
{
  status: 'ready', // or 'error'
  card: {
    brand: 'visa',
    last_four_digits: '1111',
    kind: 'credit',
    country: 'Chile'
  },
  error: null // or { code: 'incomplete_card', message: 'Completa los datos de la tarjeta' }
}
```

If `status` is `ready`, your frontend calls your backend without any card data, and the backend confirms the Checkout Session (the next step). If `status` is `error`, display `error.message` and let the customer correct the fields. The promise resolves with `error` instead of throwing an exception.

### 3DS authentication

You don't write code to open or close the 3DS modal that `cardFields.submit()` shows. `cardFields.submit()` resolves only when the challenge ends, so it can take as long as the customer needs. Keep your loading state until the promise resolves.

If the authentication fails, or the customer cancels it on the issuer's page, the promise resolves with `status: 'error'` and the `authentication_failed` error. If the issuer's page doesn't load within 30 seconds, Fintoc closes the modal and the promise resolves with the `challenge_load_timeout` error. In both cases, Fintoc doesn't charge the card.

## Confirm the Checkout Session payment

When your frontend receives `ready`, your backend [confirms the Checkout Session](https://docs.fintoc.com/api/payments-api/checkout-sessions/checkout-sessions-confirm.md) with your Secret Key. Fintoc charges the card that the customer submitted. The request has no body.

**Server**

```bash Confirm Checkout Session theme={null}
curl -X POST https://api.fintoc.com/v2/checkout_sessions/cs_test_a1b2c3d4e5f6g7h8i9j0/confirm \
  -H "Authorization: YOUR_TEST_SECRET_KEY"
```

When the charge succeeds, the Payment Intent becomes `succeeded`, and the Checkout Session becomes `finished`. Wait for `payment_intent.succeeded` before treating the order as paid.

If the result of the charge isn't available yet, Fintoc responds with `202 Accepted`: confirm the Checkout Session again to get it. If the issuer declines the card, let the customer correct the card, submit it again, and confirm again.

## Save a customer's card

Save a card as a Payment Method to charge it later. You can save the card during a payment or without charging it.

### Save a card during a payment

You can save the card as a Payment Method while the customer pays, to charge it again later.

1. Create the Checkout Session with `save_payment_method: "enabled"` and a `customer` that already exists, or `customer_data` to create one. See the [Customer object](https://docs.fintoc.com/api/payments-api/customers/customer-object.md).
2. Send `savePaymentMethod: true` in `cardFields.submit()`.

**Server**

```json theme={null}
{
  "amount": 26677,
  "currency": "CLP",
  "ui_mode": "fields",
  "payment_method_types": ["card"],
  "customer": "cus_456789abcdef",
  "save_payment_method": "enabled"
}
```

**Client**

```javascript checkout.js theme={null}
const { status, card, error } = await cardFields.submit({
  holderName,
  savePaymentMethod: true,
});
```

You decide when to save the card. For example, show a checkbox and send what the customer chose, or always send `true`. Because the checkbox is on your page, you are responsible for asking the customer for consent. If you send `true` but the Checkout Session doesn't have `save_payment_method: "enabled"`, `cardFields.submit()` returns the `save_payment_method_not_enabled` error. If `savePaymentMethod` isn't a boolean, `cardFields.submit()` returns `invalid_save_payment_method`.

Fintoc saves the card only if the payment succeeds. When the payment succeeds, Fintoc sends the `payment_method.activated` webhook. The Checkout Session includes the Payment Method ID in `payment_method`, both in the confirm response and when you [get the session](https://docs.fintoc.com/api/payments-api/checkout-sessions/checkout-sessions-get.md). Store that ID from your backend. The `cardFields.submit()` response doesn't include the ID, because Fintoc hasn't charged the card yet.

To save the card, Fintoc prepares the card during `cardFields.submit()`, which can add up to 30 seconds. Keep your loading state until the promise resolves. If Fintoc can't prepare the card, `cardFields.submit()` still returns `ready` and the payment continues without saving the card. In that case, the Checkout Session doesn't include `payment_method`, and you don't receive `payment_method.activated`.

If the issuer also requires a 3DS challenge, Fintoc prepares the card first. Fintoc then shows the challenge modal, so the modal takes longer to appear. Keep your loading state during the entire `cardFields.submit()`, including that wait. If authentication fails or the customer cancels the challenge on the issuer's page, `cardFields.submit()` returns the `authentication_failed` error. Fintoc doesn't charge or save the card, so you don't receive `payment_method.activated`.

### Save a card without an immediate payment

Use a Checkout Session with `flow: "setup"` to save a card without charging it. For example, let your customer add a card from their account settings before making a purchase.

#### Create a setup Checkout Session

From your backend, [create a Checkout Session](https://docs.fintoc.com/api/payments-api/checkout-sessions/checkout-sessions-create.md) with `flow: "setup"`, `ui_mode: "fields"`, and `payment_method_types: ["card"]`. Send an existing `customer`, or use `customer_data` to create one.

**Server**

```bash cURL theme={null}
curl -X POST https://api.fintoc.com/v2/checkout_sessions \
  -H "Authorization: YOUR_TEST_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "flow": "setup",
    "ui_mode": "fields",
    "payment_method_types": ["card"],
    "customer": "cus_456789abcdef"
  }'
```

```javascript Node theme={null}
const { Fintoc } = require('fintoc');

const fintoc = new Fintoc('YOUR_TEST_SECRET_KEY');
const checkoutSession = await fintoc.v2.checkoutSessions.create({
  flow: 'setup',
  ui_mode: 'fields',
  payment_method_types: ['card'],
  customer: 'cus_456789abcdef',
});
```

```python Python theme={null}
from fintoc import Fintoc

client = Fintoc('YOUR_TEST_SECRET_KEY')
checkout_session = client.v2.checkout_sessions.create(
    flow='setup',
    ui_mode='fields',
    payment_method_types=['card'],
    customer='cus_456789abcdef',
)
```

The response includes the `session_token`, as in the payment flow:

```json Response (abbreviated) theme={null}
{
  "id": "cs_test_a1b2c3d4e5f6g7h8i9j0",
  "object": "checkout_session",
  "flow": "setup",
  "status": "created",
  "session_token": "cs_test_a1b2c3d4e5f6g7h8i9j0_token_k1l2m3n4o5p6q7r8s9t0"
}
```

Pass only that token to your frontend. A setup session has no `amount`. With `ui_mode: "fields"`, you don't need `success_url` or `cancel_url` because your customer stays on your page.

You don't need `save_payment_method: "enabled"`: the `setup` flow saves the card without a payment. You can apply the same `payment_method_options.card.kinds` restriction described above. `bins` doesn't apply to the `setup` flow.

#### Collect and save the card

[Load the secure fields](#load-the-secure-fields) with the setup session's `session_token` and your Public Key. Use the same containers and `Fintoc.create` configuration as in the payment flow, but label your button **Save card**. Ask your customer for consent before saving the card.

`onChange` works as in the payment flow.

When your customer clicks **Save card**, submit the card with `cardFields.submit()`. Send `holderName` and, optionally, `holderTaxId`, as in the payment flow, without `installments` or `savePaymentMethod`:

**Client**

```javascript checkout.js theme={null}
const { status, card, error } = await cardFields.submit({
  holderName,
  holderTaxId: { type: 'cl_rut', value: '11.111.111-1' },
});

if (status === 'error') {
  // Show error.message and let your customer correct the fields
}
```

When Fintoc saves the card, the call returns `status: "ready"` with the saved `card`. In the setup flow, `ready` means Fintoc already saved the card. Unlike the payment flow, setup doesn't require 3DS or a backend call to confirm the Checkout Session. If the submission fails, show `error.message` and let your customer retry.

#### Store the saved Payment Method

Handle `payment_method.activated` on your backend to know when the card is available for charges. Store the Payment Method ID with the corresponding `customer`. The Checkout Session also includes the saved ID in `payment_method`, available when you [get the session](https://docs.fintoc.com/api/payments-api/checkout-sessions/checkout-sessions-get.md) or receive `checkout_session.finished`.

Handle `checkout_session.expired` by letting your customer start a new setup session. Don't wait for `payment_intent.succeeded`: setup doesn't process a payment. To charge the card later, follow [Pay with a saved card](#pay-with-a-saved-card).

## Pay with a saved card

To charge a saved card while the customer is on your page, your backend creates a Payment Intent. The customer doesn't type card data, so you don't load the secure fields or create a Checkout Session.

> [!NOTE]
>
> Paying with a saved card while the customer is present (`off_session: false`) is available for `CLP` payments of organizations in Chile. You can include a `split` array. Fintoc validates the array before charging the card, with the same rules and error codes as a [split Payment Intent](https://docs.fintoc.com/guides/payments/accept-a-payment/accept-split-payments.md#split-a-payment-intent-created-by-api). If your organization can't charge saved cards with the customer present, creating the Payment Intent returns `403 Forbidden`.

### List the customer's saved cards

Use `GET /v2/payment_methods` with the `customer` and `payment_options[off_session]=false` query parameters. With `payment_options[off_session]=false`, the list includes only the customer's active cards that you can charge while the customer is present. The list leaves out cards saved from a wallet and all payment methods that aren't cards. If your organization can't charge saved cards with the customer present, the list is empty.

The following response example uses the documented [Payment Method object](https://docs.fintoc.com/api/payments-api/payment-methods/payment-method-object.md#the-card-object). Display the card's `brand`, `last_four_digits`, and `expiration` in your interface:

**Server**

```bash List saved cards theme={null}
curl -G "https://api.fintoc.com/v2/payment_methods" \
  -H "Authorization: YOUR_TEST_SECRET_KEY" \
  --data-urlencode "customer=cus_456789abcdef" \
  --data-urlencode "payment_options[off_session]=false"
```

```json Saved cards response theme={null}
[
  {
    "id": "pm_test_a1b2c3d4e5f6g7h8i9j0",
    "object": "payment_method",
    "card": {
      "active": true,
      "brand": "visa",
      "country": "Chile",
      "expiration": {
        "month": "12",
        "year": "2030"
      },
      "kind": "credit",
      "last_four_digits": "1111",
      "wallet": null
    },
    "created_at": "2026-10-28T18:30:00Z",
    "customer": "cus_456789abcdef",
    "mode": "test",
    "type": "card"
  }
]
```

### Get the available installments

When the customer chooses a saved card, get its available installments for the amount to charge. You don't have the card's BIN, so Fintoc calculates them from the Payment Method.

**Server**

```bash Get installments theme={null}
curl "https://api.fintoc.com/v2/payment_methods/pm_test_a1b2c3d4e5f6g7h8i9j0/installments?amount=26677&currency=CLP" \
  -H "Authorization: YOUR_TEST_SECRET_KEY"
```

```json Installments response theme={null}
{
  "available_installments": [3, 6, 12]
}
```

`amount` must be a positive integer in the smallest currency unit, and `currency` must be `CLP`. The `available_installments` array is empty for debit and prepaid cards, and for cards issued outside Chile. If the Payment Method isn't a card, or the card is canceled, inactive, or has no network token, Fintoc responds with `422 Unprocessable Entity` and the `invalid_payment_method_state` error code. See [Get the installments of a payment method](https://docs.fintoc.com/api/payments-api/payment-methods/payment-methods-installments.md).

If the installments lookup fails, Fintoc responds with `503 Service Unavailable` and the `installments_temporarily_unavailable` error code. Retry the request. An empty `available_installments` array means the customer pays in a single installment.

### Create the Payment Intent

[Create a Payment Intent](https://docs.fintoc.com/api/payments-api/payment-intents/payment-intents-create.md) with the saved Payment Method ID in `payment_method`. Set `off_session` to `false` to indicate that the customer is on your page and chose the card, and set `payment_method_options.card.installments` to the number of installments.

`payment_method_options` is optional: without it, Fintoc charges the card in a single installment. To charge more than one installment, the number must be one of the card's `available_installments`; otherwise, Fintoc responds with `400 Bad Request`. If you omit `off_session` or set it to `true`, Fintoc charges the Payment Method without the customer present, as with any other saved payment method. In that case, if you send `payment_method_options`, Fintoc responds with `400 Bad Request`.

If you charge more than one installment and the installments lookup fails while creating the Payment Intent, Fintoc responds with `503 Service Unavailable` and the `installments_temporarily_unavailable` error code. Fintoc doesn't create the Payment Intent. Retry the request with a new [`Idempotency-Key`](https://docs.fintoc.com/api/fintoc-api/idempotent-requests). A retry with the same key returns the stored `503` response for 24 hours.

If the card provider is unavailable when Fintoc reads the saved card, Fintoc responds with `503 Service Unavailable` and `error.code` set to `provider_unavailable`. Fintoc doesn't create the Payment Intent. Retry the request with a new `Idempotency-Key` or without one. A retry with the same key returns the stored `503` response for 24 hours.

If the saved card is canceled, Fintoc responds with `422 Unprocessable Entity` and `error.code` set to `payment_method_canceled`. If the card is inactive, Fintoc responds with `422 Unprocessable Entity` and `error.code` set to `payment_method_inactive`. These are the same error codes as a charge without the customer present. With `off_session` set to `false`, Fintoc doesn't create the Payment Intent. Ask your customer to choose another card or pay with new card details.

**Server**

```bash Create Payment Intent theme={null}
curl -X POST https://api.fintoc.com/v2/payment_intents \
  -H "Authorization: YOUR_TEST_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 26677,
    "currency": "CLP",
    "payment_method": "pm_test_a1b2c3d4e5f6g7h8i9j0",
    "off_session": false,
    "payment_method_options": {
      "card": {
        "installments": 3
      }
    }
  }'
```

Response (abbreviated):

```json Response theme={null}
{
  "id": "pi_test_a1b2c3d4e5f6g7h8i9j0",
  "object": "payment_intent",
  "amount": 26677,
  "currency": "CLP",
  "next_action": {
    "type": "card_authentication",
    "expires_at": "2026-10-28T18:40:00Z"
  },
  "payment_type": "card",
  "status": "requires_action",
  "widget_token": "pi_test_a1b2c3d4e5f6g7h8i9j0_sec_k1l2m3n4o5p6q7r8s9t0"
}
```

Fintoc responds with `201 Created`. If the payment requires 3DS authentication, the Payment Intent has the `requires_action` status, a `widget_token`, and a `next_action` of type `card_authentication`. Fintoc charges the card only after your page completes the authentication, so always handle `requires_action`. The `widget_token` is only returned in this response.

### Handle the 3DS authentication

Your backend passes the `widget_token` to your page. Your page loads Fintoc.js and calls `Fintoc.handleNextAction()` with your Public Key and the token:

**Client**

```html checkout.html theme={null}
<script src="https://js.fintoc.com/v1/"></script>
```

```javascript checkout.js theme={null}
const { status, error } = await Fintoc.handleNextAction({
  publicKey: 'YOUR_TEST_PUBLIC_KEY',
  widgetToken: 'pi_test_a1b2c3d4e5f6g7h8i9j0_sec_k1l2m3n4o5p6q7r8s9t0',
});
```

If the issuer requires a challenge, Fintoc shows it in a modal. Keep your loading state until the promise resolves. The promise resolves with `{ status: 'succeeded' }` or with `{ status: 'error', error: { code, message } }`, and never throws an exception. To update the order, use the `payment_intent.succeeded`, `payment_intent.failed`, and `payment_intent.expired` webhooks.

If your page sets a Content Security Policy, it needs the same domains as the secure fields. See [Content Security Policy](#content-security-policy).

## Show more than one card form

You can show more than one card form on the same page. Each form has its own Checkout Session, its own containers, and its own `Fintoc.create` call. The card number field only collects the data of its own form.

* **Discounts for some cards**: you can't change the `amount` of a Checkout Session. If you offer a discount for some cards, for example, the cards of one bank, show a separate form for them. Create its Checkout Session from the start with the discounted `amount` and `payment_method_options.card.bins`, so Fintoc rejects other cards in that form.
* **Credit and debit cards in separate forms**: create two Checkout Sessions, one with `kinds: ["credit"]` and the other with `kinds: ["debit"]`. If the customer types a debit card in the credit form, the card number field returns an error.
* **Card and bank transfer**: create a separate Checkout Session with `payment_method_types: ["bank_transfer"]` and open it in the [Fintoc Widget](https://docs.fintoc.com/guides/resources/widget/web-integration.md) with `Fintoc.create`. You can create that session when the customer chooses bank transfer, so you don't leave unused sessions.

## States, webhooks, and errors

> [!WARNING]
>
> Treat the order as paid only when the `payment_intent.succeeded` webhook arrives.

For a payment, the Checkout Session moves from `created` to `in_progress` when the customer submits a card, and to `finished` when the related Payment Intent reaches a final state. For setup, the Checkout Session finishes when the card setup completes, without a payment. The Checkout Session moves to `expired` if `expires_at` is reached before the customer submits a card.

Handle Payment Intent states as follows:

| State | Meaning | Action |
| - | - | - |
| `in_progress` | Processing | Wait for the webhook |
| `requires_action` | Waiting for 3DS authentication of a saved card | Call `Fintoc.handleNextAction()` |
| `succeeded` | Paid | Fulfill the order |
| `failed` | Declined (see `error.code`) | Show the error to the customer |
| `expired` | Authentication expired | Create a new Payment Intent |

**[Webhooks](https://docs.fintoc.com/api/main-resources/webhook-endpoints/webhook-endpoints-object.md):** `checkout_session.finished`, `checkout_session.expired`, `payment_intent.succeeded`, `payment_intent.failed`, `payment_intent.expired`, `payment_method.activated`.

**Common errors** (in `error.code`):

| Code | Cause |
| - | - |
| `card_declined` | The issuer declined the card |
| `insufficient_funds` | Insufficient balance or credit |
| `card_kind_not_permitted` | The card's kind is not in `payment_method_options.card.kinds` |
| `card_bin_not_permitted` | The card's BIN is not in `payment_method_options.card.bins` |
| `authentication_failed` | 3DS was not completed |

## Customization and security

### Appearance

The fields look like the rest of your form:

* **Container**: you style the border, background, and label of each field with your own CSS on its container. Fintoc adds the `fintoc-focus`, `fintoc-empty`, `fintoc-invalid`, and `fintoc-complete` classes to the container according to the field's state. An empty field isn't invalid: use `fintoc-empty` to decide whether to mark it.
* **Text inside the field**: configure it with `cardFields.style` when you call `Fintoc.create`. `style.base` applies to the input text in every state. `style.placeholder` applies to the placeholder, and `style.invalid` applies to the text of an invalid value. `placeholder` and `invalid` replace only the `base` properties they set. Each variant accepts `color`, `fontSize`, `fontWeight`, `letterSpacing`, `lineHeight`, and `textAlign`. `base` also accepts `fontFamily` with the name of a Google Fonts family. Fintoc ignores any other property.

You control the labels, error messages, and layout; the iframes only render the input.

### Content Security Policy

If your page sets a Content Security Policy (CSP), add Fintoc's domains to it:

| Directive | Source |
| - | - |
| `script-src` | `https://js.fintoc.com` |
| `frame-src` | `https://wizard.fintoc.com` |

The secure fields and the 3DS modal are iframes served from `wizard.fintoc.com`. The issuer's page loads inside the modal's iframe, so you don't add the issuer's domains. The modal doesn't need `style-src 'unsafe-inline'`. If your page doesn't set a CSP, you don't need to configure anything.

### Mobile apps

Checkout Fields works the same way on a web page inside a webview.

## Test the integration

Use your test Public Key and Secret Key in this guide's examples. Use the [published card payment test data](https://docs.fintoc.com/guides/payments/payment-initiation-test-your-integration.md#card-payments) instead of real card data. Start with these Chilean card scenarios:

| Scenario | Card number | Expiration date | CVV | Cardholder name | Expected result |
| - | - | - | - | - | - |
| Successful payment | `4111111111111111` | Any future date | Any | Any | `payment_intent.succeeded` |
| Declined payment | `4349003000047015` | Any future date | Any | Any | The payment is declined. |
| Successful payment that saves the card, with `savePaymentMethod: true` | `5120342233150747` | Any future date | Any | Any | `payment_intent.succeeded` and `payment_method.activated` |

Verify the following outcomes with the flow described above:

1. Create a Checkout Session with `ui_mode: "fields"` and check that you receive the `session_token`.
2. Load the secure fields and type a test card. Check that `onChange` returns `complete: true` for the three fields.
3. Submit the test data. Check that your frontend receives `status: "ready"` without receiving card data.
4. Confirm the Checkout Session from your backend. For a successful payment, verify that you receive `payment_intent.succeeded` before treating the order as paid.

To test saving a card without a payment, create a session with `flow: "setup"` and submit a test card. Verify that you receive `payment_method.activated` and `checkout_session.finished`, and store the session's `payment_method`. Don't call the confirm endpoint or expect a payment webhook for this flow.

To test saving a card during a payment, create the session with `save_payment_method: "enabled"` and a `customer`, submit `5120342233150747` with `savePaymentMethod: true`, and confirm the Checkout Session. Verify that you receive `payment_method.activated` and that the confirm response includes `payment_method`. With `4000080000000004`, the payment succeeds without saving the card, matching the outcome when Fintoc can't prepare the card.

To test paying with a saved card, list the customer's cards with `payment_options[off_session]=false`, get the available installments for one of them, and create the Payment Intent with `off_session: false`. If the response has the `requires_action` status, call `Fintoc.handleNextAction()` with the `widget_token` from the response. Verify that you receive `payment_intent.succeeded`.

> [!NOTE]
>
> Find the sandbox test data and expected results in [Test your integration: card payments](https://docs.fintoc.com/guides/payments/payment-initiation-test-your-integration.md#card-payments).
