Charges
Charges are the base object for both PIX and card payment flows authenticated by the merchant.
Main endpoint
POST /v1/charges creates either a PIX or card charge. The payload uses amount_cents, payment_method and a customer object.
Installation
npm install mupag-sdk@0.2.0import { MuPag } from 'mupag-sdk';
const mupag = new MuPag({
apiKey: process.env.MUPAG_API_KEY,
env: 'test',
});
const charge = await mupag.charges.create({
amount_cents: 1290,
payment_method: 'pix',
customer: {
name: 'Ana Silva',
email: 'ana@example.com',
tax_id: '12345678909',
},
}, { idempotencyKey: 'order_123_charge_1' });
console.log(charge.charge_id);
Expected response
For PIX you receive charge_id, status, pix_emv_code, pix_qr_code_base64 and expires_at. For card flows, rely on webhooks and follow-up reads for the final state.
Safe operation
- Generate one
Idempotency-Keyper business attempt. - Reuse the same
customer_idwhen the buyer already exists. - Do not deliver goods or access from the synchronous response alone; wait for the correct event.
Did this page unblock the next step?
Feedback stays inside the docs flow and should never include customer or card data.