---
name: luniumpay-pix-charge
description: "Receber Pix de um pagador brasileiro e liquidar em USDT/USDC na carteira do dono (ou em saldo em reais) com a LuniumPay. Use quando o usuário quiser \"receber Pix em USDT\", cobrar em reais com entrega em cripto, gerar QR Pix por API, ou montar checkout Pix → stablecoin em Next.js, Express, FastAPI ou Supabase. Inclui receitas por stack e script de teste no sandbox. EN: Accept a Pix payment from a Brazilian customer and settle USDT/USDC to the owner wallet (or BRL balance) with LuniumPay. Use for \"accept Pix, receive USDT\", Pix QR by API, Pix → stablecoin checkout in Next.js, Express, FastAPI or Supabase. Stack recipes and sandbox smoke script included."
license: MIT
metadata:
  version: "2.2.0"
  api: "1.45.2"
title: luniumpay-pix-charge
canonical_url: https://skilld.dev/gh/luniumpay/lunium-agent-skills/luniumpay-pix-charge
last_updated: 2026-10-26T17:05:31.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [.claude-plugin/plugin.json](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/.claude-plugin/plugin.json), [references/checkout-react.md](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/references/checkout-react.md), [references/express.md](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/references/express.md), [references/fastapi.md](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/references/fastapi.md), [references/nextjs.md](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/references/nextjs.md), [references/supabase-edge.md](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/references/supabase-edge.md), [scripts/smoke.mjs](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-pix-charge/scripts/smoke.mjs).
>
> If the user asked to install this Skill, run `npx skilld install luniumpay/lunium-agent-skills/luniumpay-pix-charge`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/luniumpay-pix-charge`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/luniumpay/lunium-agent-skills/luniumpay-pix-charge) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/luniumpay-pix-charge`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/luniumpay-pix-charge --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/luniumpay-pix-charge --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Cash-in: Pix entra, USDT sai

Base: `https://api.luniumpay.com`. Header `X-API-Key: <LUNIUM_API_KEY>` em todas as
chamadas. Chave de teste: `POST /keys/sandbox` com `{"email": "<e-mail de quem testa>"}`
(obrigatório). Chave de produção: `POST /keys` com `{"name": "<negócio>", "email": "<e-mail>"}`.

## Decisão inicial: destino

- `destino: "cripto"` → USDT/USDC entregue na `payout_address` em cada cobrança
  (ou na `settlement_address` da chave, se configurada). Exige `asset` e `chain`
  presentes em `GET /cashin/catalog` com `entregavel: true`.
- `destino: "saldo"` → crédito em reais na custódia, sem carteira. Dono saca
  depois (`POST /saldo/sacar-cripto`) ou paga Pix com o saldo. Use quando o dono
  não tem carteira ou quer agrupar saques. `customer_ref` separa subcontas.

## Sequência (sempre nesta ordem)

1. `GET /keys/me` → capacidades, taxas, `nivel_conta`, webhook configurado?
2. `GET /cashin/catalog` → escolha `asset` + `network` (vai no campo **`chain`**).
   Confira `withdrawMin`, `minBuyAmount`, `memoRequired` (redes como XRP/TON
   exigem `payout_tag`).
3. `POST /cashin/preview` `{"amount_cents": 10000, "destino": "cripto",
   "asset": "USDT", "chain": "polygon"}` → `net_cents`, `asset_amount`
   (estimativa), `min_brl_cents`, `fee_total_cents`. Mostre como estimativa.
4. Persista seu `external_id` (≤ 64 chars, único por intenção) **antes** de criar.
5. `POST /cashin/charge`:
   ```json
   {
     "amount_cents": 10000,
     "payer_tax_number": "<CPF/CNPJ do pagador, só dígitos>",
     "destino": "cripto",
     "asset": "USDT",
     "chain": "polygon",
     "payout_address": "<carteira confirmada pelo dono>",
     "external_id": "pedido-4812",
     "customer_ref": "cliente-42"
   }
   ```
   Resposta: `cashin_id`, `status: "pending"`, `qr_copypaste`, `qr_image_url`,
   `expires_at`, `net_cents`, `hold_hours`.
