@macropayments/sdk package is the fastest way to talk to Macropay from any
JavaScript runtime. It ships full TypeScript types, async pagination helpers, and
covers the entire v1 API — from hosted checkout to usage meters to agent
Signals. Because Macropay is your merchant of
record, the same calls that move money also handle sales tax, VAT, and PCI scope
on your behalf.
Install
- npm
- pnpm
- yarn
Terminal
Configure the client
Create oneMacropay instance and reuse it. Point it at sandbox while you
build, then flip the env var to production when you go live — no code changes.
macropay.ts
Your first call
List operations return an async iterator, so paging through results is a singlefor await loop. Here we walk every benefit a customer has unlocked — license
keys, downloads, Discord access, and so on.
list-benefits.ts
Spin up a checkout
Everything you sell — one-time or subscription — is a product, so the call shape is identical. Create a checkout session and redirect the customer to the hosted, fully localized payment page:checkout.ts
Meter AI and agent usage
Bill for what your product actually does — tokens consumed, actions taken, or outcomes delivered — by ingesting events. Meters aggregate those events into a metered price, and you can certify agent ROI with value receipts.ingest-usage.ts
Routing model calls through the OpenAI-compatible AI proxy at
/ai/v1
captures token cost automatically — no manual event ingestion needed. See the
proxy and agent-billing flows in the adapter guides.camelCase in TypeScript
The Macropay API and reference docs usesnake_case, but this SDK exposes
camelCase to match JS/TS convention. Modern editors surface the camelCase
fields via the bundled types, so the mapping is usually invisible — just keep it
in mind when copying field names straight from the API
reference.
A future release will let you opt into
snake_case in TypeScript so SDK code maps
one-to-one with the API design and documentation.