Card-on-File (CoF) & Recurring Payments API Guide
Basic information about using the Payrix Pro API for card-on-file payments.
When storing a payment method for subsequent recurring transactions it is important to properly identify the transaction both with the appropriate cofType
field and the original authorized transaction within the firstTxns
field within the txns request.
In this resource, we outline best practices for the following Recurring Transaction use cases:
New CoF (Card-on-File)
Existing CoF (Card-on-File)
Imported CoF (Card-on-File)
Failure to submit both values will not identify the transaction as recurring with the Processor and increase the Risk of any subsequent recurring transaction with the token being rejected by the issuer.
Terms:
cofType
is a parameter used to validate the type of Card On File transaction when using a token.firstTxn
is a parameter used to identify the first transaction processed through a subscription and used again to process subsequent transactions.
cofType
and firstTxns
fields are for CoF & recurring card payments only. You should skip these fields when saving an eCheck payment method.
New Card on File Setup
This page outlines the necessary endpoints for creating a new "Card on File" for future transactions.
Use the Tokens endpoint to create a token for storing payment information.
Create a Plan to define the schedule for recurring or installment payments.
Establish a Subscription to link customers to the created plan for charging.
Utilize SubscriptionTokens to connect tokens with subscriptions for payment processing.
Create a Token
First, you’ll need to create a payment token with the customer’s payment information.
This particular step covers the use case of creating a brand new customer and token without a previous transaction.
To create a token while processing a card payment transaction, see Tokenization & Recurring Payments.
New Token Request
Build the body of the POST /tokens
request:
{
"customer": {
"first": "John",
"last": "Doe",
"zip": "22222"
},
"payment": {
"number": "4242424242424242",
"cvv": "123"
},
"expiration": "1025"
}
Parameter | Type | Required | Description | Notes | |
---|---|---|---|---|---|
| object | Required | The customer object that assigns the customer to the payment method being tokenized. | These object parameters are only required for this use case. | |
| string | Required | The customer’s first name. | ||
| string | Required | The customer’s last name. | ||
| string | Required | The customer’s billing zip code. | 5-10 characters max. | |
| object | Required | The customer’s payment information. | ||
| string | Required | The credit card number | ||
| string | Required | The 3 or 4-digit card verification value as shown on the card. | 3-4 characters max. | |
| string | Required | The 4-digit month & year expiration as shown on the card. |
|
New Token Response
After successfully submitting the POST /tokens request, you’ll receive a response from the Payrix Pro API. See the example below:
{
"customer": {
"id": "t1_cus_123abc4d567890efg1h2i34",
"created": "2024-11-11 12:04:35.0792",
"modified": "2024-11-11 12:04:35.0792",
"creator": "t1_log_123abc4d567890efg1h2i34",
"modifier": "t1_log_123abc4d567890efg1h2i34",
"login": "t1_log_123abc4d567890efg1h2i34",
"merchant": null,
"first": "John",
"middle": null,
"last": "Doe",
"company": null,
"email": null,
"fax": null,
"phone": null,
"country": null,
"zip": "11111",
"state": null,
"city": null,
"address2": null,
"address1": null,
"inactive": 0,
"frozen": 0,
"shippingFirst": null,
"shippingMiddle": null,
"shippingLast": null,
"shippingCompany": null,
"shippingAddress1": null,
"shippingAddress2": null,
"shippingCity": null,
"shippingState": null,
"shippingZip": null,
"shippingCountry": null,
"shippingPhone": null,
"shippingFax": null,
"custom": null,
"authTokenCustomer": null,
"entity": null
},
"payment": {
"id": "t1_pmt_123abc4d567890efg1h2i34",
"method": 5,
"number": "0000",
"routing": "0",
"bin": "601100",
"payment": null,
"lastChecked": null,
"last4": null,
"mask": null,
"plaidConsumerAccount": null
},
"id": "t1_tok_123abc4d567890efg1h2i34",
"created": "2024-11-11 12:04:35.1111",
"modified": "2024-11-11 12:04:35.1111",
"creator": "t1_log_123abc4d567890efg1h2i34",
"modifier": "t1_log_123abc4d567890efg1h2i34",
"token": "a12bc3d4e56f789g0h1ij23kl456789",
"expiration": "1025",
"inactive": 0,
"frozen": 0,
"name": null,
"description": null,
"custom": null,
"authTokenCustomer": null,
"status": "ready",
"origin": null,
"entryMode": null,
"omnitoken": null
}
Now you’re ready to move on to creating the plan, which you can use to configure the details for subscription payments, installment payments of a larger purchase, or some other form of recurring payment structure between Merchants and customers.
Set Up a Plan
After you've generated your token, the next step is to set up a plan. This will allow you to create a subscription, where the customer's tokenized payment method will be assigned as a subscription token.
New Plan Request
Build the body of the POST /plans
request:
{
"name": "Recurring Payment Plan",
"amount": "5000",
"merchant": "t1_mer_123abc4d567890efg1h2i34",
"schedule": "3",
"scheduleFactor": "1",
"um": "actual",
"type": "recurring",
"inactive": "0",
"frozen": "0"
}
Parameter | Type | Required | Description | Notes & Valid Values |
---|---|---|---|---|
| string | Optional | ||
| integer | Required | The amount charged in each payment of this plan. | This value is represented as an integer in cents or as a percentage depending on the Example: |
| ID | Required | The ID of the Merchant associated with the customer and plan. | |
| string | Required | The measurement of the time interval associated with the | Valid Values:
|
| integer | Required | The numerical value of the | Example If the |
| string | Required | The unit of measurement for the | actual - Dollar amount percent -
|
| string | Required | Valid Values:
| |
| boolean | Required | ||
| boolean | Required |
New Plan Response
After successfully submitting the POST /tokens
request, you’ll receive a response from the Payrix Pro API. See the example below:
{
"id": "t1_pln_123abc4d567890efg1h2i34",
"created": "2024-11-11 12:34:49.2953",
"modified": "2024-11-11 12:34:49.2953",
"creator": "t1_log_123abc4d567890efg1h2i34",
"modifier": "t1_log_123abc4d567890efg1h2i34",
"merchant": "t1_mer_123abc4d567890efg1h2i34",
"name": "Recurring Payment Plan",
"description": null,
"schedule": "3",
"scheduleFactor": 1,
"amount": 5000,
"inactive": "0",
"frozen": "0",
"maxFailures": null,
"type": "recurring",
"txnDescription": null,
"order": null,
"billing": null,
"um": "actual"
}
Create a Subscription
Once you’ve set up a plan, you’ll need to create a new subscription so the payment method you’ve saved as a token (the “card on file”) can be assigned to the payment plan.
New Subscription Request
Build the POST /subscriptions
request body:
{
"failures": "2",
"origin": "2",
"plan": "t1_pln_123abc4d567890efg1h2i34",
"start": "20241112",
"inactive": "0",
"frozen": "0"
}
Parameter | Type | Required | Description | Notes & Valid Values |
---|---|---|---|---|
| integer | Required | The number of failures before the subscription stops attempting to charge the payment method. | |
| integer | Required | The origin of the transaction that will be generated through this subscription. | Valid Values:
|
| ID | Required | The ID of the plan that includes the specified payment amount and schedule. | |
| integer | Required | The date when the Subscription is set to start. | The date must be an 8-digit string in the format Example: Note: The value must represent a future date. |
| boolean | Required | ||
| boolean | Required |
New Subscription Response
After successfully submitting the POST /subscriptions
request, you’ll receive a response from the Payrix Pro API. See the example below:
{
"id": "t1_sbn_673286abaa76c43fa9957df",
"created": "2024-11-11 17:35:23.7174",
"modified": "2024-11-11 17:35:23.7174",
"creator": "t1_log_617b1b16317575170b3c711",
"modifier": "t1_log_617b1b16317575170b3c711",
"plan": "t1_pln_6732403946724480017e1db",
"start": "20241112",
"finish": null,
"tax": null,
"descriptor": null,
"inactive": "0",
"frozen": "0",
"failures": 2,
"maxFailures": null,
"origin": "2",
"firstTxn": null,
"txnDescription": null,
"order": null,
"authentication": null,
"authenticationId": null,
"statementEntity": null
}
New Card on File Setup
When creating a new token for recurring billing both AVS & CVV data should be submitted within the initial transaction request.
Existing Card on File Usage
Existing token transactions submitted with a cofType
of “scheduled” should have an initial transaction submitted within the firstTxn
field. If this information is not available then a new “initial” transaction that is only identified as eCommerce (submitted without cofType
) should be submitted using a $0.00 Auth.
To increase the chance of subsequent transactions processing AVS data (if available) should be provided on the txn request (unless stored on the token.customer
record).
3. Imported CoF
When a transaction is imported from another Processor they do not send over the initial transaction. For this reason, even when a recurring transaction is imported a new initial transaction should be performed on the Payrix Pro platform. After receiving the token import file an initial $0.00 Auth transaction should be submitted with each token without the cofType
field. Then all subsequent transactions with the token should submit the initial transaction ID within the firstTxn
field in addition to the cofType
field.
Any recurring transaction submitted that has an initial authorization without AVS/CVV is susceptible to being declined by the issuer. In these instances the partner will need to reachout to the cardholder to obtain this information and go through the process of a New CoF.