UNPKG

@montarist/nestpay-api-v2

Version:

Unofficial comprehensive TypeScript API client for Nestpay payment gateway with 3D Secure support

202 lines 6.03 kB
import { BankProvider, ThreeDModel } from '../types/enums'; import { ApiResponse, DirectPaymentRequest, DirectPaymentResponse, NestpayConfig, RefundRequest, RefundResponse, ThreeDCallbackResponse, ThreeDFormData, ThreeDPaymentRequest, ThreeDPaymentResponse, TransactionQueryRequest, TransactionQueryResponse, VoidRequest, VoidResponse } from '../types/interfaces'; /** * Enhanced Nestpay API client class with comprehensive provider support * Supports all Turkish banks with automatic endpoint management and runtime provider switching */ export declare class NestpayClient { private config; private hashUtil; private apiClient; private threeDModel; private currentProvider; private currentEndpoints; /** * Initialize enhanced Nestpay client with provider support * @param config Enhanced Nestpay configuration with provider support */ constructor(config: NestpayConfig); /** * Process direct payment (without 3D Secure) */ processDirectPayment(request: DirectPaymentRequest): Promise<ApiResponse<DirectPaymentResponse>>; /** * Initiate 3D Secure payment with model-specific implementation */ initiate3DPayment(request: ThreeDPaymentRequest): Promise<ApiResponse<ThreeDFormData>>; /** * Complete 3D Secure payment after callback */ complete3DPayment(callbackData: ThreeDCallbackResponse): Promise<ApiResponse<ThreeDPaymentResponse>>; /** * Process refund */ processRefund(request: RefundRequest): Promise<ApiResponse<RefundResponse>>; /** * Process void (cancel) */ processVoid(request: VoidRequest): Promise<ApiResponse<VoidResponse>>; /** * Query transaction status */ queryTransaction(request: TransactionQueryRequest): Promise<ApiResponse<TransactionQueryResponse>>; /** * Verify 3D Secure callback with primary status validation and optional hash verification */ verify3DCallbackHash(callbackData: Record<string, string>, strictHashValidation?: boolean): boolean; /** * Get current 3D model */ get3DModel(): ThreeDModel; /** * Set 3D model (for runtime switching if needed) */ set3DModel(model: ThreeDModel): void; /** * Get current provider */ getProvider(): BankProvider; /** * Get current provider display name */ getProviderDisplayName(): string; /** * Set provider and update endpoints (runtime provider switching) */ setProvider(provider: BankProvider, customEndpoints?: any): void; /** * Get current endpoints */ getCurrentEndpoints(): { api: string; threeD: string; }; /** * Test hash generation with bank provided example */ testHashWithBankExample(): { calculated: string; expected: string; matches: boolean; }; /** * Debug 3D Secure callback validation - shows status and optional hash analysis */ debug3DCallbackHash(callbackData: Record<string, string>): { statusValidation: { mdStatus: string; response: string; procReturnCode: string; isValid: boolean; }; hashAnalysis?: { isValid: boolean; expectedHash: string; receivedHash: string; parametersUsed: string[]; hashString: string; }; }; /** * Get all available providers */ static getAvailableProviders(): BankProvider[]; /** * Get provider display name */ static getProviderDisplayName(provider: BankProvider): string; /** * Auto-detect provider from client ID */ static detectProviderFromClientId(clientId: string): BankProvider | null; /** * Detect provider from configuration */ private detectProviderFromConfig; /** * Resolve endpoints based on current provider and configuration */ private resolveEndpoints; /** * Detect 3D model from store type */ private detectModelFromStoreType; /** * Get 3D model from request or use default */ private get3DModelFromRequest; /** * Validate configuration */ private validateConfig; /** * Build complete configuration with defaults */ private buildConfig; /** * Create configured axios instance */ private createApiClient; /** * Validate direct payment request */ private validateDirectPaymentRequest; /** * Build direct payment API request */ private buildDirectPaymentRequest; /** * Parse direct payment response */ private parseDirectPaymentResponse; /** * Validate 3D payment request */ private validate3DPaymentRequest; /** * Build 3D Secure form data with model-specific implementation */ private build3DSecureForm; /** * Build 3D form data without hash (for hash calculation) */ private build3DFormDataWithoutHash; /** * Get different callback hash verification methods to try */ private getCallbackHashMethods; /** * Generate 3D form HTML based on model */ private generate3DFormHTML; /** * Get refresh time for model */ private getRefreshTimeForModel; /** * Get pay hosting URL */ private getPayHostingUrl; /** * Verify 3D callback data with model-specific verification */ private verify3DCallback; /** * Build 3D completion request */ private build3DCompletionRequest; /** * Parse 3D payment response with model information */ private parse3DPaymentResponse; private validateRefundRequest; private buildRefundRequest; private parseRefundResponse; private validateVoidRequest; private buildVoidRequest; private parseVoidResponse; private validateQueryRequest; private buildQueryRequest; private parseQueryResponse; } //# sourceMappingURL=nestpay-client.d.ts.map