@nehorai/payments-il 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cardcom/index.cjs +734 -0
- package/dist/cardcom/index.cjs.map +1 -0
- package/dist/cardcom/index.d.cts +188 -0
- package/dist/cardcom/index.d.ts +188 -0
- package/dist/cardcom/index.js +678 -0
- package/dist/cardcom/index.js.map +1 -0
- package/dist/cardcom-provider-uGEDtf_i.d.cts +56 -0
- package/dist/cardcom-provider-uGEDtf_i.d.ts +56 -0
- package/dist/factory.cjs +1418 -0
- package/dist/factory.cjs.map +1 -0
- package/dist/factory.d.cts +67 -0
- package/dist/factory.d.ts +67 -0
- package/dist/factory.js +1381 -0
- package/dist/factory.js.map +1 -0
- package/dist/hyp/index.cjs +885 -0
- package/dist/hyp/index.cjs.map +1 -0
- package/dist/hyp/index.d.cts +119 -0
- package/dist/hyp/index.d.ts +119 -0
- package/dist/hyp/index.js +841 -0
- package/dist/hyp/index.js.map +1 -0
- package/dist/hyp-types-BTLDpI0a.d.cts +235 -0
- package/dist/hyp-types-BTLDpI0a.d.ts +235 -0
- package/dist/index.cjs +1724 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1642 -0
- package/dist/index.js.map +1 -0
- package/dist/routing/index.cjs +146 -0
- package/dist/routing/index.cjs.map +1 -0
- package/dist/routing/index.d.cts +66 -0
- package/dist/routing/index.d.ts +66 -0
- package/dist/routing/index.js +113 -0
- package/dist/routing/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/cardcom/index.ts","../../src/providers/cardcom/cardcom-provider.ts","../../src/providers/cardcom/cardcom-types.ts","../../src/providers/cardcom/cardcom-webhook-handler.ts"],"sourcesContent":["/**\r\n * Cardcom Provider Exports\r\n */\r\n\r\n// Provider and webhook handler\r\nexport { CardcomProvider, type CardcomProviderConfig } from './cardcom-provider.js';\r\nexport { CardcomWebhookHandler } from './cardcom-webhook-handler.js';\r\n\r\n// Types\r\nexport type {\r\n CardcomConfig,\r\n CardcomLowProfileRequest,\r\n CardcomLowProfileResponse,\r\n CardcomLowProfileStatusRequest,\r\n CardcomLowProfileStatusResponse,\r\n CardcomDirectChargeRequest,\r\n CardcomDirectChargeResponse,\r\n CardcomRefundRequest,\r\n CardcomRefundResponse,\r\n CardcomWebhookParams,\r\n CardcomWebhookEventType,\r\n} from './cardcom-types.js';\r\n\r\nexport {\r\n CardcomOperation,\r\n CardcomTransactionType,\r\n CARDCOM_API_BASE,\r\n CARDCOM_ENDPOINTS,\r\n CARDCOM_SUPPORTED_CURRENCIES,\r\n CARDCOM_WEBHOOK_EVENTS,\r\n CARDCOM_DEAL_RESPONSE_ACTIONS,\r\n CARDCOM_RESPONSE_CODE_MAP,\r\n CARDCOM_CURRENCY_CODES,\r\n CARDCOM_LANGUAGE_CODES,\r\n mapCardcomDealResponseToStatus,\r\n mapCardcomError,\r\n getCurrencyCode,\r\n} from './cardcom-types.js';\r\n\r\n// Webhook utilities\r\nexport {\r\n validateCardcomCallback,\r\n parseCardcomCallbackUrl,\r\n isCardcomCallbackSuccess,\r\n isCardcomCallbackAuthorized,\r\n getCardcomCallbackError,\r\n} from './cardcom-webhook-handler.js';\r\n","/**\r\n * Cardcom Provider Implementation\r\n *\r\n * Implements IPaymentProvider for Cardcom payment gateway (Israeli market).\r\n * Uses Low Profile (hosted page) for PCI compliance and direct API for operations.\r\n * Supports Two-Phase Commit (J5) with SuspendDealOnly operation.\r\n *\r\n * @see https://secure.cardcom.solutions/api/v11/swagger/ui/index\r\n */\r\n\r\nimport * as crypto from 'crypto';\r\nimport type {\r\n PaymentProvider,\r\n CreatePaymentIntentParams,\r\n PaymentIntentResult,\r\n AuthorizePaymentParams,\r\n AuthorizationResult,\r\n CapturePaymentParams,\r\n CaptureResult,\r\n VoidPaymentParams,\r\n VoidResult,\r\n RefundParams,\r\n RefundResult,\r\n ProviderHealthStatus,\r\n} from '@nehorai/payments/types';\r\nimport type {\r\n IPaymentProvider,\r\n SavePaymentMethodParams,\r\n SavePaymentMethodResult,\r\n DeletePaymentMethodResult,\r\n CreateSetupIntentParams,\r\n SetupIntentResult,\r\n CreateCustomerParams,\r\n CreateCustomerResult,\r\n} from '@nehorai/payments/providers';\r\nimport { calculateCaptureDeadline } from '@nehorai/payments/types';\r\nimport {\r\n CARDCOM_API_BASE,\r\n CARDCOM_ENDPOINTS,\r\n CARDCOM_SUPPORTED_CURRENCIES,\r\n CardcomOperation,\r\n getCurrencyCode,\r\n mapCardcomDealResponseToStatus,\r\n mapCardcomError,\r\n type CardcomLowProfileRequest,\r\n type CardcomLowProfileResponse,\r\n type CardcomLowProfileStatusResponse,\r\n type CardcomRefundRequest,\r\n type CardcomRefundResponse,\r\n} from './cardcom-types.js';\r\n\r\n/**\r\n * Cardcom provider constructor config\r\n */\r\nexport interface CardcomProviderConfig {\r\n terminalNumber: string;\r\n apiName: string;\r\n apiPassword: string;\r\n webhookSecret?: string;\r\n}\r\n\r\n/**\r\n * Cardcom Payment Provider\r\n *\r\n * Full implementation of IPaymentProvider for Cardcom.\r\n */\r\nexport class CardcomProvider implements IPaymentProvider {\r\n readonly name: PaymentProvider = 'cardcom';\r\n readonly supportedCurrencies = CARDCOM_SUPPORTED_CURRENCIES;\r\n readonly supportsRecurring = true;\r\n readonly supportsSplitPayments = false;\r\n\r\n private config: CardcomProviderConfig;\r\n\r\n constructor(config: CardcomProviderConfig) {\r\n if (!config.terminalNumber || !config.apiName || !config.apiPassword) {\r\n throw new Error(\r\n 'CardcomProvider requires terminalNumber, apiName, and apiPassword in config'\r\n );\r\n }\r\n this.config = config;\r\n }\r\n\r\n // ==========================================================================\r\n // Payment Intent Operations\r\n // ==========================================================================\r\n\r\n async createPaymentIntent(\r\n params: CreatePaymentIntentParams\r\n ): Promise<PaymentIntentResult> {\r\n try {\r\n const amountMajor = params.amount.amountMinor / 100;\r\n\r\n const operation =\r\n params.captureMethod === 'manual'\r\n ? CardcomOperation.SUSPEND_DEAL_ONLY\r\n : params.metadata?.savePaymentMethod\r\n ? CardcomOperation.BILL_AND_CREATE_TOKEN\r\n : CardcomOperation.BILL_ONLY;\r\n\r\n const request: CardcomLowProfileRequest = {\r\n TerminalNumber: this.config.terminalNumber,\r\n ApiName: this.config.apiName,\r\n ApiPassword: this.config.apiPassword,\r\n Sum: amountMajor,\r\n CoinID: getCurrencyCode(params.amount.currency),\r\n Operation: operation,\r\n Language: 'en',\r\n ReturnUrl: params.returnUrl,\r\n ErrorUrl: params.returnUrl,\r\n ProductName: params.description ?? 'Payment',\r\n InternalDealNumber: params.idempotencyKey,\r\n SendEmail: false,\r\n };\r\n\r\n if (params.metadata?.customerName) {\r\n request.CustomerName = String(params.metadata.customerName);\r\n }\r\n if (params.metadata?.customerEmail) {\r\n request.Email = String(params.metadata.customerEmail);\r\n }\r\n\r\n const response = await this.makeRequest<CardcomLowProfileResponse>(\r\n CARDCOM_ENDPOINTS.LOW_PROFILE_CREATE,\r\n request as unknown as Record<string, unknown>\r\n );\r\n\r\n if (response.ResponseCode !== 0 || !response.PaymentUrl) {\r\n return {\r\n success: false,\r\n error: mapCardcomError(response.ResponseCode),\r\n errorCode: String(response.ResponseCode),\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n providerIntentId: response.LowProfileCode!,\r\n redirectUrl: response.PaymentUrl,\r\n status: 'created',\r\n };\r\n } catch (error) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n async authorize(params: AuthorizePaymentParams): Promise<AuthorizationResult> {\r\n try {\r\n const statusResponse = await this.getLowProfileStatus(\r\n params.providerIntentId\r\n );\r\n\r\n if (!statusResponse.success || !statusResponse.data) {\r\n return {\r\n success: false,\r\n error: statusResponse.error ?? 'Failed to check payment status',\r\n };\r\n }\r\n\r\n const status = statusResponse.data;\r\n\r\n if (status.DealResponse === 1) {\r\n return {\r\n success: true,\r\n authorizationCode: status.InternalDealNumber ?? params.providerIntentId,\r\n status: 'authorized',\r\n captureDeadline: calculateCaptureDeadline(new Date()),\r\n };\r\n }\r\n\r\n if (status.DealResponse === 2) {\r\n return {\r\n success: false,\r\n error: 'Payment declined',\r\n status: 'failed',\r\n };\r\n }\r\n\r\n return {\r\n success: false,\r\n error: 'Payment not yet completed',\r\n status: 'pending_authorization',\r\n };\r\n } catch (error) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n async capture(params: CapturePaymentParams): Promise<CaptureResult> {\r\n try {\r\n const statusResponse = await this.getLowProfileStatus(\r\n params.providerIntentId\r\n );\r\n\r\n if (!statusResponse.success || !statusResponse.data) {\r\n return {\r\n success: false,\r\n error: statusResponse.error ?? 'Failed to capture payment',\r\n };\r\n }\r\n\r\n const status = statusResponse.data;\r\n\r\n if (status.DealResponse === 1) {\r\n return {\r\n success: true,\r\n providerTransactionId: status.InternalDealNumber ?? params.providerIntentId,\r\n status: 'captured',\r\n capturedAmount: {\r\n amountMinor: Math.round((status.Amount ?? 0) * 100),\r\n currency: status.Currency ?? params.amount?.currency ?? 'ILS',\r\n },\r\n };\r\n }\r\n\r\n return {\r\n success: false,\r\n error: 'Payment not authorized for capture',\r\n status: mapCardcomDealResponseToStatus(status.DealResponse ?? 3),\r\n };\r\n } catch (error) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n async void(_params: VoidPaymentParams): Promise<VoidResult> {\r\n return {\r\n success: false,\r\n error: 'Void operation not supported via API. Please use Cardcom merchant dashboard.',\r\n };\r\n }\r\n\r\n async refund(params: RefundParams): Promise<RefundResult> {\r\n try {\r\n const refundAmount = params.amount\r\n ? params.amount.amountMinor / 100\r\n : undefined;\r\n\r\n if (!refundAmount) {\r\n return {\r\n success: false,\r\n error: 'Refund amount is required',\r\n };\r\n }\r\n\r\n const request: CardcomRefundRequest = {\r\n TerminalNumber: this.config.terminalNumber,\r\n ApiName: this.config.apiName,\r\n ApiPassword: this.config.apiPassword,\r\n InternalDealNumber: params.providerTransactionId,\r\n Amount: refundAmount,\r\n CoinID: params.amount ? getCurrencyCode(params.amount.currency) : 1,\r\n };\r\n\r\n const response = await this.makeRequest<CardcomRefundResponse>(\r\n CARDCOM_ENDPOINTS.REFUND,\r\n request as unknown as Record<string, unknown>\r\n );\r\n\r\n if (response.ResponseCode !== 0) {\r\n return {\r\n success: false,\r\n error: mapCardcomError(response.ResponseCode),\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n providerRefundId: response.InternalDealNumber ?? params.providerTransactionId,\r\n refundedAmount: {\r\n amountMinor: Math.round((response.Amount ?? 0) * 100),\r\n currency: params.amount?.currency ?? 'ILS',\r\n },\r\n status: 'succeeded',\r\n };\r\n } catch (error) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n // ==========================================================================\r\n // Payment Method Tokenization\r\n // ==========================================================================\r\n\r\n async createSetupIntent(\r\n params: CreateSetupIntentParams\r\n ): Promise<SetupIntentResult> {\r\n try {\r\n const request: CardcomLowProfileRequest = {\r\n TerminalNumber: this.config.terminalNumber,\r\n ApiName: this.config.apiName,\r\n ApiPassword: this.config.apiPassword,\r\n Sum: 0,\r\n Operation: CardcomOperation.CREATE_TOKEN_ONLY,\r\n Language: 'en',\r\n InternalDealNumber: `setup_${params.userId}_${Date.now()}`,\r\n };\r\n\r\n const response = await this.makeRequest<CardcomLowProfileResponse>(\r\n CARDCOM_ENDPOINTS.LOW_PROFILE_CREATE,\r\n request as unknown as Record<string, unknown>\r\n );\r\n\r\n if (response.ResponseCode !== 0 || !response.PaymentUrl) {\r\n return {\r\n success: false,\r\n error: mapCardcomError(response.ResponseCode),\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n setupIntentId: response.LowProfileCode!,\r\n clientSecret: response.PaymentUrl,\r\n };\r\n } catch (error) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n async savePaymentMethod(\r\n params: SavePaymentMethodParams\r\n ): Promise<SavePaymentMethodResult> {\r\n try {\r\n const lowProfileCode = params.setupData.lowProfileCode as string;\r\n\r\n if (!lowProfileCode) {\r\n return {\r\n success: false,\r\n error: 'Low profile code is required',\r\n };\r\n }\r\n\r\n const statusResponse = await this.getLowProfileStatus(lowProfileCode);\r\n\r\n if (!statusResponse.success || !statusResponse.data) {\r\n return {\r\n success: false,\r\n error: statusResponse.error ?? 'Failed to retrieve payment method',\r\n };\r\n }\r\n\r\n const status = statusResponse.data;\r\n\r\n if (!status.Token) {\r\n return {\r\n success: false,\r\n error: 'No token created',\r\n };\r\n }\r\n\r\n const [expMonth, expYear] = (status.CardExpiration ?? '/').split('/');\r\n\r\n return {\r\n success: true,\r\n paymentMethodId: status.Token,\r\n cardBrand: status.CardType ?? 'unknown',\r\n cardLast4: status.CardMask?.slice(-4),\r\n cardExpMonth: expMonth?.padStart(2, '0'),\r\n cardExpYear: expYear ? `20${expYear}` : undefined,\r\n cardBin: status.CardBin,\r\n };\r\n } catch (error) {\r\n return this.handleError(error);\r\n }\r\n }\r\n\r\n async deletePaymentMethod(\r\n _paymentMethodId: string\r\n ): Promise<DeletePaymentMethodResult> {\r\n return {\r\n success: true,\r\n };\r\n }\r\n\r\n // ==========================================================================\r\n // Customer Management\r\n // ==========================================================================\r\n\r\n async createCustomer(params: CreateCustomerParams): Promise<CreateCustomerResult> {\r\n return {\r\n success: true,\r\n customerId: params.userId,\r\n };\r\n }\r\n\r\n async getOrCreateCustomer(\r\n userId: string,\r\n email: string\r\n ): Promise<CreateCustomerResult> {\r\n return this.createCustomer({ userId, email });\r\n }\r\n\r\n // ==========================================================================\r\n // Health & Status\r\n // ==========================================================================\r\n\r\n async getHealth(): Promise<ProviderHealthStatus> {\r\n const start = Date.now();\r\n try {\r\n const request: CardcomLowProfileRequest = {\r\n TerminalNumber: this.config.terminalNumber,\r\n ApiName: this.config.apiName,\r\n ApiPassword: this.config.apiPassword,\r\n Sum: 1,\r\n Operation: CardcomOperation.BILL_ONLY,\r\n InternalDealNumber: `health_check_${Date.now()}`,\r\n };\r\n\r\n const response = await this.makeRequest<CardcomLowProfileResponse>(\r\n CARDCOM_ENDPOINTS.LOW_PROFILE_CREATE,\r\n request as unknown as Record<string, unknown>\r\n );\r\n\r\n const healthy = response.ResponseCode === 0 || response.ResponseCode === 1;\r\n\r\n return {\r\n provider: 'cardcom',\r\n healthy,\r\n lastChecked: new Date(),\r\n avgLatencyMs: Date.now() - start,\r\n circuitBreakerOpen: false,\r\n };\r\n } catch {\r\n return {\r\n provider: 'cardcom',\r\n healthy: false,\r\n lastChecked: new Date(),\r\n circuitBreakerOpen: false,\r\n };\r\n }\r\n }\r\n\r\n validateWebhookSignature(payload: string, signature: string): boolean {\r\n if (!this.config.webhookSecret) {\r\n return false;\r\n }\r\n\r\n try {\r\n const expectedSignature = crypto\r\n .createHmac('sha256', this.config.webhookSecret)\r\n .update(payload)\r\n .digest('hex');\r\n\r\n return crypto.timingSafeEqual(\r\n Buffer.from(signature),\r\n Buffer.from(expectedSignature)\r\n );\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n async getPaymentIntentStatus(\r\n providerIntentId: string\r\n ): Promise<{ status: string; error?: string }> {\r\n try {\r\n const result = await this.getLowProfileStatus(providerIntentId);\r\n\r\n if (!result.success || !result.data) {\r\n return {\r\n status: 'unknown',\r\n error: result.error,\r\n };\r\n }\r\n\r\n const status = mapCardcomDealResponseToStatus(\r\n result.data.DealResponse ?? 0\r\n );\r\n\r\n return { status };\r\n } catch (error) {\r\n return {\r\n status: 'unknown',\r\n error: error instanceof Error ? error.message : 'Unknown error',\r\n };\r\n }\r\n }\r\n\r\n // ==========================================================================\r\n // Helper Methods\r\n // ==========================================================================\r\n\r\n private async makeRequest<T>(\r\n endpoint: string,\r\n data: Record<string, unknown>\r\n ): Promise<T> {\r\n const url = `${CARDCOM_API_BASE}${endpoint}`;\r\n\r\n const response = await fetch(url, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n body: JSON.stringify(data),\r\n });\r\n\r\n if (!response.ok) {\r\n throw new Error(`Cardcom API error: ${response.status} ${response.statusText}`);\r\n }\r\n\r\n return response.json() as Promise<T>;\r\n }\r\n\r\n private async getLowProfileStatus(\r\n lowProfileCode: string\r\n ): Promise<{\r\n success: boolean;\r\n data?: CardcomLowProfileStatusResponse;\r\n error?: string;\r\n }> {\r\n try {\r\n const params = new URLSearchParams({\r\n terminalnumber: this.config.terminalNumber,\r\n lowprofilecode: lowProfileCode,\r\n username: this.config.apiName,\r\n });\r\n\r\n const url = `${CARDCOM_API_BASE}${CARDCOM_ENDPOINTS.LOW_PROFILE_STATUS}?${params}`;\r\n\r\n const response = await fetch(url, {\r\n method: 'GET',\r\n });\r\n\r\n if (!response.ok) {\r\n return {\r\n success: false,\r\n error: `Status check failed: ${response.status}`,\r\n };\r\n }\r\n\r\n const data = (await response.json()) as CardcomLowProfileStatusResponse;\r\n\r\n if (data.ResponseCode !== 0) {\r\n return {\r\n success: false,\r\n error: mapCardcomError(data.ResponseCode),\r\n };\r\n }\r\n\r\n return { success: true, data };\r\n } catch (error) {\r\n return {\r\n success: false,\r\n error: error instanceof Error ? error.message : 'Status check failed',\r\n };\r\n }\r\n }\r\n\r\n private handleError(error: unknown): {\r\n success: false;\r\n error: string;\r\n errorCode?: string;\r\n } {\r\n const errorMessage =\r\n error instanceof Error ? error.message : 'Unknown error occurred';\r\n\r\n return {\r\n success: false,\r\n error: errorMessage,\r\n };\r\n }\r\n}\r\n","/**\r\n * Cardcom Type Definitions\r\n *\r\n * Type definitions for Cardcom payment gateway API v11.\r\n * Supports JSON API endpoints for Low Profile (hosted page) and direct transactions.\r\n *\r\n * @see https://secure.cardcom.solutions/api/v11/swagger/ui/index\r\n */\r\n\r\nimport type { TransactionStatus } from '@nehorai/payments/types';\r\n\r\n// ============================================================================\r\n// API Configuration\r\n// ============================================================================\r\n\r\nexport const CARDCOM_API_BASE = 'https://secure.cardcom.solutions';\r\n\r\nexport const CARDCOM_ENDPOINTS = {\r\n LOW_PROFILE_CREATE: '/api/v11/LowProfile/Create',\r\n LOW_PROFILE_STATUS: '/Interface/BillGoldGetLowProfileIndicator.aspx',\r\n DIRECT_CHARGE: '/api/v11/Transactions/Transaction',\r\n REFUND: '/api/v11/Transactions/RefundByTransactionId',\r\n} as const;\r\n\r\nexport const CARDCOM_SUPPORTED_CURRENCIES = ['ILS', 'USD', 'EUR', 'GBP'] as const;\r\n\r\nexport const CARDCOM_API_VERSION = 'v11';\r\n\r\n// ============================================================================\r\n// Cardcom Configuration\r\n// ============================================================================\r\n\r\nexport interface CardcomConfig {\r\n /** Terminal number (merchant ID) */\r\n terminalNumber: string;\r\n /** API username */\r\n apiName: string;\r\n /** API password */\r\n apiPassword: string;\r\n /** Webhook secret for signature validation */\r\n webhookSecret?: string;\r\n /** Environment (sandbox uses same endpoints but different credentials) */\r\n environment: 'sandbox' | 'production';\r\n}\r\n\r\n// ============================================================================\r\n// Operation Types\r\n// ============================================================================\r\n\r\nexport enum CardcomOperation {\r\n /** Charge immediately */\r\n BILL_ONLY = 1,\r\n /** Charge + save card token */\r\n BILL_AND_CREATE_TOKEN = 2,\r\n /** Save card without charging */\r\n CREATE_TOKEN_ONLY = 3,\r\n /** Authorize without capture (J5) */\r\n SUSPEND_DEAL_ONLY = 4,\r\n}\r\n\r\nexport enum CardcomTransactionType {\r\n REGULAR = 1,\r\n CREDIT = 2,\r\n INSTALLMENTS = 3,\r\n}\r\n\r\n// ============================================================================\r\n// Request Types\r\n// ============================================================================\r\n\r\nexport interface CardcomLowProfileRequest {\r\n TerminalNumber: string;\r\n ApiName: string;\r\n ApiPassword: string;\r\n Sum: number;\r\n CoinID?: number;\r\n Operation?: CardcomOperation;\r\n Language?: string;\r\n ReturnUrl?: string;\r\n ErrorUrl?: string;\r\n ProductName?: string;\r\n CustomerName?: string;\r\n Email?: string;\r\n InvoiceLanguage?: string;\r\n SendEmail?: boolean;\r\n IndicatorUrl?: string;\r\n InternalDealNumber?: string;\r\n}\r\n\r\nexport interface CardcomLowProfileStatusRequest {\r\n terminalnumber: string;\r\n lowprofilecode: string;\r\n username: string;\r\n}\r\n\r\nexport interface CardcomDirectChargeRequest {\r\n TerminalNumber: string;\r\n ApiName: string;\r\n ApiPassword: string;\r\n CardNumber: string;\r\n CVV: string;\r\n Year: string;\r\n Month: string;\r\n CardOwnerID: string;\r\n Sum: number;\r\n CoinID?: number;\r\n NumOfPayments?: number;\r\n Operation?: CardcomOperation;\r\n Token?: string;\r\n}\r\n\r\nexport interface CardcomRefundRequest {\r\n TerminalNumber: string;\r\n ApiName: string;\r\n ApiPassword: string;\r\n InternalDealNumber: string;\r\n Amount: number;\r\n CoinID?: number;\r\n}\r\n\r\n// ============================================================================\r\n// Response Types\r\n// ============================================================================\r\n\r\nexport interface CardcomLowProfileResponse {\r\n ResponseCode: number;\r\n Description?: string;\r\n LowProfileCode?: string;\r\n PaymentUrl?: string;\r\n DealCode?: string;\r\n}\r\n\r\nexport interface CardcomLowProfileStatusResponse {\r\n ResponseCode: number;\r\n Description?: string;\r\n DealResponse?: number;\r\n OperationResponse?: number;\r\n InternalDealNumber?: string;\r\n Token?: string;\r\n CardMask?: string;\r\n CardType?: string;\r\n CardExpiration?: string;\r\n Amount?: number;\r\n Currency?: string;\r\n CardBin?: string;\r\n}\r\n\r\nexport interface CardcomDirectChargeResponse {\r\n ResponseCode: number;\r\n Description?: string;\r\n InternalDealNumber?: string;\r\n ApprovalNumber?: string;\r\n CardMask?: string;\r\n Token?: string;\r\n DealCode?: string;\r\n}\r\n\r\nexport interface CardcomRefundResponse {\r\n ResponseCode: number;\r\n Description?: string;\r\n InternalDealNumber?: string;\r\n Amount?: number;\r\n}\r\n\r\n// ============================================================================\r\n// Webhook Types\r\n// ============================================================================\r\n\r\nexport interface CardcomWebhookParams {\r\n ResponseCode?: string;\r\n LowProfileCode?: string;\r\n DealResponse?: string;\r\n OperationResponse?: string;\r\n InternalDealNumber?: string;\r\n Amount?: string;\r\n Currency?: string;\r\n CardMask?: string;\r\n Token?: string;\r\n}\r\n\r\nexport const CARDCOM_WEBHOOK_EVENTS = [\r\n 'payment.completed',\r\n 'payment.declined',\r\n 'payment.authorized',\r\n] as const;\r\n\r\nexport type CardcomWebhookEventType = (typeof CARDCOM_WEBHOOK_EVENTS)[number];\r\n\r\nexport const CARDCOM_DEAL_RESPONSE_ACTIONS: Record<number, string> = {\r\n 0: 'pending',\r\n 1: 'approved',\r\n 2: 'declined',\r\n 3: 'error',\r\n};\r\n\r\n// ============================================================================\r\n// Response Code Mapping\r\n// ============================================================================\r\n\r\nexport const CARDCOM_RESPONSE_CODE_MAP: Record<number, TransactionStatus> = {\r\n 0: 'created',\r\n 1: 'failed',\r\n 2: 'failed',\r\n 3: 'failed',\r\n 4: 'failed',\r\n 5: 'failed',\r\n 6: 'failed',\r\n 7: 'failed',\r\n 8: 'failed',\r\n 9: 'failed',\r\n 10: 'failed',\r\n};\r\n\r\nexport function mapCardcomDealResponseToStatus(\r\n dealResponse: number\r\n): TransactionStatus {\r\n switch (dealResponse) {\r\n case 0:\r\n return 'pending_authorization';\r\n case 1:\r\n return 'captured';\r\n case 2:\r\n return 'failed';\r\n case 3:\r\n return 'failed';\r\n default:\r\n return 'failed';\r\n }\r\n}\r\n\r\nexport function mapCardcomError(responseCode: number): string {\r\n const errorMessages: Record<number, string> = {\r\n 0: 'Success',\r\n 1: 'General error',\r\n 2: 'Invalid API credentials',\r\n 3: 'Invalid terminal number',\r\n 4: 'Invalid operation type',\r\n 5: 'Invalid card details',\r\n 6: 'Card declined by issuer',\r\n 7: 'Insufficient funds',\r\n 8: 'Invalid amount',\r\n 9: 'Transaction not found',\r\n 10: 'Duplicate transaction',\r\n 11: 'Terminal not active',\r\n 12: 'CVV validation failed',\r\n 13: 'Card expired',\r\n 14: 'Invalid currency',\r\n 15: 'Operation not supported',\r\n };\r\n\r\n return errorMessages[responseCode] ?? `Error code ${responseCode}`;\r\n}\r\n\r\nexport const CARDCOM_CURRENCY_CODES: Record<string, number> = {\r\n ILS: 1,\r\n USD: 2,\r\n EUR: 3,\r\n GBP: 4,\r\n};\r\n\r\nexport function getCurrencyCode(currency: string): number {\r\n return CARDCOM_CURRENCY_CODES[currency.toUpperCase()] ?? 1;\r\n}\r\n\r\nexport const CARDCOM_LANGUAGE_CODES = {\r\n en: 'en',\r\n he: 'he',\r\n} as const;\r\n","/**\r\n * Cardcom Webhook Handler\r\n *\r\n * Processes incoming Cardcom webhooks with idempotency.\r\n * Maps Cardcom callback events to transaction status updates.\r\n *\r\n * Cardcom uses GET callback parameters instead of POST webhooks.\r\n * Parameters are sent to ReturnUrl after payment completion.\r\n */\r\n\r\nimport type {\r\n PaymentProvider,\r\n TransactionStatus,\r\n WebhookProcessingResult,\r\n ReconciliationResult,\r\n} from '@nehorai/payments/types';\r\nimport type {\r\n IWebhookHandler,\r\n ParsedWebhookEvent,\r\n ParseWebhookResult,\r\n} from '@nehorai/payments/providers';\r\nimport {\r\n CARDCOM_WEBHOOK_EVENTS,\r\n CARDCOM_DEAL_RESPONSE_ACTIONS,\r\n mapCardcomDealResponseToStatus,\r\n type CardcomWebhookEventType,\r\n type CardcomWebhookParams,\r\n} from './cardcom-types.js';\r\n\r\n/**\r\n * Cardcom Webhook Handler Implementation\r\n */\r\nexport class CardcomWebhookHandler implements IWebhookHandler {\r\n readonly provider: PaymentProvider = 'cardcom';\r\n readonly supportedEventTypes = CARDCOM_WEBHOOK_EVENTS;\r\n\r\n parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult {\r\n try {\r\n const params = rawPayload as unknown as CardcomWebhookParams;\r\n\r\n const responseCode = parseInt(params.ResponseCode ?? '1', 10);\r\n const dealResponse = parseInt(params.DealResponse ?? '0', 10);\r\n const lowProfileCode = params.LowProfileCode ?? '';\r\n const internalDealNumber = params.InternalDealNumber ?? '';\r\n\r\n if (!lowProfileCode && !internalDealNumber) {\r\n return {\r\n success: false,\r\n error: 'Missing LowProfileCode or InternalDealNumber in callback',\r\n };\r\n }\r\n\r\n let eventType: CardcomWebhookEventType;\r\n if (dealResponse === 1) {\r\n eventType = 'payment.completed';\r\n } else if (dealResponse === 2) {\r\n eventType = 'payment.declined';\r\n } else if (dealResponse === 0 && responseCode === 0) {\r\n eventType = 'payment.authorized';\r\n } else {\r\n eventType = 'payment.declined';\r\n }\r\n\r\n const status = mapCardcomDealResponseToStatus(dealResponse);\r\n\r\n const amountString = params.Amount ?? '0';\r\n const amountMajor = parseFloat(amountString);\r\n const amountMinor = Math.round(amountMajor * 100);\r\n\r\n const parsed: ParsedWebhookEvent = {\r\n provider: 'cardcom',\r\n eventId: `${lowProfileCode}_${internalDealNumber}_${Date.now()}`,\r\n eventType,\r\n providerTransactionId: internalDealNumber || lowProfileCode,\r\n timestamp: new Date(),\r\n rawPayload,\r\n newStatus: status,\r\n amountMinor,\r\n currency: params.Currency ?? 'ILS',\r\n };\r\n\r\n if (dealResponse === 2 || responseCode !== 0) {\r\n parsed.error = {\r\n code: String(responseCode),\r\n message: CARDCOM_DEAL_RESPONSE_ACTIONS[dealResponse] ?? 'Payment failed',\r\n };\r\n }\r\n\r\n return { success: true, event: parsed };\r\n } catch (error) {\r\n return {\r\n success: false,\r\n error: error instanceof Error ? error.message : 'Parse error',\r\n };\r\n }\r\n }\r\n\r\n async processEvent(\r\n event: ParsedWebhookEvent\r\n ): Promise<WebhookProcessingResult> {\r\n const action = this.getActionForEvent(event.eventType);\r\n\r\n if (action === 'ignored') {\r\n return {\r\n success: true,\r\n action: 'ignored_event_type',\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n transactionId: event.providerTransactionId,\r\n action: 'status_updated',\r\n };\r\n }\r\n\r\n canHandle(eventType: string): boolean {\r\n return this.supportedEventTypes.includes(\r\n eventType as CardcomWebhookEventType\r\n );\r\n }\r\n\r\n async reconcile(\r\n _transactionId: string,\r\n _providerTransactionId: string\r\n ): Promise<ReconciliationResult> {\r\n return {\r\n reconciled: false,\r\n finalStatus: 'created',\r\n source: 'provider_query',\r\n statusChanged: false,\r\n };\r\n }\r\n\r\n mapEventType(providerEventType: string): string {\r\n return providerEventType;\r\n }\r\n\r\n mapStatus(providerStatus: string): TransactionStatus | null {\r\n const dealResponse = parseInt(providerStatus, 10);\r\n if (isNaN(dealResponse)) {\r\n return null;\r\n }\r\n return mapCardcomDealResponseToStatus(dealResponse);\r\n }\r\n\r\n private getActionForEvent(eventType: string): 'status_update' | 'ignored' {\r\n switch (eventType) {\r\n case 'payment.completed':\r\n case 'payment.declined':\r\n case 'payment.authorized':\r\n return 'status_update';\r\n default:\r\n return 'ignored';\r\n }\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Callback Utility Functions\r\n// ============================================================================\r\n\r\nexport function validateCardcomCallback(\r\n params: Record<string, unknown>\r\n): { valid: boolean; error?: string } {\r\n const requiredFields = ['ResponseCode', 'LowProfileCode'];\r\n\r\n for (const field of requiredFields) {\r\n if (!params[field]) {\r\n return {\r\n valid: false,\r\n error: `Missing required field: ${field}`,\r\n };\r\n }\r\n }\r\n\r\n const responseCode = parseInt(String(params.ResponseCode), 10);\r\n if (isNaN(responseCode)) {\r\n return {\r\n valid: false,\r\n error: 'Invalid ResponseCode format',\r\n };\r\n }\r\n\r\n return { valid: true };\r\n}\r\n\r\nexport function parseCardcomCallbackUrl(url: string): CardcomWebhookParams {\r\n try {\r\n const urlObj = new URL(url);\r\n const params: CardcomWebhookParams = {};\r\n\r\n params.ResponseCode = urlObj.searchParams.get('ResponseCode') ?? undefined;\r\n params.LowProfileCode =\r\n urlObj.searchParams.get('LowProfileCode') ?? undefined;\r\n params.DealResponse = urlObj.searchParams.get('DealResponse') ?? undefined;\r\n params.OperationResponse =\r\n urlObj.searchParams.get('OperationResponse') ?? undefined;\r\n params.InternalDealNumber =\r\n urlObj.searchParams.get('InternalDealNumber') ?? undefined;\r\n params.Amount = urlObj.searchParams.get('Amount') ?? undefined;\r\n params.Currency = urlObj.searchParams.get('Currency') ?? undefined;\r\n params.CardMask = urlObj.searchParams.get('CardMask') ?? undefined;\r\n params.Token = urlObj.searchParams.get('Token') ?? undefined;\r\n\r\n return params;\r\n } catch {\r\n return {};\r\n }\r\n}\r\n\r\nexport function isCardcomCallbackSuccess(params: CardcomWebhookParams): boolean {\r\n const responseCode = parseInt(params.ResponseCode ?? '1', 10);\r\n const dealResponse = parseInt(params.DealResponse ?? '0', 10);\r\n\r\n return responseCode === 0 && dealResponse === 1;\r\n}\r\n\r\nexport function isCardcomCallbackAuthorized(\r\n params: CardcomWebhookParams\r\n): boolean {\r\n const responseCode = parseInt(params.ResponseCode ?? '1', 10);\r\n const dealResponse = parseInt(params.DealResponse ?? '0', 10);\r\n\r\n return responseCode === 0 && (dealResponse === 0 || dealResponse === 1);\r\n}\r\n\r\nexport function getCardcomCallbackError(\r\n params: CardcomWebhookParams\r\n): string | null {\r\n const responseCode = parseInt(params.ResponseCode ?? '1', 10);\r\n const dealResponse = parseInt(params.DealResponse ?? '0', 10);\r\n\r\n if (responseCode === 0 && dealResponse === 1) {\r\n return null;\r\n }\r\n\r\n if (dealResponse === 2) {\r\n return 'Payment declined by card issuer';\r\n }\r\n\r\n if (responseCode !== 0) {\r\n return `Payment failed with code ${responseCode}`;\r\n }\r\n\r\n return 'Payment processing error';\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,aAAwB;AAyBxB,mBAAyC;;;ACpBlC,IAAM,mBAAmB;AAEzB,IAAM,oBAAoB;AAAA,EAC/B,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf,QAAQ;AACV;AAEO,IAAM,+BAA+B,CAAC,OAAO,OAAO,OAAO,KAAK;AAyBhE,IAAK,mBAAL,kBAAKA,sBAAL;AAEL,EAAAA,oCAAA,eAAY,KAAZ;AAEA,EAAAA,oCAAA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B,KAAK,EAAE;AAC5D,QAAM,eAAe,SAAS,OAAO,gBAAgB,KAAK,EAAE;AAE5D,MAAI,iBAAiB,KAAK,iBAAiB,GAAG;AAC5C,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,GAAG;AACtB,WAAO,4BAA4B,YAAY;AAAA,EACjD;AAEA,SAAO;AACT;","names":["CardcomOperation","CardcomTransactionType"]}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
export { C as CardcomProvider, a as CardcomProviderConfig } from '../cardcom-provider-uGEDtf_i.cjs';
|
|
2
|
+
import { TransactionStatus, PaymentProvider, WebhookProcessingResult, ReconciliationResult } from '@nehorai/payments/types';
|
|
3
|
+
import { IWebhookHandler, ParseWebhookResult, ParsedWebhookEvent } from '@nehorai/payments/providers';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cardcom Type Definitions
|
|
7
|
+
*
|
|
8
|
+
* Type definitions for Cardcom payment gateway API v11.
|
|
9
|
+
* Supports JSON API endpoints for Low Profile (hosted page) and direct transactions.
|
|
10
|
+
*
|
|
11
|
+
* @see https://secure.cardcom.solutions/api/v11/swagger/ui/index
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare const CARDCOM_API_BASE = "https://secure.cardcom.solutions";
|
|
15
|
+
declare const CARDCOM_ENDPOINTS: {
|
|
16
|
+
readonly LOW_PROFILE_CREATE: "/api/v11/LowProfile/Create";
|
|
17
|
+
readonly LOW_PROFILE_STATUS: "/Interface/BillGoldGetLowProfileIndicator.aspx";
|
|
18
|
+
readonly DIRECT_CHARGE: "/api/v11/Transactions/Transaction";
|
|
19
|
+
readonly REFUND: "/api/v11/Transactions/RefundByTransactionId";
|
|
20
|
+
};
|
|
21
|
+
declare const CARDCOM_SUPPORTED_CURRENCIES: readonly ["ILS", "USD", "EUR", "GBP"];
|
|
22
|
+
interface CardcomConfig {
|
|
23
|
+
/** Terminal number (merchant ID) */
|
|
24
|
+
terminalNumber: string;
|
|
25
|
+
/** API username */
|
|
26
|
+
apiName: string;
|
|
27
|
+
/** API password */
|
|
28
|
+
apiPassword: string;
|
|
29
|
+
/** Webhook secret for signature validation */
|
|
30
|
+
webhookSecret?: string;
|
|
31
|
+
/** Environment (sandbox uses same endpoints but different credentials) */
|
|
32
|
+
environment: 'sandbox' | 'production';
|
|
33
|
+
}
|
|
34
|
+
declare enum CardcomOperation {
|
|
35
|
+
/** Charge immediately */
|
|
36
|
+
BILL_ONLY = 1,
|
|
37
|
+
/** Charge + save card token */
|
|
38
|
+
BILL_AND_CREATE_TOKEN = 2,
|
|
39
|
+
/** Save card without charging */
|
|
40
|
+
CREATE_TOKEN_ONLY = 3,
|
|
41
|
+
/** Authorize without capture (J5) */
|
|
42
|
+
SUSPEND_DEAL_ONLY = 4
|
|
43
|
+
}
|
|
44
|
+
declare enum CardcomTransactionType {
|
|
45
|
+
REGULAR = 1,
|
|
46
|
+
CREDIT = 2,
|
|
47
|
+
INSTALLMENTS = 3
|
|
48
|
+
}
|
|
49
|
+
interface CardcomLowProfileRequest {
|
|
50
|
+
TerminalNumber: string;
|
|
51
|
+
ApiName: string;
|
|
52
|
+
ApiPassword: string;
|
|
53
|
+
Sum: number;
|
|
54
|
+
CoinID?: number;
|
|
55
|
+
Operation?: CardcomOperation;
|
|
56
|
+
Language?: string;
|
|
57
|
+
ReturnUrl?: string;
|
|
58
|
+
ErrorUrl?: string;
|
|
59
|
+
ProductName?: string;
|
|
60
|
+
CustomerName?: string;
|
|
61
|
+
Email?: string;
|
|
62
|
+
InvoiceLanguage?: string;
|
|
63
|
+
SendEmail?: boolean;
|
|
64
|
+
IndicatorUrl?: string;
|
|
65
|
+
InternalDealNumber?: string;
|
|
66
|
+
}
|
|
67
|
+
interface CardcomLowProfileStatusRequest {
|
|
68
|
+
terminalnumber: string;
|
|
69
|
+
lowprofilecode: string;
|
|
70
|
+
username: string;
|
|
71
|
+
}
|
|
72
|
+
interface CardcomDirectChargeRequest {
|
|
73
|
+
TerminalNumber: string;
|
|
74
|
+
ApiName: string;
|
|
75
|
+
ApiPassword: string;
|
|
76
|
+
CardNumber: string;
|
|
77
|
+
CVV: string;
|
|
78
|
+
Year: string;
|
|
79
|
+
Month: string;
|
|
80
|
+
CardOwnerID: string;
|
|
81
|
+
Sum: number;
|
|
82
|
+
CoinID?: number;
|
|
83
|
+
NumOfPayments?: number;
|
|
84
|
+
Operation?: CardcomOperation;
|
|
85
|
+
Token?: string;
|
|
86
|
+
}
|
|
87
|
+
interface CardcomRefundRequest {
|
|
88
|
+
TerminalNumber: string;
|
|
89
|
+
ApiName: string;
|
|
90
|
+
ApiPassword: string;
|
|
91
|
+
InternalDealNumber: string;
|
|
92
|
+
Amount: number;
|
|
93
|
+
CoinID?: number;
|
|
94
|
+
}
|
|
95
|
+
interface CardcomLowProfileResponse {
|
|
96
|
+
ResponseCode: number;
|
|
97
|
+
Description?: string;
|
|
98
|
+
LowProfileCode?: string;
|
|
99
|
+
PaymentUrl?: string;
|
|
100
|
+
DealCode?: string;
|
|
101
|
+
}
|
|
102
|
+
interface CardcomLowProfileStatusResponse {
|
|
103
|
+
ResponseCode: number;
|
|
104
|
+
Description?: string;
|
|
105
|
+
DealResponse?: number;
|
|
106
|
+
OperationResponse?: number;
|
|
107
|
+
InternalDealNumber?: string;
|
|
108
|
+
Token?: string;
|
|
109
|
+
CardMask?: string;
|
|
110
|
+
CardType?: string;
|
|
111
|
+
CardExpiration?: string;
|
|
112
|
+
Amount?: number;
|
|
113
|
+
Currency?: string;
|
|
114
|
+
CardBin?: string;
|
|
115
|
+
}
|
|
116
|
+
interface CardcomDirectChargeResponse {
|
|
117
|
+
ResponseCode: number;
|
|
118
|
+
Description?: string;
|
|
119
|
+
InternalDealNumber?: string;
|
|
120
|
+
ApprovalNumber?: string;
|
|
121
|
+
CardMask?: string;
|
|
122
|
+
Token?: string;
|
|
123
|
+
DealCode?: string;
|
|
124
|
+
}
|
|
125
|
+
interface CardcomRefundResponse {
|
|
126
|
+
ResponseCode: number;
|
|
127
|
+
Description?: string;
|
|
128
|
+
InternalDealNumber?: string;
|
|
129
|
+
Amount?: number;
|
|
130
|
+
}
|
|
131
|
+
interface CardcomWebhookParams {
|
|
132
|
+
ResponseCode?: string;
|
|
133
|
+
LowProfileCode?: string;
|
|
134
|
+
DealResponse?: string;
|
|
135
|
+
OperationResponse?: string;
|
|
136
|
+
InternalDealNumber?: string;
|
|
137
|
+
Amount?: string;
|
|
138
|
+
Currency?: string;
|
|
139
|
+
CardMask?: string;
|
|
140
|
+
Token?: string;
|
|
141
|
+
}
|
|
142
|
+
declare const CARDCOM_WEBHOOK_EVENTS: readonly ["payment.completed", "payment.declined", "payment.authorized"];
|
|
143
|
+
type CardcomWebhookEventType = (typeof CARDCOM_WEBHOOK_EVENTS)[number];
|
|
144
|
+
declare const CARDCOM_DEAL_RESPONSE_ACTIONS: Record<number, string>;
|
|
145
|
+
declare const CARDCOM_RESPONSE_CODE_MAP: Record<number, TransactionStatus>;
|
|
146
|
+
declare function mapCardcomDealResponseToStatus(dealResponse: number): TransactionStatus;
|
|
147
|
+
declare function mapCardcomError(responseCode: number): string;
|
|
148
|
+
declare const CARDCOM_CURRENCY_CODES: Record<string, number>;
|
|
149
|
+
declare function getCurrencyCode(currency: string): number;
|
|
150
|
+
declare const CARDCOM_LANGUAGE_CODES: {
|
|
151
|
+
readonly en: "en";
|
|
152
|
+
readonly he: "he";
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Cardcom Webhook Handler
|
|
157
|
+
*
|
|
158
|
+
* Processes incoming Cardcom webhooks with idempotency.
|
|
159
|
+
* Maps Cardcom callback events to transaction status updates.
|
|
160
|
+
*
|
|
161
|
+
* Cardcom uses GET callback parameters instead of POST webhooks.
|
|
162
|
+
* Parameters are sent to ReturnUrl after payment completion.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Cardcom Webhook Handler Implementation
|
|
167
|
+
*/
|
|
168
|
+
declare class CardcomWebhookHandler implements IWebhookHandler {
|
|
169
|
+
readonly provider: PaymentProvider;
|
|
170
|
+
readonly supportedEventTypes: readonly ["payment.completed", "payment.declined", "payment.authorized"];
|
|
171
|
+
parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult;
|
|
172
|
+
processEvent(event: ParsedWebhookEvent): Promise<WebhookProcessingResult>;
|
|
173
|
+
canHandle(eventType: string): boolean;
|
|
174
|
+
reconcile(_transactionId: string, _providerTransactionId: string): Promise<ReconciliationResult>;
|
|
175
|
+
mapEventType(providerEventType: string): string;
|
|
176
|
+
mapStatus(providerStatus: string): TransactionStatus | null;
|
|
177
|
+
private getActionForEvent;
|
|
178
|
+
}
|
|
179
|
+
declare function validateCardcomCallback(params: Record<string, unknown>): {
|
|
180
|
+
valid: boolean;
|
|
181
|
+
error?: string;
|
|
182
|
+
};
|
|
183
|
+
declare function parseCardcomCallbackUrl(url: string): CardcomWebhookParams;
|
|
184
|
+
declare function isCardcomCallbackSuccess(params: CardcomWebhookParams): boolean;
|
|
185
|
+
declare function isCardcomCallbackAuthorized(params: CardcomWebhookParams): boolean;
|
|
186
|
+
declare function getCardcomCallbackError(params: CardcomWebhookParams): string | null;
|
|
187
|
+
|
|
188
|
+
export { CARDCOM_API_BASE, CARDCOM_CURRENCY_CODES, CARDCOM_DEAL_RESPONSE_ACTIONS, CARDCOM_ENDPOINTS, CARDCOM_LANGUAGE_CODES, CARDCOM_RESPONSE_CODE_MAP, CARDCOM_SUPPORTED_CURRENCIES, CARDCOM_WEBHOOK_EVENTS, type CardcomConfig, type CardcomDirectChargeRequest, type CardcomDirectChargeResponse, type CardcomLowProfileRequest, type CardcomLowProfileResponse, type CardcomLowProfileStatusRequest, type CardcomLowProfileStatusResponse, CardcomOperation, type CardcomRefundRequest, type CardcomRefundResponse, CardcomTransactionType, type CardcomWebhookEventType, CardcomWebhookHandler, type CardcomWebhookParams, getCardcomCallbackError, getCurrencyCode, isCardcomCallbackAuthorized, isCardcomCallbackSuccess, mapCardcomDealResponseToStatus, mapCardcomError, parseCardcomCallbackUrl, validateCardcomCallback };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
export { C as CardcomProvider, a as CardcomProviderConfig } from '../cardcom-provider-uGEDtf_i.js';
|
|
2
|
+
import { TransactionStatus, PaymentProvider, WebhookProcessingResult, ReconciliationResult } from '@nehorai/payments/types';
|
|
3
|
+
import { IWebhookHandler, ParseWebhookResult, ParsedWebhookEvent } from '@nehorai/payments/providers';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cardcom Type Definitions
|
|
7
|
+
*
|
|
8
|
+
* Type definitions for Cardcom payment gateway API v11.
|
|
9
|
+
* Supports JSON API endpoints for Low Profile (hosted page) and direct transactions.
|
|
10
|
+
*
|
|
11
|
+
* @see https://secure.cardcom.solutions/api/v11/swagger/ui/index
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare const CARDCOM_API_BASE = "https://secure.cardcom.solutions";
|
|
15
|
+
declare const CARDCOM_ENDPOINTS: {
|
|
16
|
+
readonly LOW_PROFILE_CREATE: "/api/v11/LowProfile/Create";
|
|
17
|
+
readonly LOW_PROFILE_STATUS: "/Interface/BillGoldGetLowProfileIndicator.aspx";
|
|
18
|
+
readonly DIRECT_CHARGE: "/api/v11/Transactions/Transaction";
|
|
19
|
+
readonly REFUND: "/api/v11/Transactions/RefundByTransactionId";
|
|
20
|
+
};
|
|
21
|
+
declare const CARDCOM_SUPPORTED_CURRENCIES: readonly ["ILS", "USD", "EUR", "GBP"];
|
|
22
|
+
interface CardcomConfig {
|
|
23
|
+
/** Terminal number (merchant ID) */
|
|
24
|
+
terminalNumber: string;
|
|
25
|
+
/** API username */
|
|
26
|
+
apiName: string;
|
|
27
|
+
/** API password */
|
|
28
|
+
apiPassword: string;
|
|
29
|
+
/** Webhook secret for signature validation */
|
|
30
|
+
webhookSecret?: string;
|
|
31
|
+
/** Environment (sandbox uses same endpoints but different credentials) */
|
|
32
|
+
environment: 'sandbox' | 'production';
|
|
33
|
+
}
|
|
34
|
+
declare enum CardcomOperation {
|
|
35
|
+
/** Charge immediately */
|
|
36
|
+
BILL_ONLY = 1,
|
|
37
|
+
/** Charge + save card token */
|
|
38
|
+
BILL_AND_CREATE_TOKEN = 2,
|
|
39
|
+
/** Save card without charging */
|
|
40
|
+
CREATE_TOKEN_ONLY = 3,
|
|
41
|
+
/** Authorize without capture (J5) */
|
|
42
|
+
SUSPEND_DEAL_ONLY = 4
|
|
43
|
+
}
|
|
44
|
+
declare enum CardcomTransactionType {
|
|
45
|
+
REGULAR = 1,
|
|
46
|
+
CREDIT = 2,
|
|
47
|
+
INSTALLMENTS = 3
|
|
48
|
+
}
|
|
49
|
+
interface CardcomLowProfileRequest {
|
|
50
|
+
TerminalNumber: string;
|
|
51
|
+
ApiName: string;
|
|
52
|
+
ApiPassword: string;
|
|
53
|
+
Sum: number;
|
|
54
|
+
CoinID?: number;
|
|
55
|
+
Operation?: CardcomOperation;
|
|
56
|
+
Language?: string;
|
|
57
|
+
ReturnUrl?: string;
|
|
58
|
+
ErrorUrl?: string;
|
|
59
|
+
ProductName?: string;
|
|
60
|
+
CustomerName?: string;
|
|
61
|
+
Email?: string;
|
|
62
|
+
InvoiceLanguage?: string;
|
|
63
|
+
SendEmail?: boolean;
|
|
64
|
+
IndicatorUrl?: string;
|
|
65
|
+
InternalDealNumber?: string;
|
|
66
|
+
}
|
|
67
|
+
interface CardcomLowProfileStatusRequest {
|
|
68
|
+
terminalnumber: string;
|
|
69
|
+
lowprofilecode: string;
|
|
70
|
+
username: string;
|
|
71
|
+
}
|
|
72
|
+
interface CardcomDirectChargeRequest {
|
|
73
|
+
TerminalNumber: string;
|
|
74
|
+
ApiName: string;
|
|
75
|
+
ApiPassword: string;
|
|
76
|
+
CardNumber: string;
|
|
77
|
+
CVV: string;
|
|
78
|
+
Year: string;
|
|
79
|
+
Month: string;
|
|
80
|
+
CardOwnerID: string;
|
|
81
|
+
Sum: number;
|
|
82
|
+
CoinID?: number;
|
|
83
|
+
NumOfPayments?: number;
|
|
84
|
+
Operation?: CardcomOperation;
|
|
85
|
+
Token?: string;
|
|
86
|
+
}
|
|
87
|
+
interface CardcomRefundRequest {
|
|
88
|
+
TerminalNumber: string;
|
|
89
|
+
ApiName: string;
|
|
90
|
+
ApiPassword: string;
|
|
91
|
+
InternalDealNumber: string;
|
|
92
|
+
Amount: number;
|
|
93
|
+
CoinID?: number;
|
|
94
|
+
}
|
|
95
|
+
interface CardcomLowProfileResponse {
|
|
96
|
+
ResponseCode: number;
|
|
97
|
+
Description?: string;
|
|
98
|
+
LowProfileCode?: string;
|
|
99
|
+
PaymentUrl?: string;
|
|
100
|
+
DealCode?: string;
|
|
101
|
+
}
|
|
102
|
+
interface CardcomLowProfileStatusResponse {
|
|
103
|
+
ResponseCode: number;
|
|
104
|
+
Description?: string;
|
|
105
|
+
DealResponse?: number;
|
|
106
|
+
OperationResponse?: number;
|
|
107
|
+
InternalDealNumber?: string;
|
|
108
|
+
Token?: string;
|
|
109
|
+
CardMask?: string;
|
|
110
|
+
CardType?: string;
|
|
111
|
+
CardExpiration?: string;
|
|
112
|
+
Amount?: number;
|
|
113
|
+
Currency?: string;
|
|
114
|
+
CardBin?: string;
|
|
115
|
+
}
|
|
116
|
+
interface CardcomDirectChargeResponse {
|
|
117
|
+
ResponseCode: number;
|
|
118
|
+
Description?: string;
|
|
119
|
+
InternalDealNumber?: string;
|
|
120
|
+
ApprovalNumber?: string;
|
|
121
|
+
CardMask?: string;
|
|
122
|
+
Token?: string;
|
|
123
|
+
DealCode?: string;
|
|
124
|
+
}
|
|
125
|
+
interface CardcomRefundResponse {
|
|
126
|
+
ResponseCode: number;
|
|
127
|
+
Description?: string;
|
|
128
|
+
InternalDealNumber?: string;
|
|
129
|
+
Amount?: number;
|
|
130
|
+
}
|
|
131
|
+
interface CardcomWebhookParams {
|
|
132
|
+
ResponseCode?: string;
|
|
133
|
+
LowProfileCode?: string;
|
|
134
|
+
DealResponse?: string;
|
|
135
|
+
OperationResponse?: string;
|
|
136
|
+
InternalDealNumber?: string;
|
|
137
|
+
Amount?: string;
|
|
138
|
+
Currency?: string;
|
|
139
|
+
CardMask?: string;
|
|
140
|
+
Token?: string;
|
|
141
|
+
}
|
|
142
|
+
declare const CARDCOM_WEBHOOK_EVENTS: readonly ["payment.completed", "payment.declined", "payment.authorized"];
|
|
143
|
+
type CardcomWebhookEventType = (typeof CARDCOM_WEBHOOK_EVENTS)[number];
|
|
144
|
+
declare const CARDCOM_DEAL_RESPONSE_ACTIONS: Record<number, string>;
|
|
145
|
+
declare const CARDCOM_RESPONSE_CODE_MAP: Record<number, TransactionStatus>;
|
|
146
|
+
declare function mapCardcomDealResponseToStatus(dealResponse: number): TransactionStatus;
|
|
147
|
+
declare function mapCardcomError(responseCode: number): string;
|
|
148
|
+
declare const CARDCOM_CURRENCY_CODES: Record<string, number>;
|
|
149
|
+
declare function getCurrencyCode(currency: string): number;
|
|
150
|
+
declare const CARDCOM_LANGUAGE_CODES: {
|
|
151
|
+
readonly en: "en";
|
|
152
|
+
readonly he: "he";
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Cardcom Webhook Handler
|
|
157
|
+
*
|
|
158
|
+
* Processes incoming Cardcom webhooks with idempotency.
|
|
159
|
+
* Maps Cardcom callback events to transaction status updates.
|
|
160
|
+
*
|
|
161
|
+
* Cardcom uses GET callback parameters instead of POST webhooks.
|
|
162
|
+
* Parameters are sent to ReturnUrl after payment completion.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Cardcom Webhook Handler Implementation
|
|
167
|
+
*/
|
|
168
|
+
declare class CardcomWebhookHandler implements IWebhookHandler {
|
|
169
|
+
readonly provider: PaymentProvider;
|
|
170
|
+
readonly supportedEventTypes: readonly ["payment.completed", "payment.declined", "payment.authorized"];
|
|
171
|
+
parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult;
|
|
172
|
+
processEvent(event: ParsedWebhookEvent): Promise<WebhookProcessingResult>;
|
|
173
|
+
canHandle(eventType: string): boolean;
|
|
174
|
+
reconcile(_transactionId: string, _providerTransactionId: string): Promise<ReconciliationResult>;
|
|
175
|
+
mapEventType(providerEventType: string): string;
|
|
176
|
+
mapStatus(providerStatus: string): TransactionStatus | null;
|
|
177
|
+
private getActionForEvent;
|
|
178
|
+
}
|
|
179
|
+
declare function validateCardcomCallback(params: Record<string, unknown>): {
|
|
180
|
+
valid: boolean;
|
|
181
|
+
error?: string;
|
|
182
|
+
};
|
|
183
|
+
declare function parseCardcomCallbackUrl(url: string): CardcomWebhookParams;
|
|
184
|
+
declare function isCardcomCallbackSuccess(params: CardcomWebhookParams): boolean;
|
|
185
|
+
declare function isCardcomCallbackAuthorized(params: CardcomWebhookParams): boolean;
|
|
186
|
+
declare function getCardcomCallbackError(params: CardcomWebhookParams): string | null;
|
|
187
|
+
|
|
188
|
+
export { CARDCOM_API_BASE, CARDCOM_CURRENCY_CODES, CARDCOM_DEAL_RESPONSE_ACTIONS, CARDCOM_ENDPOINTS, CARDCOM_LANGUAGE_CODES, CARDCOM_RESPONSE_CODE_MAP, CARDCOM_SUPPORTED_CURRENCIES, CARDCOM_WEBHOOK_EVENTS, type CardcomConfig, type CardcomDirectChargeRequest, type CardcomDirectChargeResponse, type CardcomLowProfileRequest, type CardcomLowProfileResponse, type CardcomLowProfileStatusRequest, type CardcomLowProfileStatusResponse, CardcomOperation, type CardcomRefundRequest, type CardcomRefundResponse, CardcomTransactionType, type CardcomWebhookEventType, CardcomWebhookHandler, type CardcomWebhookParams, getCardcomCallbackError, getCurrencyCode, isCardcomCallbackAuthorized, isCardcomCallbackSuccess, mapCardcomDealResponseToStatus, mapCardcomError, parseCardcomCallbackUrl, validateCardcomCallback };
|