Skip to main content
All use cases
Recurring billingSaaS

Recurring Pix, authorized once by the customer.

For a monthly plan paid in Brazil. codespar_charge creates the Pix Automático recurrence at Celcoin in one of three ways: a request sent to the payer's bank app with no QR, a QR that carries only the recurrence, or a QR that charges now and carries it. The customer authorizes it in the bank app, and each cycle is charged on that authorization; the results come back from Celcoin. It needs Pix Automático activated for your organization. Charging one price in several currencies and dunning are not offered; the fiscal document per cycle goes through NFe.io, in live projects only.

BeforeA card on file, or a boleto every month
AfterPix Automático, authorized once in the bank app
Pix Automático
recurrence the customer authorizes once
Try it in the Sandbox
Pix Automático
Recurring Pix
The customer authorizes once in the bank app; each cycle charges on it
Celcoin
Provider
The recurrence is created at Celcoin
3
Ways to start
No QR, a recurrence QR, or a QR that charges now and carries it
NF-e
Per cycle
codespar_invoice through NFe.io, in live projects only
Illustrative example · demo data

One authorization, then each cycle.

An example with demo data: the agent creates a monthly Pix Automático recurrence of R$ 52.00; the customer authorizes it in the bank app, and the fiscal document for each cycle is issued in a live project.

  • The customer authorizes once, in the bank app
  • The recurrence is created at Celcoin
  • Several currencies and dunning are not offered
Plan · Pro
Pix Automático · Celcoin
Agent
codespar_charge · pix_automatic · R$ 52,00 / mês
via codespar_charge · Celcoin
✓ Pix Automático
codespar_invoice · NF-e
via codespar_invoice · NFe.io
✓ R$ 52,00 · Pix Automáticorec_demo
The pain

The conversation is the easy part.

Recurring billing in Brazil meant a card on file or a boleto every month, and failed charges chased by hand.

Ask the customer for a card on file

Pix Automático: the customer authorizes the recurrence in the bank app

Send a boleto every month

Each cycle is charged on the authorization the customer gave

Issue the fiscal document at month end

codespar_invoice issues it per cycle, in a live project

Start every recurrence the same way

Three ways to start: no QR, a recurrence QR, or a QR that charges now

How the agent does it

Recurring Pix, authorized by the customer.

codespar_charge creates the Pix Automático recurrence at Celcoin in one of three journeys: a request to the payer's bank app with no QR, a QR that carries only the recurrence, or a QR that charges now and carries it. The customer's authorization in the bank app is what lets each cycle be charged, and Celcoin reports the outcome. Charging one base price in several currencies and dunning are not offered; the fiscal document per cycle goes through NFe.io, in live projects only.

01
Plan
Your billing

Price and cycle

02
Recurrence
codespar_charge

Pix Automático

Celcoin
03
Authorize
Customer

In the bank app

04
Cycle
Celcoin

Charged on the authorization

05
Invoice
codespar_invoice

NF-e · live projects only

NFe.io
Architecture

codespar_charge with a recurrence block maps the journey to its Celcoin endpoint: journey 1 (no QR, the request reaches the payer's bank app), journey 2 (a QR carrying only the recurrence) or journey 3 (a QR that charges now and carries it; paying it is the acceptance). The payer's authorization at their bank and the agent's mandate are separate objects. Each cycle is an instruction to Celcoin, and its result arrives by webhook. The NF-e per cycle is codespar_invoice through NFe.io, in a live project.

In code

The code, and what it assumes.

subscription-agent.ts
// Prerequisites: CODESPAR_API_KEY set to a test key (csk_test_…), a Celcoin
// connection, Pix Automático activated for your organization, and a mandate of
// the receiving consumer to create the recurrence under.
import { CodeSpar } from "@codespar/sdk";

const session = await new CodeSpar().create("user_0000", { preset: "brazilian" });

// the agent fills codespar_charge with the recurrence block
const run = await session.send(
  "Create a monthly Pix Automático recurrence of R$ 52.00 for Ana Souza (CPF 123.456.789-09), plan Pro, with a QR that charges the first month now.",
);
const created = run.tool_calls.find((c) => c.tool_name === "codespar_charge");
console.log(created?.status, created?.output); // the QR the customer pays and authorizes in the bank app

Example with the published SDK (@codespar/sdk 0.16.11). Its prerequisites are in the comments. Compiling does not prove the integration: run it in test mode first.

Featured tools
codespar_charge

Creates the Pix Automático recurrence at Celcoin, in one of three journeys.

codespar_invoice

Issues the fiscal document for a cycle through NFe.io; live projects only.

See the meta-tool reference

Start with a test key.

Test keys are free. Open the sandbox, connect the providers your project uses and see which tools it can call before you build.

Subscription agent — CodeSpar | CodeSpar