# Card-on-File (COF) transactions

> In this page, you can learn about what "COF" is and how to enable it.

COF (Card-on-File) refers to a card that the buyer has previously used for payment and stored at the merchant's site during a transaction. With the buyer’s authorization, you can either store the card information yourself or have Antom store it on your behalf. When your buyer makes a payment using the stored card information, it is strongly recommended that you mark the transaction as a stored card payment in the request. Using stored card payments can effectively reduce the decline rate from card schemes and issuing banks, and improve the payment success rate. This article introduces how to enable COF.

#### Tab: Payment Element integration

## How to enable

When the buyer initiates a payment using a stored card, you need to set _availablePaymentMethod.paymentMethodMetaData.isCardOnFile_ to `true` in the [**createPaymentSession (One-time Payments)**](https://docs.antom.com/ac/ams/session_cashier.md) API to identify the transaction as a stored card payment.

The following is a sample code for initiating a subsequent transaction where the card information is stored by Antom, and the _cardToken_ information provided by Antom is used:

```json
{
  ...
    "availablePaymentMethod": {
        "paymentMethodMetaData": {
            "isCardOnFile": true
        }
    },
  "savedPaymentMethods": [
        {
            "paymentMethodType": "CARD",
            "paymentMethodId": "ALIPAYEfG2DFbGx2Eh739qU+VMnCPEe7MfRKfMfC5k7k/IFASWpAh/vCxHV3dPYpbkGz1iyWCloE4MwfmN48sP8+rSPQ=="
        }
    ]
  ...
}
```

#### Tab: Hosted card integration

## How to enable

When the buyer initiates a payment using a stored card, you need to set _paymentMethod.paymentMethodMetaData.isCardOnFile_ to `true` in the [**pay (One-time Payments)**](https://docs.antom.com/ac/ams/payment_cashier.md) API to identify the transaction as a stored card payment.

The following is a sample code for initiating a subsequent transaction where the card information is stored by Antom, and the _cardToken_ information provided by Antom is used:

```json
"paymentMethod":
    {
        "paymentMethodMetaData":
        {
            "isCardOnFile": true
        },
        "paymentMethodType": "CARD",
        "paymentMethodId": "ALIPAYgzViZ*********RWZIU31kU+2avs5dAgkzss/NrTymfnc/0+xI0ssHmyU3VyWCloE4MwfmN48sP1+rSPQ=="
    }
```

#### Tab: Server-to-server card integration

## How to enable

When the buyer initiates a payment using a stored card, you need to set _paymentMethod.paymentMethodMetaData.isCardOnFile_ to `true` in the [**pay (One-time Payments)**](https://docs.antom.com/ac/ams/payment_cashier.md) API to identify the transaction as a stored card payment.

### Antom stores card information Recommended

It is recommended that you let Antom store the card information on your behalf, and use the _cardToken_ information provided by Antom to initiate subsequent transactions. Data shows that using card information stored by Antom and initiating subsequent transactions with a token results in a significantly higher success rate compared to storing card information yourself.

The following is a sample code for initiating a subsequent transaction using the _cardToken_ information provided by Antom:

```json
"paymentMethod":
    {
        "paymentMethodMetaData":
        {
            "isCardOnFile": true
        },
        "paymentMethodType": "CARD",
        "paymentMethodId": "AL****************PQ=="
    }
```

### Manually store card information

If you choose to store the card information yourself, you need to specify the _cardNo_, _expiryYear_, _expiryMonth_, _cardholderName_, and _isCardOnFile_ parameters in subsequent transactions. Note that _cvv_ is not required in subsequent transactions.

The following is a sample code for initiating a subsequent transaction using the card information stored by yourself:

```json
"paymentMethod":
    {
        "paymentMethodMetaData":
        {
            "cardholderName":
            {
                "firstName": "Tom",
                "lastName": "Jerry"
            },
            "expiryMonth": "11",
            "expiryYear": "28",
            "cardNo": "41************54",
            "isCardOnFile": true
        },
        "paymentMethodType": "CARD"
    },
```

#### Tab: Checkout Page (CKP) integration

## How to enable

When the buyer initiates a payment using a stored card, you need to set _availablePaymentMethod.paymentMethodMetaData.isCardOnFile_ to `true` in the [**createPaymentSession (One-time Payments)**](https://docs.antom.com/ac/ams/session_cashier.md) API to identify the transaction as a stored card payment.

The following is a sample code for initiating a subsequent transaction where the card information is stored by Antom, and the _cardToken_ information provided by Antom is used:

```json
{
  ...
    "availablePaymentMethod": {
        "paymentMethodMetaData": {
            "isCardOnFile": true
        }
    },
  "savedPaymentMethods": [
        {
            "paymentMethodType": "CARD",
            "paymentMethodId": "ALIPAYEfG2DFbGx2Eh739qU+VMnCPEe7MfRKfMfC5k7k/IFASWpAh/vCxHV3dPYpbkGz1iyWCloE4MwfmN48sP8+rSPQ=="
        }
    ]
  ...
}
```

> **Note**: In COF (Card-on-File) transactions, the payment may fail if the buyer’s card has expired. In such cases, Antom will return the error code `INVALID_EXPIRATION_DATE`. We recommend guiding the buyer to bind the card again to update the card information.