Skip to main content
All use cases
ERP + fiscal · ConceptOperations

From a payment's status to your ERP entry: a proposal.

This page is a conceptual proposal, not a product feature. CodeSpar does not write to ERPs: Omie and Tiny are not connectors it routes to, and Bling is routed only to issue NFS-e. What exists to build on: codespar_pay reads each payment's status by id, and codespar_wallet lists the wallet's entries. Mapping each money event to the right ERP, entity and account, and writing it, is your integration.

BeforeKey each transaction into the ERP by hand
AfterYour integration writes the entry from CodeSpar's records
ERP
your integration, from CodeSpar's records
Try it in the Sandbox
ERP
Writing the entry
Not offered: a proposal, built in your integration
status
Payment status
codespar_pay action=status reads a payment by id
statement
Wallet statement
codespar_wallet action=statement lists the wallet's entries
Bling
Bling
Routed only to issue NFS-e, not to write ledger entries
Illustrative example · demo data

From a payment's status to your ERP entry.

An illustrative sketch: the agent reads the payment's status from CodeSpar and your integration writes the entry to the ERP. CodeSpar does not write to the ERP.

  • CodeSpar returns the payment's status and the wallet's statement
  • Writing to the ERP is your integration
  • Bling is routed only to issue NFS-e
Entry · AP-771
codespar_pay → ERP
Agent
codespar_pay · action: "status" · AP-771
payment_statussucceeded
amountR$ 3.480,00
via codespar_pay · Pix
POST <your-erp>/entries · AP-771
201
✓ codespar_pay → ERPAP-771
The pain

The conversation is the easy part.

Every transaction gets keyed into an ERP by hand, then reconciled at month end across countries and entities.

Key each transaction into the ERP

Your integration writes the entry from the payment's status

Check the bank portal for what settled

codespar_pay action=status reads each payment

Rebuild the wallet's movements for the accountant

codespar_wallet action=statement lists them

Attach the fiscal document by hand

codespar_invoice issues it (NFe.io, live projects only); attaching it is your integration

How the agent does it

A proposal, on the records that exist.

Your integration reads what CodeSpar records: a payment's status by id (codespar_pay, action=status) and the wallet's entries (codespar_wallet, action=statement). It maps each entry to the entity, account and currency of the right ERP and writes it there. CodeSpar has no ERP connector that writes entries: Omie and Tiny are not routed, and Bling is routed only for NFS-e.

01
Settle
codespar_pay

Payment status by id

CodeSpar
02
Statement
codespar_wallet

The wallet's entries

CodeSpar
03
Map
Your integration

Entity, account, currency

04
Write
Your integration

The entry in the ERP

05
Attach
Your integration

The fiscal document, if any

Architecture

A sketch, not a product flow. codespar_pay with action=status returns a payment's provider status by id; codespar_wallet with action=statement returns the wallet's ledger entries. Your integration turns each settled entry into an ERP entry for the right entity and writes it through the ERP's own API. No CodeSpar connector writes to Omie, Bling or Tiny.

In code

The code, and what it assumes.

erp-bridge.ts
// Prerequisites: CODESPAR_API_KEY set to a test key (csk_test_…) and a payment
// made through codespar_pay. Writing to the ERP is your code: CodeSpar does not
// write to Omie, Bling or Tiny.
import { CodeSpar } from "@codespar/sdk";

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

// what CodeSpar can tell your integration
const status = await session.execute("codespar_pay", { action: "status", payment_id: "<payment id>" });
const statement = await session.execute("codespar_wallet", { action: "statement", consumer_id: "user_0000", limit: 20 });

// your integration: map each settled entry to the ERP of the right entity
console.log(status.data, statement.data);

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_pay

action=status reads a payment's status by id.

codespar_wallet

action=statement lists the wallet's ledger entries.

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.

ERP bridge — CodeSpar | CodeSpar