Create, list, retrieve, update, refund, and reconcile Pagou transactions with concrete TypeScript SDK examples.
{ "external_ref": "order_1001", "amount": 1500, "currency": "BRL", "method": "pix" }
{ "success": true, "requestId": "req_3002", "data": { "id": "tr_1001", "status": "pending" } }
const created = await client.transactions.create({ external_ref: "order_1001", amount: 1500, currency: "BRL", method: "pix", buyer: { name: "Ada Lovelace", email: "ada@example.com", document: { type: "CPF", number: "12345678901" }, }, products: [{ name: "Starter order", price: 1500, quantity: 1 }], });
const cardPayment = await client.transactions.create( { external_ref: "order_2001", amount: 2490, currency: "BRL", method: "credit_card", token: "pgct_token_from_browser", installments: 1, buyer: { name: "Ada Lovelace", email: "ada@example.com", document: { type: "CPF", number: "12345678901" }, }, products: [{ name: "Plan upgrade", price: 2490, quantity: 1 }], }, { idempotencyKey: "tx_order_2001" }, );
const current = await client.transactions.retrieve("tr_1001", { requestId: "reconcile_tr_1001", timeoutMs: 10_000, });
const refunded = await client.transactions.refund( "tr_1001", { amount: 500, reason: "requested_by_customer" }, { idempotencyKey: "refund_tr_1001_1" }, );
for await (const item of client.transactions.listAutoPagingIterator({ limit: 100 })) { console.log(item.id, item.status); }