SDK Guide
The PayChain SDK is the recommended integration path for Node.js and TypeScript backends. It wraps the same public REST API with typed helpers, safer payout split handling, idempotency support, error mapping, and webhook verification utilities.Positioning note: Use the SDK when your backend runs Node.js or TypeScript. Use the REST API directly when you need another language, full HTTP control, or your own wrapper.
Install
Create a client
What the SDK covers
- Customers.
- Invoices.
- Payout route attachment.
- Dynamic payout recipients.
- Withdrawals.
- Webhooks.
- Balances.
- Transactions.
- Networks.
- Tokens.
What the SDK does not cover
- Account settings, API key management, billing changes, and payout-route administration that are handled in the dashboard.
- Unsupported or private beta surfaces that are not part of the public API.
- Low-level custody, infrastructure, or treasury implementation details.
Idempotency
Every mutating operation should include an idempotency key.Customer deposit addresses
For reusable customer deposit-address flows, ensure the customer has an address for the rail before showing payment instructions.ensureAddress returns an existing address when one already exists, or creates a missing address when the business is configured for the requested rail. Call it before displaying a reusable address, not only during customer creation. This lets existing customers receive newly supported rail addresses as PayChain adds networks over time.
Solana
Stellar dedicated addresses
ensureAddress. By default, PayChain returns the business Stellar treasury address plus a required Memo ID:
Lazy provisioning note: PayChain can create a missing customer address for a supported rail on demand. If only one active network matches the requested rail, PayChain may infer
networkId, but SDK integrations should pass networkId explicitly for a predictable address-selection pattern.Invoice confirmation progress
Useinvoices.get to poll canonical invoice state while a payment is waiting for required network confirmations.
Fulfillment note: Wait for
paid or overpaid invoice status before fulfilling. Confirmation progress is for customer-facing visibility while settlement finality is still pending.Webhook verification
Webhook verification must use the raw request body.When to use REST instead
Use REST directly when:- Your backend is not Node.js or TypeScript.
- You need language-specific HTTP instrumentation.
- You want to build your own wrapper.
- You need to inspect exact request and response payloads.
- You are debugging endpoint-level behavior.