Skip to main content
This page gathers practical usage examples for @pagfinance/sdk.

Public endpoints (no authentication)

Authenticated calls

Provide the JWT token obtained outside the SDK and call protected endpoints:

End-to-end transaction flow

The typical payment flow has three steps: quote, creation, and receipt.
1

Quote

Request a quote for the desired payment.
2

Create

Create the payment from the quote.
3

Submit and track

Submit the transaction and fetch the receipt.
The exact fields of each request and response depend on the API contract. See the API Reference and the Method Reference for parameter details.

Error handling

Every failure throws PagFinanceError, with messages and field errors already normalized:
PagFinanceError normalizes the two API response envelopes ({ success, data } and { ok, error }) into a single structure with messages, fieldErrors, httpStatus, and code.

Runnable example

The package includes a real end-to-end example in examples/transaction-flow (quote, creation, and receipt) using a TOKEN_JWT environment variable:
See the official package on npm for the most recent example code.