Accepting payments
Create charges with PIX, bank billet or credit card and follow them until they are paid.
On this page
Charges are created with the Create charge endpoint. A charge creates an order with its items and starts the payment with the method you choose.
| Payment method | method value |
How it works |
|---|---|---|
| PIX | pix |
Created directly with the payment data of the request. |
| Bank billet | bank-billet |
Created directly with the payment data of the request. |
| Credit card | credit-card |
The card data is encrypted with the Easyflow JavaScript SDK before the charge is created. |
Anatomy of a charge
The request body has three required fields:
| Field | Description |
|---|---|
businessId |
Identifier of the business that receives the payment. |
items |
Products being sold. Each item requires name, description, quantity and priceInCents. |
payments |
How the order is paid. Each payment requires method, numberInstallments and valueInCents. |
You can also send the buyer, shipping details and your own metadata. When the buyer is already registered as a customer, send only buyer.customerId instead of the other buyer details.
PIX
{
"businessId": "YOUR_BUSINESS_ID",
"buyer": {
"name": "Maria Silva",
"email": "maria@example.com",
"document": { "type": "CPF", "number": "12345678909" }
},
"items": [
{
"name": "Premium plan",
"description": "Monthly subscription to the premium plan",
"quantity": 1,
"priceInCents": 4990
}
],
"payments": [
{
"method": "pix",
"numberInstallments": 1,
"valueInCents": 4990,
"pix": { "expirationInMinutes": 30 }
}
]
}pix.expirationInMinutes sets how long the PIX code can be paid.
Bank billet
Use the bank-billet method and, optionally, the number of days until the billet expires:
{
"method": "bank-billet",
"numberInstallments": 1,
"valueInCents": 4990,
"bankBillet": { "expirationInDays": 3 }
}When you pay with a bank billet and identify the buyer with
buyer.customerId, the customer must have an address registered. Otherwise the order is canceled.
Credit card
Card data never goes to your server in plain text. The flow has three steps:
- Retrieve the installment options for the amount with Get installment options.
- Encrypt the card data in the browser with the Easyflow JavaScript SDK.
- Create the charge sending the encrypted token in
payments[].creditCard.token.
1. Get the installment options
curl --request GET \
--url 'https://9iq81tsdy4.execute-api.sa-east-1.amazonaws.com/orders/installment-options?amountToBePaidInCents=5000' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-api-secret: YOUR_API_SECRET' \
--header 'business-id: YOUR_BUSINESS_ID'Each option shows the number of installments, the value of each installment, the interest, the total and the fees that the buyer pays. A fee paid by the buyer is a fixed value in cents plus a percentage of the amount, and the fixed value is added to the total. The interest is calculated on orderValueInCents, which already includes these fees.
The values below are illustrative. They assume a business with a fee paid by the buyer of 99 cents plus 2% in every option: on 5000, the fee is 99 + 100 = 199, so orderValueInCents is 5199.
{
"data": {
"options": [
{ "installments": 1, "parcelValueInCents": 5199, "totalInterestInCents": 0, "totalValueInCents": 5199, "orderValueInCents": 5199, "totalBuyerPaymentTaxValueInCents": 199 },
{ "installments": 2, "parcelValueInCents": 2697, "totalInterestInCents": 195, "totalValueInCents": 5394, "orderValueInCents": 5199, "totalBuyerPaymentTaxValueInCents": 199 },
{ "installments": 3, "parcelValueInCents": 1820, "totalInterestInCents": 261, "totalValueInCents": 5460, "orderValueInCents": 5199, "totalBuyerPaymentTaxValueInCents": 199 }
]
}
}2. Encrypt the card
Load the SDK on your checkout page, configure it with your business identifier and encrypt the card data. Replace your-business-id with the identifier of your business, which contains only letters, numbers and hyphens:
<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>window.easyflowSDK.configure({
businessId: 'your-business-id',
});
const encryptedCard = await window.easyflowSDK.encrypt({
cardNumber: '5480832801033311',
holderName: 'JOHN DOE',
month: '12',
year: '2035',
cvv: '123',
});Send the encrypted token to your server and use it to create the charge.
3. Create the charge
In payments[].valueInCents, send the amount without interest and without fees, the same 5000 of step 1. The sum of the payments must be equal to the sum of the items plus shipping. Easyflow adds the fees that the buyer pays and the interest of numberInstallments to the payment.
{
"method": "credit-card",
"numberInstallments": 2,
"valueInCents": 5000,
"creditCard": {
"token": "ENCRYPTED_CARD_TOKEN",
"flag": "mastercard",
"last4Numbers": "3311",
"expiresAtMonth": 12,
"expiresAtYear": 2035,
"holderName": "JOHN DOE"
}
}All the creditCard fields are required for credit card payments. flag is the card brand, such as visa, mastercard, elo or american-express.
The encrypted token goes only in the request that creates the charge. No response and no webhook returns it: they show only the display fields of the card, such as
last4Numbers,holderNameandflag. Recurrences of a subscription paid by credit card are charged to the card saved in the subscription, without a new token. For a subscription, a new token is sent only when you create the subscription or change its card.
To test card payments without a real card, use the test cards of the sandbox.
Response
The response contains the identifier of the order and of each payment:
{
"statusCode": 200,
"data": {
"orderId": "1a3c5e7a-9c1e-4a5c-8e9a-1c3e5a7c0029",
"payments": ["1a3c5e7a-9c1e-4a5c-8e9a-1c3e5a7c0029"]
}
}Following the payment
Payments are confirmed asynchronously. To know when an order is paid:
- Listen to the order and payment webhooks, such as
order.paid. This is the recommended approach, see Webhooks. - Retrieve the order with Get order when you need its current state.
An order can have the status pending, paid, partially-paid, canceled, reversed, refunded or charged-back.
Splitting payments
To split the value of an item with other businesses, add commissionedParticipants to the item. Each participant has the commissionedId of the business that receives part of the funds, and the share as commissionedValueInCents or commissionedPercentage.
Splitting a subscription
To split a subscription with other businesses, send commissionedParticipants when you create the subscription. Each participant has the commissionedId of a business and exactly one of commissionedValueInCents and commissionedPercentage. The participants receive their part in every recurrence, the first one included, with the same value or percentage. The business that owns the subscription receives the rest. The sum of the parts cannot exceed 60% of valueInCents, and the participants cannot be changed after the subscription is created.
Recurring payment links
A payment link with subscription terms is a recurring payment link. Create it with Create payment link and share its distUrl. The buyer subscribes in the Easyflow checkout of the payment link, paying with a credit card, and a subscription starts with the terms of the payment link.
The checkout subscribes the buyer through a route that only the Easyflow checkout can call: it is not authenticated with your API key, and Easyflow also checks the captcha and the device of the buyer in the checkout. Do not call it from your server. To subscribe a buyer from your own system, use Create subscription.
What the subscription takes from the payment link
- The name,
valueInCents,periodicity,numberRecurrences,repeatIndefinitely,retryand the card statement text come from the payment link. The buyer sends only the buyer data and the card. - The subscription belongs to the business of the payment link. It has no split participants and no
metadataof yours. - When the payment link has
advanced.buyerWhitelist, only a buyer whose email belongs to one of the domains, or to a subdomain of one of them, can subscribe.
Follow the result with the subscription and order webhooks, and read the subscription with Get subscription.
Limit of subscriptions
When the payment link has maxOrdersPerLink, each subscription counts once, when the order of its first recurrence is paid. The following recurrences create no order and do not count. When the limit is reached, the payment link is closed with the status canceled and paymentLink.canceled is sent. order.paid and paymentLink.canceled can arrive in any order, so treat them as independent events. See the payment link events.
Retries and errors in the checkout
Each attempt of the buyer has its own idempotency key, and the key is valid only for that payment link:
- While the payment link can be subscribed, a retry with the same key and the same data returns the same subscription and never charges twice.
- After the buyer was charged under a key, a retry with that key and the same data returns the same subscription, even when the payment link was canceled, expired or deleted in the meantime. Without a charge, a closed payment link refuses the attempt.
The checkout refuses the attempt when:
| Situation | Response |
|---|---|
| Buyer or card data is missing or invalid. | 400, with the name of the field in the message. |
| The payment link does not exist or was deleted. | 400 with the message Invalid param: [Invalid Payment Link.]. |
| The payment link is not recurring, not active or expired. | 400 with errorCode PAYMENT_LINK_NOT_RECURRING, PAYMENT_LINK_NOT_ACTIVE or PAYMENT_LINK_EXPIRED. |
The email of the buyer is not allowed by advanced.buyerWhitelist. |
400 with errorCode BUYER_WHITELIST_BUYER_NOT_AUTHORIZED. |
| The same key was used with different data, or the attempt with this key is still running. | 409. |
| The card was refused. | 422 with the same errorCode values of Create subscription. A refused card returns the same error for every retry with that key. |
| The same device made more than 5 attempts in 10 minutes. | 429, with the Retry-After header. |
| The request did not come from the Easyflow checkout, or the checkout could not verify the captcha or the device. | 401 or 403. |
Subscription cycles
A subscription, created with Create subscription or by a recurring payment link, is charged in cycles. Each cycle is a recurrence, followed by the recurrence events.
Orders and recurrences
- Only the first cycle, charged when the buyer subscribes, is an order. It sends the order events, such as
order.paid. - From the second cycle on, Easyflow charges the card saved in the subscription without creating an order. No
order.*event is sent for these cycles: follow them withsubscriptionRecurrence.*. - The number of the cycle is
recurrencein the recurrence events.
Due dates
- The first cycle is charged when the buyer subscribes. Its
billingDateis the moment when its order was created. - The following cycles are due every
periodicity: 1 month forMonthly, 3 months forQuarterly, 6 months forBiannualyand 12 months forAnnualy. The day of the month depends on when the subscription was created, as described below. - A routine runs every hour and charges the cycles that are due, so a cycle is charged in the hours after its due date.
- The date of the charge cannot be chosen.
- No field shows which rule a subscription follows. The rules below do not add any field to the API, the events or the webhooks.
Subscriptions created from the November 10, 2026 deploy
This rule applies to every subscription created from the deploy on November 10, 2026 on, from an offer, through the API or by a payment link, with any periodicity.
- Each following cycle is due on the day of the month when the buyer subscribed, read in Brasília time.
- When the month of the cycle does not have that day, the cycle is due on the last day of that month. The next cycles go back to the day of the subscription.
- The due date is at midnight, Brasília time, for
Monthly,Quarterly,BiannualyandAnnualy.
For example, a Monthly subscription created on January 31 is due on February 28 (February 29 in a leap year), then on March 31. One created on October 31 is due on November 30, then on December 31.
Subscriptions created before the November 10, 2026 deploy
These subscriptions keep the previous rule.
- Each following cycle is due on the due date of the previous cycle plus the
periodicity. - For
Monthly,QuarterlyandBiannualy, the due date is at midnight, Brasília time. ForAnnualy, it keeps the time of day of the previous due date.
Attempts and retries
A recurrence is the cycle, not a charge attempt. Its id stays the same while Easyflow retries it, and each attempt adds a new item to payments, with its own id. retry.retries counts the retries made so far.
subscriptionRecurrence.failedis sent for every attempt that fails, not only after the last one.subscriptionRecurrence.delayedmeans that the payment is past due and was not paid. The recurrence follows the same retries as a failed one.- Retries apply from the second cycle on. The first cycle is charged when the buyer subscribes and is never retried: when its order is canceled, for example because the card was refused, the subscription is canceled.
retry.retriesMaxNumbercounts the retries after the original charge. With the default of 5 retries, 3 days apart, a cycle is charged up to 6 times while the card is not changed.- Change subscription credit card restarts the retries. Each
delayedorfailedcycle that it sends to the new card is charged right away,retry.retriesgoes back to0, and aninactivesubscription becomesactiveagain. The count of attempts starts over from the card change, so a cycle can be charged more times than the limit above. A cycle retried in the last 10 minutes is not restarted. - When the last retry also fails, the subscription is not canceled: its
statusbecomesinactiveandsubscription.deactivatedis sent, aboutretry.intervalInDaysdays after the last retry.
The details are in retry of Create subscription.
Commissions of each cycle
Every cycle has its own payment and its own commissions, and commission.released is sent for every cycle. In the commission events:
installmentis the installment of the card payment, not the number of the cycle. From the second cycle on, each cycle is charged in a single installment, so it is1.- To find the cycle of a commission, match
payment.idwith one of thepayments[].idof the recurrence. The number of the cycle isrecurrencein the recurrence events. commission.releaseddoes not sendrecurrencenororderItem, sopayment.idis the way to link it to the cycle.- In
commission.released,statusisreleasedwhen the installment was fully settled, orpartialy-releasedwhen only part of it was settled so far. Apartialy-releasedcommission can be released again later, with a newcommission.released.