@montarist/nestpay-api-v2
Version:
Unofficial comprehensive TypeScript API client for Nestpay payment gateway with 3D Secure support
103 lines • 3.35 kB
TypeScript
import { ErrorResponse } from '../types/interfaces';
/**
* Base Nestpay error class
*/
export declare class NestpayError extends Error {
readonly code?: string;
readonly details?: Record<string, unknown>;
constructor(message: string, code?: string, details?: Record<string, unknown>);
}
/**
* Validation error class
*/
export declare class ValidationError extends NestpayError {
readonly validationErrors: string[];
constructor(errors: string[], details?: Record<string, unknown>);
}
/**
* API communication error class
*/
export declare class ApiError extends NestpayError {
readonly statusCode?: number;
readonly response?: unknown;
constructor(message: string, statusCode?: number, response?: unknown, code?: string, details?: Record<string, unknown>);
}
/**
* Payment processing error class
*/
export declare class PaymentError extends NestpayError {
readonly transactionId?: string;
readonly orderId?: string;
readonly procReturnCode?: string;
constructor(message: string, code?: string, transactionId?: string, orderId?: string, procReturnCode?: string, details?: Record<string, unknown>);
}
/**
* 3D Secure specific error class
*/
export declare class ThreeDSecureError extends NestpayError {
readonly mdStatus?: string;
readonly cavv?: string;
readonly eci?: string;
constructor(message: string, code?: string, mdStatus?: string, cavv?: string, eci?: string, details?: Record<string, unknown>);
}
/**
* Hash verification error class
*/
export declare class HashVerificationError extends NestpayError {
readonly expectedHash?: string;
readonly receivedHash?: string;
constructor(message: string, expectedHash?: string, receivedHash?: string, details?: Record<string, unknown>);
}
/**
* Configuration error class
*/
export declare class ConfigurationError extends NestpayError {
constructor(message: string, details?: Record<string, unknown>);
}
/**
* Error handler utility class
*/
export declare class ErrorHandler {
/**
* Create error response object
* @param error Error object
* @returns Formatted error response
*/
static createErrorResponse(error: Error): ErrorResponse;
/**
* Parse API error response
* @param response API response
* @param statusCode HTTP status code
* @returns Parsed error or null if no error
*/
static parseApiError(response: any, statusCode?: number): NestpayError | null;
/**
* Map ProcReturnCode to internal error codes
* @param procReturnCode Process return code from API
* @returns Mapped error code
*/
private static mapProcReturnCodeToErrorCode;
/**
* Get 3D Secure error message based on mdStatus
* @param mdStatus MD status code
* @returns Error message
*/
private static getThreeDErrorMessage;
/**
* Determine if error is retryable
* @param error Error object
* @returns True if error is retryable
*/
static isRetryableError(error: Error): boolean;
/**
* Get user-friendly error message
* @param error Error object
* @returns User-friendly error message
*/
static getUserFriendlyMessage(error: Error): string;
}
/**
* Default error handler instance
*/
export declare const errorHandler: ErrorHandler;
//# sourceMappingURL=errors.d.ts.map