API & typed errors

API and typed errors

All v1 API routes require the merchant’s server-side bearer key. Browser customers use the authenticated same-origin merchant bridge. Health endpoints disclose only service readiness information.

MethodRoutePurpose
GET/health, /readyAPI liveness and database/migration-count observation
POST/v1/productsCreate product
POST/v1/pricesCreate immutable price version
POST/v1/checkout/sessionsCreate merchant-scoped session
GET/v1/checkout/sessions/:idRetrieve owned session
GET/v1/checkout/sessions/:id/paymentConfirmed session payment, if any
POST/v1/checkout/sessions/:id/orderCreate or retrieve canonical quote
POST/v1/checkout/sessions/:id/renewExplicit safe quote renewal
POST/v1/submissions/:id/signaturesPersist the two verified signatures
GET/v1/submissions/:idPublic-safe owned submission status
GET/v1/payments, /v1/payments/:idMerchant payment list/detail
GET/v1/merchantMerchant profile
import { WhitePay, WhitePayAPIError } from '@whitepay/node';
 
export async function paymentOrMissing(client: WhitePay, paymentId: string) {
  try {
    return await client.payments.retrieve(paymentId);
  } catch (error) {
    if (error instanceof WhitePayAPIError && error.status === 404) return null;
    throw error;
  }
}

Errors expose a status and bounded code. Examples include unauthorized, not_found, invalid_request, idempotency_conflict, quote_expired, invalid_signature, rate_limited, network_error and timeout. Unknown upstream error bodies are not echoed as trusted SDK messages. Transport errors use status 0. Treat a timeout as uncertain execution, not permission to charge again.

The current API returns exact validated integer minor-unit numbers within safe bounds. There is no claim of a published/generated OpenAPI contract yet. Read limitations before hosting publicly.