6. Frontend mostra `qr_image_url` + `qr_copypaste` + valor + validade. Nada gerado
   localmente.
7. Acompanhe por webhook (`cashin.paid`, `cashin.settled`, `cashin.held`,
   `cashin.failed`, `cashin.refunded`, `cashin.expired`) e confirme por
   `GET /cashin/{cashin_id}/status`. Polling: a cada 5 s até `expires_at`.

## Leitura do status (três eixos independentes)

| Campo | Valores | Significado |
|---|---|---|
| `status` | pending, delayed, under_review, paid, expired, refunded, failed | O Pix em si |
| `settlement_status` | pending, sending, entregando, sent, incerto, failed | A entrega/crédito |
| `settlement_proof` | none, broadcast, confirmed, reported, simulated | Evidência da entrega |

- Libere o pedido quando `status=paid` **e** `settlement_status=sent` (ou, para
  saldo, quando o crédito aparecer em `GET /saldo`). Para rastro on-chain use
  `settlement_tx_hash` / `settlement_tx_url` e `settlement_proof=confirmed`.
- `held: true` / `hold_hours > 0`: retenção automática por faixa do pagador.
  Mostre `liberar_em`. Não peça outro Pix.
- `settlement_status=incerto`: estado de conciliação. Mostre e aguarde; nunca
  repita a cobrança nem anuncie entrega.
- `e2e` é o identificador do Banco Central: qualquer um prova o Pix em
  `GET /v1/verificar/{e2e}` sem chave.

## Armadilhas

- A API **não valida o dígito verificador** de `payer_tax_number`: CPF digitado errado gera QR
  normalmente e o Pix volta como `refunded` (`refund_reason=PAYER_MISMATCH`). Valide no app
  antes de chamar (`documentoValido` nas receitas). Formato errado → `documento_invalido`.
- `payer_name` é opcional (só informativo). `delivery_mode` (`full`|`split`) existe só para
  `chain: "liquid"` (DePix); ignore nas demais redes.
- Pagador estreante tem teto baixo: `erro=limite_do_pagador` → ofereça valor
  menor; o teto sobe com o histórico. Não divida a compra em vários Pix para
  contornar.
- `external_id` reaproveitado com corpo diferente → `external_id_divergente`.
  Crie um id novo para uma intenção nova.
- Taxa fixa por Pix e percentual vêm da conta (`GET /keys/me`, prévia). Não os
  grave no código.
- Sandbox: `qr_copypaste` vem como `SANDBOX:NAO_PAGAVEL:...`; pague só com
  `POST /sandbox/cashin/{id}/pay`. `sandbox_scenario` por destino — cripto: `success`,
  `delayed`, `expired`, `refunded`, `failed`, `payer_mismatch`, `settlement_failed`,
  `settlement_uncertain`, `route_unavailable`, `provider_unavailable`; saldo: os mesmos +
  `held` (carência visível em `GET /saldo`). Cenário de outro fluxo → 400 `cenario_invalido`.
  `settlement_uncertain` para em `incerto`: feche com `POST /sandbox/operations/{cashin_id}/resolve`
  `{"outcome": "sent"}`. A escada por pagador fica desligada no sandbox. Omita em produção.

## Receitas prontas

Todas leem `LUNIUM_DESTINO` (`cripto` com `LUNIUM_PAYOUT_ADDRESS`, ou `saldo` sem carteira) e
validam o dígito do CPF/CNPJ antes de chamar a API.
- `references/nextjs.md` — App Router: rota de cobrança, rota de status, webhook com corpo cru.
- `references/express.md` — Node/Express com `express.raw` no webhook.
- `references/fastapi.md` — Python/FastAPI com httpx.
- `references/supabase-edge.md` — Edge Function Deno + tabela `pedidos`.
- `scripts/smoke.mjs` — prova ponta a ponta no sandbox (recusa `lun_live_`).
