1. Install the package
2. Set your credentials
Create a.env file in your project root:
3. Create a client
createOakClient configures authentication and retry behavior. Each create*Service(client) factory returns a typed service instance — import only the services you need.
4. Make your first call
index.ts) and run it:
Result<T, OakError> — a discriminated union that is either { ok: true, value: T } or { ok: false, error: OakError }. Check result.ok before accessing the value.
This pattern replaces try/catch for API calls. The SDK never throws on HTTP errors — it wraps them in the Result type. For the full breakdown, see Error Handling.
5. Create a customer
6. Create a payment
Steps 5 and 6 go inside the main() function, after the list call.
Adding more services
Import additional service factories as you need them:What to read next
- Authentication — how OAuth2 token management works under the hood
- Payments — create, confirm, and cancel payments across providers
- Webhooks — register endpoints and receive real-time event notifications
- Error Handling — the
Result<T>pattern, error types, and retry configuration