Menu
Guides
API Reference

Guides

Setting up the type of interest rate

Learn how to define the interest calculation method of a payment condition with the Payments Gateway API, including the simple interest with tax option, which is unavailable in the VTEX Admin.

5 min read

When a payment condition allows installments with interest, the VTEX Payment Gateway uses the interestRateMethod field to calculate the amount of each installment. This field belongs to the installmentOptions object of the payment condition, which the Payments Gateway API refers to as a rule.

The field accepts the following values:

ValueInterest calculationAvailable in the VTEX Admin
null or 0Compound interest, levied on the order total and on the interest accumulated between installments. This is the default value.Yes
1Simple interest with tax, levied on the order total and combined with the interest tax defined for each installment in interestTax.No
2Simple interest, levied only on the order total.Yes

Compound interest is the most common model in Brazil, while countries such as Argentina prefer simple interest. For a comparison between both models, see How to choose the type of interest for a payment condition.

When using simple interest with tax (1), set the interestTax value for each installment in the installmentOptions.installments array. This guide covers changing the interestRateMethod field; include the desired interestTax values in the same payment rule request.

The interest type selector in the VTEX Admin offers only compound interest (0) and simple interest (2). To set either of these values, follow How to choose the type of interest for a payment condition. Use the following steps to set simple interest with tax (1), which is only available through the API.

Before you begin

To complete the steps in this guide, you need the following:

EndpointProductCategoryResource
Get payment rule by IDPCI GatewayPayment-Make PaymentsView Payment Data
Update payment rule by IDPCI GatewayPayment-ManageStoreManage Store

No predefined role grants these resources. Create a custom role with the resources in the preceding table, and follow the best practices for managing API keys to avoid granting excessive permissions.

Step 1: Get the payment condition ID

  1. In the VTEX Admin, go to Store Settings > Payment > Settings, or type Settings in the search bar at the top of the page.
  2. Click the Payment Conditions tab.
  3. Select the payment condition you want to configure.
  4. Copy the last parameter of the page URL, which is the ID of the payment condition, as shown in the following image.

{"base64":"  ","img":{"width":1993,"height":825,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":175340,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/setting-up-the-type-of-interest-rate-0.png"}}

This value corresponds to the ruleId path parameter in the following requests.

The ruleId identifies the payment condition, not the payment method. A payment method such as Visa can have several payment conditions, each with its own ruleId and interest settings. Setting the interest rate type affects only the payment condition you send in the request.

Step 2: Retrieve the payment condition

Send a Get payment rule by ID request to retrieve the current configuration of the payment condition:


_10
curl --request GET \
_10
--url https://{accountName}.vtexpayments.com.br/api/pvt/rules/{ruleId} \
_10
--header 'Accept: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}'

Replace {accountName} with your account name, {ruleId} with the ID from the previous step, and {appKey} and {appToken} with your API key credentials.

A successful request returns the status code 200 OK and the complete payment condition. The interest settings are inside the installmentOptions object. The following excerpt shows the relevant fields from the response:


_17
{
_17
"installmentOptions": {
_17
"dueDateType": 0,
_17
"interestRateMethod": null,
_17
"minimumInstallmentValue": 400,
_17
"installments": [
_17
{
_17
"ruleId": null,
_17
"quantity": 12,
_17
"value": 0,
_17
"interestRate": 25,
_17
"isExternalInstallmentService": null,
_17
"interestTax": 5
_17
}
_17
]
_17
}
_17
}

Save the entire response body, including the other payment condition fields, as you need it to build the request in the next step.

Step 3: Set the interest rate type

Send an Update payment rule by ID request using the response from the previous step as the request body, changing only the value of interestRateMethod:


_56
curl --request PUT \
_56
--url https://{accountName}.vtexpayments.com.br/api/pvt/rules/{ruleId} \
_56
--header 'Accept: application/json' \
_56
--header 'Content-Type: application/json' \
_56
--header 'X-VTEX-API-AppKey: {appKey}' \
_56
--header 'X-VTEX-API-AppToken: {appToken}' \
_56
--data '{
_56
"id": "c997267e-39bf-4217-a890-a503f6a7dc47",
_56
"name": "Visa 12 installments with interest",
_56
"salesChannels": [
_56
{
_56
"id": "1"
_56
}
_56
],
_56
"paymentSystem": {
_56
"id": 8,
_56
"name": "Visa",
_56
"implementation": null
_56
},
_56
"connector": {
_56
"implementation": "Vtex.PaymentGateway.Connectors.CieloV3Connector",
_56
"affiliationId": "0a8488e6-0c30-4150-be96-b0dcaaa6a0cd"
_56
},
_56
"issuer": null,
_56
"antifraud": null,
_56
"installmentOptions": {
_56
"dueDateType": 0,
_56
"interestRateMethod": 1,
_56
"minimumInstallmentValue": 400,
_56
"installments": [
_56
{
_56
"ruleId": null,
_56
"quantity": 12,
_56
"value": 0,
_56
"interestRate": 25,
_56
"isExternalInstallmentService": null,
_56
"interestTax": 0
_56
}
_56
]
_56
},
_56
"isSelfAuthorized": null,
_56
"requiresAuthentication": null,
_56
"enabled": true,
_56
"installmentsService": false,
_56
"isDefault": null,
_56
"condition": null,
_56
"multiMerchantList": [],
_56
"country": {
_56
"name": null,
_56
"isoCode": "br"
_56
},
_56
"externalInterest": false,
_56
"minimumValue": null,
_56
"deadlines": [],
_56
"excludedBinsRanges": null
_56
}'

This request replaces the entire payment condition. Any field omitted from the request body is overwritten with its default value, which can disable the payment condition or remove its installment settings. Always build the request body from the response you retrieved in the previous step, rather than from the preceding example.

A successful request returns the status code 200 OK and the updated payment condition.

Step 4: Check the configuration

  1. Send a new Get payment rule by ID request and confirm that interestRateMethod returns the expected value.
  2. Place a test order in your store and confirm that the installment amounts displayed at checkout match the interest model you configured.

The interest type selector in the VTEX Admin doesn't display simple interest with tax, and it hides the option to change the interest type when the payment condition uses this value. If you edit and save this payment condition in the VTEX Admin, check interestRateMethod again with Get payment rule by ID and repeat step 3 if the value changed.