Runnable, testable, cross-language examples for the core flows of the Pagou API v2.
This repository is a practical reference that complements the official documentation and the OpenAPI specification. It is not an SDK and it is not framework-specific — every example uses an idiomatic HTTP client with as few dependencies as possible, so the same integration patterns translate across languages.
Status: beta. All mandatory V1 flows are implemented, tested and owned across the seven languages — see the coverage matrix. The badge remains until the docs Examples area lands and owner teams are assigned; the rollout checklist tracks what is left. Browse the guides in the Examples area at developer.pagou.ai/examples/overview.
Português: README.pt-BR.md
Each language mirrors the same set of core flows:
- Payments — create a Pix charge and return the
pix.qr_code; retrieve and reconcile a transaction; voucher/boleto with asynchronous instructions; card via Payment Element (browser) →pgct_*token → backend, continuing 3DS onnext_action; full and partial refunds; list transactions with cursor pagination. - Checkout links — create a link and store the returned public identifier.
- Customers & subscriptions — create/reuse a customer; create, retrieve and cancel a subscription; handle renewal, failure, past-due and cancellation events.
- Transfers (Pix Out) — create, retrieve and reconcile a transfer; cancel when the status allows; reach the final state via webhook.
- Webhooks — real handlers for the transaction, subscription and transfer event families.
| Language | Directory |
|---|---|
| TypeScript / Node | typescript/ |
| Python | python/ |
| PHP | php/ |
| Java | java/ |
| C# / .NET | dotnet/ |
| Go | go/ |
| Ruby | ruby/ |
Every example runs against the sandbox by default. You never need production credentials to try this repository.
-
Get a sandbox token. Sign in to your Pagou dashboard and create a sandbox API token. Sandbox and production tokens are separate — keep them that way.
-
Pick a language and flow. Open the language directory (for example
typescript/) and read itsREADME.md. -
Configure the environment. Copy
.env.exampleto.envin that language directory and set your sandbox token. The base URL defaults to the sandbox server:Environment Base URL Sandbox https://api.sandbox.pagou.aiProduction https://api.pagou.ai -
Run a flow. Each flow README documents a single run command, the input payload, the relevant response, and the expected error and recovery path.
A minimal sanity check — list transactions to confirm authentication and network path:
curl --request GET \
--url https://api.sandbox.pagou.ai/v2/transactions \
--header "Authorization: Bearer YOUR_SANDBOX_TOKEN"A 200 response means your credentials and environment are ready.
All v2 routes require authentication. Choose one scheme and use it consistently:
Authorization: Bearer <token>(recommended default)apiKey: <token>header- Basic auth with username
tokenand passwordx
The API key is a server-side secret. It is never read in browser code. Card data is captured only
through the Payment Element / Elements and exchanged for a pgct_* token before it reaches your
backend — no example accepts a PAN or CVV directly.
These rules are enforced in CI and are non-negotiable:
- No real keys, tokens, documents, PAN or CVV are ever committed.
.env.exampleholds placeholders only. - The API key is never read in browser code.
- Card data uses only the Payment Element / Elements →
pgct_*token. - All fixtures are synthetic.
- Logs redact
Authorization, tokens and sensitive payloads. - Only the public UUID
identifierreturned by the API is used to reference resources.
See SECURITY.md for how to report a vulnerability.
/
README.md README.pt-BR.md LICENSE SECURITY.md CONTRIBUTING.md CODEOWNERS
.github/ workflows, issue templates, PR template, dependabot config
docs/ coverage-matrix.md, architecture.md, troubleshooting.md
shared/ fixtures/ (synthetic), contracts/ (OpenAPI snapshot + used-operations manifest)
typescript/ python/ php/ java/ dotnet/ go/ ruby/
Each language directory shares the same conceptual structure:
<language>/
README.md .env.example
payments/ checkout-links/ subscriptions/ transfers/ webhooks/ tests/
Contributions are welcome. Read CONTRIBUTING.md first — it explains the branch and PR workflow, the coverage-matrix requirement, and the security checks every change must pass.