Skip to content
Studeia Docs

Asaas integration (PIX + boleto + Brazilian card)

Asaas is Studeia's Brazilian payment provider: PIX (95% of market), bank boleto, national card. Fail-closed webhooks, customer split per provider, parallel with Stripe (USD/international card).

2026-05-24 5 min
Resposta curta

Asaas is Studeia's Brazilian payment provider: instant PIX (1.99% fee), boleto (R$3.49), national card (4.99% + R$0.49). For BR clients is cheaper and more native than Stripe. Fail-closed webhooks (503 if token absent). Customer split per provider. For international: parallel Stripe USD.

Setup

Asaas Dashboard

  1. https://asaas.com (or sandbox: https://sandbox.asaas.com)
  2. Settings > Integrations > API > copy Access Token
  3. Settings > Webhooks > URL: https://[tenant].studeia.com/api/webhooks/asaas?token=<TOKEN>
  4. Events: PAYMENT_RECEIVED, PAYMENT_OVERDUE, PAYMENT_REFUNDED, SUBSCRIPTION_CREATED/UPDATED/DELETED
  5. Custom token (cryptographically strong random string)

Env vars

ASAAS_API_KEY=$aact_...
ASAAS_WEBHOOK_TOKEN=...generated-in-step-5...
ASAAS_SANDBOX=true  # optional

PIX flow

Admin clicks "Pay with PIX" → POST /api/institution/billing/checkout { provider: "asaas" } → Studeia AsaasBillingProvider.createCheckout() (resolves asaasCustomerId, POST /subscriptions with billingType=PIX) → Asaas returns QR Code + PIX copy-paste payload → Studeia returns Asaas hosted page URL → admin scans QR, pays → PIX confirms in ~30s → webhook PAYMENT_RECEIVED → applyWebhookEvent → promotes Tenant.plan.

Hardening (rules 138, 139)

  • Fail-closed: missing ASAAS_WEBHOOK_TOKEN env = 503 asaas_not_configured
  • Token validation: query param ?token=<...> compared with env (timing-safe)
  • 5xx on failure: auto-retries
  • PaymentLog idempotent
  • PII redact: rawPayload via redactPaymentPayload() — removes cpfCnpj, email, name, address

Customer split

TenantSubscription separate fields: stripeCustomerId, asaasCustomerId, externalCustomerId (legacy fallback).

When Asaas vs Stripe

ScenarioRecommended
Brazilian client with PIXAsaas
Brazilian client with boletoAsaas
Brazilian client with cardAsaas (cheaper) or Stripe
International clientStripe USD (Asaas blocked)

Fees compared

MethodAsaasStripe
PIX1.99%NOT offered
BoletoR$3.49 fixedNOT offered
Credit card4.99% + R$0.493.99% + R$0.59 (USD)

For typical B2B Brazilian volume: Asaas is ~20-40% cheaper in total fees.

See also

FAQ

Why Asaas and not just Stripe?

For Brazilian market: 95% of B2B transactions use PIX (instant, no fee) or boleto. Stripe doesn't have native PIX. Asaas is Brazilian, natively integrates PIX/boleto/card with lower fees (1.99% PIX, R$3.49 boleto, 4.99% card + R$0.49 vs Stripe 3.99% + R$0.59).

Does Studeia automatically detect which provider to use?

Yes. getCurrencyFromHeaders() server-side via x-vercel-ip-country / cf-ipcountry: BR = Asaas offered in UI. Outside BR = Stripe USD mandatory (Asaas blocked server-side with 400 'asaas_not_for_international').

Are Asaas webhooks secure?

Yes, with hardening. Token via query param ASAAS_WEBHOOK_TOKEN. Without configured token: webhook returns 503 asaas_not_configured (fail-closed — rule 138). PaymentLog unique idempotency.

Can I test Asaas in sandbox?

Yes, separate sandbox env: https://sandbox.asaas.com. Configure ASAAS_SANDBOX=true to route to sandbox endpoint.

Veja tambem

Asaas integration (PIX + boleto + Brazilian card)