Installation
Initialization
Idempotency keys for write calls
Every resourcecreate, update, delete, and action method that writes accepts an optional final idempotencyKey string. Reuse the same value when retrying the same business operation; the SDK sends it as Idempotency-Key.
paybridgenp.checkout
checkout.create(params)
Creates a checkout session.
checkout.expire(id)
Marks a session as expired so it can no longer accept payment. Use this when you mint a fresh session for a logical purchase that already had one outstanding (e.g. a customer requesting a new payment link), so the old URL stops being payable immediately rather than waiting for its 30-minute TTL.
code: "provider_cancel_unconfirmed"; retry before creating another payable session.
checkout.retrieve(id)
Fetches a checkout session by ID: its current status, amount, customer, and any collected address. Read-only (sessions are created with checkout.create).
customerName, expiresAt, …), unlike the snake_case checkout.create response.
checkout.list(params?)
Lists checkout sessions for the project, newest first.
paybridgenp.paymentLinks
Reusable hosted payment pages. Methods need an API key with the links:read or links:write scope.
paymentLinks.create(params)
paymentLinks.list(params?)
paymentLinks.retrieve(id)
Returns the link plus aggregated view and conversion stats.
paymentLinks.update(id, params)
Updates editable fields. Only the keys you pass are changed.
paymentLinks.cancel(id)
Deactivates a link so it can no longer accept payments, while keeping it and its history for your records. The recommended way to retire a link that has already been used.
paymentLinks.delete(id)
Permanently deletes a link. Allowed only when the link has never been used. Otherwise it returns 422; cancel it instead.
paybridgenp.payments
payments.list(params?)
payments.retrieve(id)
paybridgenp.webhooks
webhooks.create(params)
webhooks.list()
webhooks.delete(id)
PayBridgeNP.webhooks.constructEvent(body, signature, secret) (static)
Verifies a webhook signature and parses the event. Use this in your webhook handler.
SignatureVerificationError if:
- The signature header is missing or malformed
- The HMAC doesn’t match
- The timestamp is more than 5 minutes old (replay attack protection)
paybridgenp.billing
The billing namespace provides access to plans, customers, subscriptions, and invoices. Live-mode Billing API access requires Growth or higher; sandbox Billing is available on every plan.
billing.plans
billing.customers
billing.subscriptions
billing.invoices
Account, analytics, providers, and SMS
account.get() requires account:read; analytics.overview() requires analytics:read. providers.list() returns only enabled, configured providers for the key’s project. sms.notifyPendingPayment() requires payments:write; its optional idempotency key is sent for SDK consistency, but the server does not currently deduplicate this route.
Error handling
All SDK methods throw typed errors you can catch and inspect:Error classes
The base class is
PayBridgeError; every error above extends it. See the Errors reference for the full list.
TypeScript types
All types are exported from@paybridge-np/sdk:
Framework examples
Next.js App Router
Next.js App Router
Express
Express