checkoutOs
Core concepts

Error reference

Every error code checkoutOs returns, its HTTP status, and what to do about it.

All errors extend AppError, so the error middleware can format a response without any switch statements or instanceof chains. Plain Error objects are never thrown from domain code.

abstract class AppError extends Error {
  abstract readonly httpStatus: number;
  readonly code: ErrorCodeValue;
  readonly details: Record<string, unknown>;
  readonly isOperational: boolean;
}

isOperational decides the log level, nothing else: true means the client sent something bad and logs at warn; false means an unexpected system failure and logs at error.

Response shape

{
  "success": false,
  "error": {
    "code": "REFUND_NOT_ALLOWED",
    "message": "Refunds are only allowed on successful payments",
    "details": { "chkId": "chk_a1b2c3d4e5f6a7b8" }
  }
}

400 — bad request

CodeError classCause
INVALID_AMOUNTInvalidAmountErrorAmount is not a positive integer in paise
INVALID_ORDER_IDInvalidOrderIdErrorOver 64 chars, or outside /^[A-Za-z0-9_.-]+$/
MISSING_IDEMPOTENCY_KEYIdempotencyKeyMissingErrorIdempotency-Key header absent
INVALID_IDEMPOTENCY_KEYIdempotencyKeyInvalidErrorHeader is not a UUID
IDEMPOTENCY_KEY_REUSEDIdempotencyKeyReusedErrorSame key, different payload
PAYTM_PHONE_REQUIREDPaytmPhoneRequiredErrorPaytm requires customerPhone

401 — unauthorized

CodeError classCause
GATEWAY_INVALID_SIGNATUREGatewayInvalidSignatureErrorWebhook signature or checksum did not verify

404 — not found

CodeError classCause
PAYMENT_NOT_FOUNDPaymentNotFoundErrorNo record for that chk_ ID
REFUND_NOT_FOUNDRefundNotFoundErrorNo record for that ref_ ID

409 — conflict

CodeError classCause
REQUEST_IN_PROGRESSIdempotencyRequestInProgressErrorThe first request with this key is still running
ORDER_CREATION_IN_PROGRESSOrderCreationInProgressErrorAnother request holds the reservation for this orderId
ORDER_ID_AMOUNT_MISMATCHOrderIdAmountMismatchErrororderId exists with a different amount
ORDER_ID_CURRENCY_MISMATCHOrderIdCurrencyMismatchErrororderId exists with a different currency

422 — unprocessable

The request is well-formed but cannot be acted on.

CodeError classCause
REFUND_NOT_ALLOWEDRefundNotAllowedErrorPayment is not SUCCESS / PARTIALLY_REFUNDED, or no webhook has set gatewayPaymentId yet
REFUND_AMOUNT_EXCEEDS_PAYMENTRefundAmountExceedsPaymentErrorRefund would exceed the original amount

500 — internal

CodeError classCause
INTERNAL_ERROR—Unhandled failure; no internals are leaked

502 — bad gateway

CodeError classCause
PAYMENT_CREATION_FAILEDPaymentCreationFailedErrorGateway returned an unexpected response on create
REFUND_FAILEDRefundFailedErrorGateway returned an unexpected response on refund
GATEWAY_MAPPING_ERRORGatewayMappingErrorGateway returned a status string checkoutOs does not recognize

Never silently map an unknown status

GatewayMappingError exists so that a gateway shipping a new status string produces a loud 502 instead of being quietly coerced into FAILED. Guessing here means mis-reporting money movement. Fail fast.

503 / 504 — gateway and store availability

CodeError classCause
GATEWAY_UNAVAILABLEGatewayUnavailableErrorNo plugin registered, the gateway is unreachable, or a gateway operation is unsupported
STORE_ERRORStoreErrorRedis read or write failed
GATEWAY_TIMEOUTGatewayTimeoutErrorUpstream call exceeded its timeout

On this page