Skip to main content

Checkout

Checkout sessions separate authenticated merchant session creation from public buyer actions. Checkout supports PIX and single-payment cards through the official Asaas invoice when the merchant has an available real integration.

Authentication​

There are two secure ways to create a session:

  • Your backend: use a secret key with the checkout_sessions.create scope.
  • Official MuPag widget: use a publishable key with the checkout_sessions.create scope.

Never expose a secret key in the browser. A publishable key can only access operations explicitly allowed for frontend use.

Flow​

  1. Your backend or the official widget creates the session with POST /v1/checkout-sessions.
  2. The frontend uses public session endpoints to apply a coupon and pay with PIX or open the official Asaas invoice returned in hosted_payment_url.
  3. The final status is confirmed by session reads and webhook events.

Key fields​

  • success_url and cancel_url
  • items
  • customer_id or customer_data
  • allowed_payment_methods: pix, credit_card, or both, depending on merchant availability
  • affiliate_code and coupon_id when relevant

The buyer enters card details only on the official Asaas page. MuPag checkout never receives card details, CVV, or PSP tokens. Simulation-only accounts do not provide this invoice; use PIX for those scenarios.

When reopening a session, query /v1/checkout-sessions/{id}/status to resume the same charge. expires_at is the session deadline; charge_expires_at is the PIX charge expiration. When that deadline is unconfirmed, keep polling before displaying a payable QR code.

A rejection before charge reservation releases the attempt for correction. If a charge already has an authoritative terminal failure, the session completes and a new attempt uses /renew. Uncertain outcomes preserve the charge binding and return a conflict while payment is reconciled.

Idempotency​

The public POST routes /select-method, /coupon, and /pay require the Idempotency-Key header: one value of 1 to 128 visible ASCII characters (0x21–0x7E). Without the header, the gateway responds 400 with idempotency_key_required. An invalid value responds idempotency_key_invalid. Coupon DELETE does not require the header. POST /renew also requires the header, and the renewal service uses that value.

The pay charge does not use the key sent by the client. The persisted key is checkout:{sessionId}. If the session already has a completed charge, the response returns that charge and does not call the PSP again.

Did this page unblock the next step?

Feedback stays inside the docs flow and should never include customer or card data.

mupag / support

How can we help?

Quick answers, AI and our team.

Frequently asked questions

How do I start integrating?

Follow the quickstart, configure the QA environment and create your first test charge.

Read documentation
My PIX payment is pending. What now?

Confirmation is asynchronous. Check the charge status and webhook events before fulfilling the order.

Read documentation
How do I receive payment notifications?

Register a webhook endpoint, verify its signature and handle duplicate events safely.

Read documentation
How do subscriptions work?

Read the subscriptions guide to configure recurring billing and follow the charge lifecycle.

Read documentation
Where can I find authentication help?

See how to use environment credentials in the documentation. Never share your key in chat.

Read documentation