@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.
@@ -0,0 +1,678 @@
1
+ // src/providers/cardcom/cardcom-provider.ts
2
+ import * as crypto from "crypto";
3
+ import { calculateCaptureDeadline } from "@nehorai/payments/types";
4
+
5
+ // src/providers/cardcom/cardcom-types.ts
6
+ var CARDCOM_API_BASE = "https://secure.cardcom.solutions";
7
+ var CARDCOM_ENDPOINTS = {
8
+ LOW_PROFILE_CREATE: "/api/v11/LowProfile/Create",
9
+ LOW_PROFILE_STATUS: "/Interface/BillGoldGetLowProfileIndicator.aspx",
10
+ DIRECT_CHARGE: "/api/v11/Transactions/Transaction",
11
+ REFUND: "/api/v11/Transactions/RefundByTransactionId"
12
+ };
13
+ var CARDCOM_SUPPORTED_CURRENCIES = ["ILS", "USD", "EUR", "GBP"];
14
+ var CardcomOperation = /* @__PURE__ */ ((CardcomOperation2) => {
15
+ CardcomOperation2[CardcomOperation2["BILL_ONLY"] = 1] = "BILL_ONLY";
16
+ CardcomOperation2[CardcomOperation2["BILL_AND_CREATE_TOKEN"] = 2] = "BILL_AND_CREATE_TOKEN";
17
+ CardcomOperation2[CardcomOperation2["CREATE_TOKEN_ONLY"] = 3] = "CREATE_TOKEN_ONLY";
18
+ CardcomOperation2[CardcomOperation2["SUSPEND_DEAL_ONLY"] = 4] = "SUSPEND_DEAL_ONLY";
19
+ return CardcomOperation2;
20
+ })(CardcomOperation || {});
21
+ var CardcomTransactionType = /* @__PURE__ */ ((CardcomTransactionType2) => {
22
+ CardcomTransactionType2[CardcomTransactionType2["REGULAR"] = 1] = "REGULAR";
23
+ CardcomTransactionType2[CardcomTransactionType2["CREDIT"] = 2] = "CREDIT";
24
+ CardcomTransactionType2[CardcomTransactionType2["INSTALLMENTS"] = 3] = "INSTALLMENTS";
25
+ return CardcomTransactionType2;
26
+ })(CardcomTransactionType || {});
27
+ var CARDCOM_WEBHOOK_EVENTS = [
28
+ "payment.completed",
29
+ "payment.declined",
30
+ "payment.authorized"
31
+ ];
32
+ var CARDCOM_DEAL_RESPONSE_ACTIONS = {
33
+ 0: "pending",
34
+ 1: "approved",
35
+ 2: "declined",
36
+ 3: "error"
37
+ };
38
+ var CARDCOM_RESPONSE_CODE_MAP = {
39
+ 0: "created",
40
+ 1: "failed",
41
+ 2: "failed",
42
+ 3: "failed",
43
+ 4: "failed",
44
+ 5: "failed",
45
+ 6: "failed",
46
+ 7: "failed",
47
+ 8: "failed",
48
+ 9: "failed",
49
+ 10: "failed"
50
+ };
51
+ function mapCardcomDealResponseToStatus(dealResponse) {
52
+ switch (dealResponse) {
53
+ case 0:
54
+ return "pending_authorization";
55
+ case 1:
56
+ return "captured";
57
+ case 2:
58
+ return "failed";
59
+ case 3:
60
+ return "failed";
61
+ default:
62
+ return "failed";
63
+ }
64
+ }
65
+ function mapCardcomError(responseCode) {
66
+ const errorMessages = {
67
+ 0: "Success",
68
+ 1: "General error",
69
+ 2: "Invalid API credentials",
70
+ 3: "Invalid terminal number",
71
+ 4: "Invalid operation type",
72
+ 5: "Invalid card details",
73
+ 6: "Card declined by issuer",
74
+ 7: "Insufficient funds",
75
+ 8: "Invalid amount",
76
+ 9: "Transaction not found",
77
+ 10: "Duplicate transaction",
78
+ 11: "Terminal not active",
79
+ 12: "CVV validation failed",
80
+ 13: "Card expired",
81
+ 14: "Invalid currency",
82
+ 15: "Operation not supported"
83
+ };
84
+ return errorMessages[responseCode] ?? `Error code ${responseCode}`;
85
+ }
86
+ var CARDCOM_CURRENCY_CODES = {
87
+ ILS: 1,
88
+ USD: 2,
89
+ EUR: 3,
90
+ GBP: 4
91
+ };
92
+ function getCurrencyCode(currency) {
93
+ return CARDCOM_CURRENCY_CODES[currency.toUpperCase()] ?? 1;
94
+ }
95
+ var CARDCOM_LANGUAGE_CODES = {
96
+ en: "en",
97
+ he: "he"
98
+ };
99
+
100
+ // src/providers/cardcom/cardcom-provider.ts
101
+ var CardcomProvider = class {
102
+ name = "cardcom";
103
+ supportedCurrencies = CARDCOM_SUPPORTED_CURRENCIES;
104
+ supportsRecurring = true;
105
+ supportsSplitPayments = false;
106
+ config;
107
+ constructor(config) {
108
+ if (!config.terminalNumber || !config.apiName || !config.apiPassword) {
109
+ throw new Error(
110
+ "CardcomProvider requires terminalNumber, apiName, and apiPassword in config"
111
+ );
112
+ }
113
+ this.config = config;
114
+ }
115
+ // ==========================================================================
116
+ // Payment Intent Operations
117
+ // ==========================================================================
118
+ async createPaymentIntent(params) {
119
+ try {
120
+ const amountMajor = params.amount.amountMinor / 100;
121
+ const operation = params.captureMethod === "manual" ? 4 /* SUSPEND_DEAL_ONLY */ : params.metadata?.savePaymentMethod ? 2 /* BILL_AND_CREATE_TOKEN */ : 1 /* BILL_ONLY */;
122
+ const request = {
123
+ TerminalNumber: this.config.terminalNumber,
124
+ ApiName: this.config.apiName,
125
+ ApiPassword: this.config.apiPassword,
126
+ Sum: amountMajor,
127
+ CoinID: getCurrencyCode(params.amount.currency),
128
+ Operation: operation,
129
+ Language: "en",
130
+ ReturnUrl: params.returnUrl,
131
+ ErrorUrl: params.returnUrl,
132
+ ProductName: params.description ?? "Payment",
133
+ InternalDealNumber: params.idempotencyKey,
134
+ SendEmail: false
135
+ };
136
+ if (params.metadata?.customerName) {
137
+ request.CustomerName = String(params.metadata.customerName);
138
+ }
139
+ if (params.metadata?.customerEmail) {
140
+ request.Email = String(params.metadata.customerEmail);
141
+ }
142
+ const response = await this.makeRequest(
143
+ CARDCOM_ENDPOINTS.LOW_PROFILE_CREATE,
144
+ request
145
+ );
146
+ if (response.ResponseCode !== 0 || !response.PaymentUrl) {
147
+ return {
148
+ success: false,
149
+ error: mapCardcomError(response.ResponseCode),
150
+ errorCode: String(response.ResponseCode)
151
+ };
152
+ }
153
+ return {
154
+ success: true,
155
+ providerIntentId: response.LowProfileCode,
156
+ redirectUrl: response.PaymentUrl,
157
+ status: "created"
158
+ };
159
+ } catch (error) {
160
+ return this.handleError(error);
161
+ }
162
+ }
163
+ async authorize(params) {
164
+ try {
165
+ const statusResponse = await this.getLowProfileStatus(
166
+ params.providerIntentId
167
+ );
168
+ if (!statusResponse.success || !statusResponse.data) {
169
+ return {
170
+ success: false,
171
+ error: statusResponse.error ?? "Failed to check payment status"
172
+ };
173
+ }
174
+ const status = statusResponse.data;
175
+ if (status.DealResponse === 1) {
176
+ return {
177
+ success: true,
178
+ authorizationCode: status.InternalDealNumber ?? params.providerIntentId,
179
+ status: "authorized",
180
+ captureDeadline: calculateCaptureDeadline(/* @__PURE__ */ new Date())
181
+ };
182
+ }
183
+ if (status.DealResponse === 2) {
184
+ return {
185
+ success: false,
186
+ error: "Payment declined",
187
+ status: "failed"
188
+ };
189
+ }
190
+ return {
191
+ success: false,
192
+ error: "Payment not yet completed",
193
+ status: "pending_authorization"
194
+ };
195
+ } catch (error) {
196
+ return this.handleError(error);
197
+ }
198
+ }
199
+ async capture(params) {
200
+ try {
201
+ const statusResponse = await this.getLowProfileStatus(
202
+ params.providerIntentId
203
+ );
204
+ if (!statusResponse.success || !statusResponse.data) {
205
+ return {
206
+ success: false,
207
+ error: statusResponse.error ?? "Failed to capture payment"
208
+ };
209
+ }
210
+ const status = statusResponse.data;
211
+ if (status.DealResponse === 1) {
212
+ return {
213
+ success: true,
214
+ providerTransactionId: status.InternalDealNumber ?? params.providerIntentId,
215
+ status: "captured",
216
+ capturedAmount: {
217
+ amountMinor: Math.round((status.Amount ?? 0) * 100),
218
+ currency: status.Currency ?? params.amount?.currency ?? "ILS"
219
+ }
220
+ };
221
+ }
222
+ return {
223
+ success: false,
224
+ error: "Payment not authorized for capture",
225
+ status: mapCardcomDealResponseToStatus(status.DealResponse ?? 3)
226
+ };
227
+ } catch (error) {
228
+ return this.handleError(error);
229
+ }
230
+ }
231
+ async void(_params) {
232
+ return {
233
+ success: false,
234
+ error: "Void operation not supported via API. Please use Cardcom merchant dashboard."
235
+ };
236
+ }
237
+ async refund(params) {
238
+ try {
239
+ const refundAmount = params.amount ? params.amount.amountMinor / 100 : void 0;
240
+ if (!refundAmount) {
241
+ return {
242
+ success: false,
243
+ error: "Refund amount is required"
244
+ };
245
+ }
246
+ const request = {
247
+ TerminalNumber: this.config.terminalNumber,
248
+ ApiName: this.config.apiName,
249
+ ApiPassword: this.config.apiPassword,
250
+ InternalDealNumber: params.providerTransactionId,
251
+ Amount: refundAmount,
252
+ CoinID: params.amount ? getCurrencyCode(params.amount.currency) : 1
253
+ };
254
+ const response = await this.makeRequest(
255
+ CARDCOM_ENDPOINTS.REFUND,
256
+ request
257
+ );
258
+ if (response.ResponseCode !== 0) {
259
+ return {
260
+ success: false,
261
+ error: mapCardcomError(response.ResponseCode)
262
+ };
263
+ }
264
+ return {
265
+ success: true,
266
+ providerRefundId: response.InternalDealNumber ?? params.providerTransactionId,
267
+ refundedAmount: {
268
+ amountMinor: Math.round((response.Amount ?? 0) * 100),
269
+ currency: params.amount?.currency ?? "ILS"
270
+ },
271
+ status: "succeeded"
272
+ };
273
+ } catch (error) {
274
+ return this.handleError(error);
275
+ }
276
+ }
277
+ // ==========================================================================
278
+ // Payment Method Tokenization
279
+ // ==========================================================================
280
+ async createSetupIntent(params) {
281
+ try {
282
+ const request = {
283
+ TerminalNumber: this.config.terminalNumber,
284
+ ApiName: this.config.apiName,
285
+ ApiPassword: this.config.apiPassword,
286
+ Sum: 0,
287
+ Operation: 3 /* CREATE_TOKEN_ONLY */,
288
+ Language: "en",
289
+ InternalDealNumber: `setup_${params.userId}_${Date.now()}`
290
+ };
291
+ const response = await this.makeRequest(
292
+ CARDCOM_ENDPOINTS.LOW_PROFILE_CREATE,
293
+ request
294
+ );
295
+ if (response.ResponseCode !== 0 || !response.PaymentUrl) {
296
+ return {
297
+ success: false,
298
+ error: mapCardcomError(response.ResponseCode)
299
+ };
300
+ }
301
+ return {
302
+ success: true,
303
+ setupIntentId: response.LowProfileCode,
304
+ clientSecret: response.PaymentUrl
305
+ };
306
+ } catch (error) {
307
+ return this.handleError(error);
308
+ }
309
+ }
310
+ async savePaymentMethod(params) {
311
+ try {
312
+ const lowProfileCode = params.setupData.lowProfileCode;
313
+ if (!lowProfileCode) {
314
+ return {
315
+ success: false,
316
+ error: "Low profile code is required"
317
+ };
318
+ }
319
+ const statusResponse = await this.getLowProfileStatus(lowProfileCode);
320
+ if (!statusResponse.success || !statusResponse.data) {
321
+ return {
322
+ success: false,
323
+ error: statusResponse.error ?? "Failed to retrieve payment method"
324
+ };
325
+ }
326
+ const status = statusResponse.data;
327
+ if (!status.Token) {
328
+ return {
329
+ success: false,
330
+ error: "No token created"
331
+ };
332
+ }
333
+ const [expMonth, expYear] = (status.CardExpiration ?? "/").split("/");
334
+ return {
335
+ success: true,
336
+ paymentMethodId: status.Token,
337
+ cardBrand: status.CardType ?? "unknown",
338
+ cardLast4: status.CardMask?.slice(-4),
339
+ cardExpMonth: expMonth?.padStart(2, "0"),
340
+ cardExpYear: expYear ? `20${expYear}` : void 0,
341
+ cardBin: status.CardBin
342
+ };
343
+ } catch (error) {
344
+ return this.handleError(error);
345
+ }
346
+ }
347
+ async deletePaymentMethod(_paymentMethodId) {
348
+ return {
349
+ success: true
350
+ };
351
+ }
352
+ // ==========================================================================
353
+ // Customer Management
354
+ // ==========================================================================
355
+ async createCustomer(params) {
356
+ return {
357
+ success: true,
358
+ customerId: params.userId
359
+ };
360
+ }
361
+ async getOrCreateCustomer(userId, email) {
362
+ return this.createCustomer({ userId, email });
363
+ }
364
+ // ==========================================================================
365
+ // Health & Status
366
+ // ==========================================================================
367
+ async getHealth() {
368
+ const start = Date.now();
369
+ try {
370
+ const request = {
371
+ TerminalNumber: this.config.terminalNumber,
372
+ ApiName: this.config.apiName,
373
+ ApiPassword: this.config.apiPassword,
374
+ Sum: 1,
375
+ Operation: 1 /* BILL_ONLY */,
376
+ InternalDealNumber: `health_check_${Date.now()}`
377
+ };
378
+ const response = await this.makeRequest(
379
+ CARDCOM_ENDPOINTS.LOW_PROFILE_CREATE,
380
+ request
381
+ );
382
+ const healthy = response.ResponseCode === 0 || response.ResponseCode === 1;
383
+ return {
384
+ provider: "cardcom",
385
+ healthy,
386
+ lastChecked: /* @__PURE__ */ new Date(),
387
+ avgLatencyMs: Date.now() - start,
388
+ circuitBreakerOpen: false
389
+ };
390
+ } catch {
391
+ return {
392
+ provider: "cardcom",
393
+ healthy: false,
394
+ lastChecked: /* @__PURE__ */ new Date(),
395
+ circuitBreakerOpen: false
396
+ };
397
+ }
398
+ }
399
+ validateWebhookSignature(payload, signature) {
400
+ if (!this.config.webhookSecret) {
401
+ return false;
402
+ }
403
+ try {
404
+ const expectedSignature = crypto.createHmac("sha256", this.config.webhookSecret).update(payload).digest("hex");
405
+ return crypto.timingSafeEqual(
406
+ Buffer.from(signature),
407
+ Buffer.from(expectedSignature)
408
+ );
409
+ } catch {
410
+ return false;
411
+ }
412
+ }
413
+ async getPaymentIntentStatus(providerIntentId) {
414
+ try {
415
+ const result = await this.getLowProfileStatus(providerIntentId);
416
+ if (!result.success || !result.data) {
417
+ return {
418
+ status: "unknown",
419
+ error: result.error
420
+ };
421
+ }
422
+ const status = mapCardcomDealResponseToStatus(
423
+ result.data.DealResponse ?? 0
424
+ );
425
+ return { status };
426
+ } catch (error) {
427
+ return {
428
+ status: "unknown",
429
+ error: error instanceof Error ? error.message : "Unknown error"
430
+ };
431
+ }
432
+ }
433
+ // ==========================================================================
434
+ // Helper Methods
435
+ // ==========================================================================
436
+ async makeRequest(endpoint, data) {
437
+ const url = `${CARDCOM_API_BASE}${endpoint}`;
438
+ const response = await fetch(url, {
439
+ method: "POST",
440
+ headers: {
441
+ "Content-Type": "application/json"
442
+ },
443
+ body: JSON.stringify(data)
444
+ });
445
+ if (!response.ok) {
446
+ throw new Error(`Cardcom API error: ${response.status} ${response.statusText}`);
447
+ }
448
+ return response.json();
449
+ }
450
+ async getLowProfileStatus(lowProfileCode) {
451
+ try {
452
+ const params = new URLSearchParams({
453
+ terminalnumber: this.config.terminalNumber,
454
+ lowprofilecode: lowProfileCode,
455
+ username: this.config.apiName
456
+ });
457
+ const url = `${CARDCOM_API_BASE}${CARDCOM_ENDPOINTS.LOW_PROFILE_STATUS}?${params}`;
458
+ const response = await fetch(url, {
459
+ method: "GET"
460
+ });
461
+ if (!response.ok) {
462
+ return {
463
+ success: false,
464
+ error: `Status check failed: ${response.status}`
465
+ };
466
+ }
467
+ const data = await response.json();
468
+ if (data.ResponseCode !== 0) {
469
+ return {
470
+ success: false,
471
+ error: mapCardcomError(data.ResponseCode)
472
+ };
473
+ }
474
+ return { success: true, data };
475
+ } catch (error) {
476
+ return {
477
+ success: false,
478
+ error: error instanceof Error ? error.message : "Status check failed"
479
+ };
480
+ }
481
+ }
482
+ handleError(error) {
483
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
484
+ return {
485
+ success: false,
486
+ error: errorMessage
487
+ };
488
+ }
489
+ };
490
+
491
+ // src/providers/cardcom/cardcom-webhook-handler.ts
492
+ var CardcomWebhookHandler = class {
493
+ provider = "cardcom";
494
+ supportedEventTypes = CARDCOM_WEBHOOK_EVENTS;
495
+ parseEvent(rawPayload) {
496
+ try {
497
+ const params = rawPayload;
498
+ const responseCode = parseInt(params.ResponseCode ?? "1", 10);
499
+ const dealResponse = parseInt(params.DealResponse ?? "0", 10);
500
+ const lowProfileCode = params.LowProfileCode ?? "";
501
+ const internalDealNumber = params.InternalDealNumber ?? "";
502
+ if (!lowProfileCode && !internalDealNumber) {
503
+ return {
504
+ success: false,
505
+ error: "Missing LowProfileCode or InternalDealNumber in callback"
506
+ };
507
+ }
508
+ let eventType;
509
+ if (dealResponse === 1) {
510
+ eventType = "payment.completed";
511
+ } else if (dealResponse === 2) {
512
+ eventType = "payment.declined";
513
+ } else if (dealResponse === 0 && responseCode === 0) {
514
+ eventType = "payment.authorized";
515
+ } else {
516
+ eventType = "payment.declined";
517
+ }
518
+ const status = mapCardcomDealResponseToStatus(dealResponse);
519
+ const amountString = params.Amount ?? "0";
520
+ const amountMajor = parseFloat(amountString);
521
+ const amountMinor = Math.round(amountMajor * 100);
522
+ const parsed = {
523
+ provider: "cardcom",
524
+ eventId: `${lowProfileCode}_${internalDealNumber}_${Date.now()}`,
525
+ eventType,
526
+ providerTransactionId: internalDealNumber || lowProfileCode,
527
+ timestamp: /* @__PURE__ */ new Date(),
528
+ rawPayload,
529
+ newStatus: status,
530
+ amountMinor,
531
+ currency: params.Currency ?? "ILS"
532
+ };
533
+ if (dealResponse === 2 || responseCode !== 0) {
534
+ parsed.error = {
535
+ code: String(responseCode),
536
+ message: CARDCOM_DEAL_RESPONSE_ACTIONS[dealResponse] ?? "Payment failed"
537
+ };
538
+ }
539
+ return { success: true, event: parsed };
540
+ } catch (error) {
541
+ return {
542
+ success: false,
543
+ error: error instanceof Error ? error.message : "Parse error"
544
+ };
545
+ }
546
+ }
547
+ async processEvent(event) {
548
+ const action = this.getActionForEvent(event.eventType);
549
+ if (action === "ignored") {
550
+ return {
551
+ success: true,
552
+ action: "ignored_event_type"
553
+ };
554
+ }
555
+ return {
556
+ success: true,
557
+ transactionId: event.providerTransactionId,
558
+ action: "status_updated"
559
+ };
560
+ }
561
+ canHandle(eventType) {
562
+ return this.supportedEventTypes.includes(
563
+ eventType
564
+ );
565
+ }
566
+ async reconcile(_transactionId, _providerTransactionId) {
567
+ return {
568
+ reconciled: false,
569
+ finalStatus: "created",
570
+ source: "provider_query",
571
+ statusChanged: false
572
+ };
573
+ }
574
+ mapEventType(providerEventType) {
575
+ return providerEventType;
576
+ }
577
+ mapStatus(providerStatus) {
578
+ const dealResponse = parseInt(providerStatus, 10);
579
+ if (isNaN(dealResponse)) {
580
+ return null;
581
+ }
582
+ return mapCardcomDealResponseToStatus(dealResponse);
583
+ }
584
+ getActionForEvent(eventType) {
585
+ switch (eventType) {
586
+ case "payment.completed":
587
+ case "payment.declined":
588
+ case "payment.authorized":
589
+ return "status_update";
590
+ default:
591
+ return "ignored";
592
+ }
593
+ }
594
+ };
595
+ function validateCardcomCallback(params) {
596
+ const requiredFields = ["ResponseCode", "LowProfileCode"];
597
+ for (const field of requiredFields) {
598
+ if (!params[field]) {
599
+ return {
600
+ valid: false,
601
+ error: `Missing required field: ${field}`
602
+ };
603
+ }
604
+ }
605
+ const responseCode = parseInt(String(params.ResponseCode), 10);
606
+ if (isNaN(responseCode)) {
607
+ return {
608
+ valid: false,
609
+ error: "Invalid ResponseCode format"
610
+ };
611
+ }
612
+ return { valid: true };
613
+ }
614
+ function parseCardcomCallbackUrl(url) {
615
+ try {
616
+ const urlObj = new URL(url);
617
+ const params = {};
618
+ params.ResponseCode = urlObj.searchParams.get("ResponseCode") ?? void 0;
619
+ params.LowProfileCode = urlObj.searchParams.get("LowProfileCode") ?? void 0;
620
+ params.DealResponse = urlObj.searchParams.get("DealResponse") ?? void 0;
621
+ params.OperationResponse = urlObj.searchParams.get("OperationResponse") ?? void 0;
622
+ params.InternalDealNumber = urlObj.searchParams.get("InternalDealNumber") ?? void 0;
623
+ params.Amount = urlObj.searchParams.get("Amount") ?? void 0;
624
+ params.Currency = urlObj.searchParams.get("Currency") ?? void 0;
625
+ params.CardMask = urlObj.searchParams.get("CardMask") ?? void 0;
626
+ params.Token = urlObj.searchParams.get("Token") ?? void 0;
627
+ return params;
628
+ } catch {
629
+ return {};
630
+ }
631
+ }
632
+ function isCardcomCallbackSuccess(params) {
633
+ const responseCode = parseInt(params.ResponseCode ?? "1", 10);
634
+ const dealResponse = parseInt(params.DealResponse ?? "0", 10);
635
+ return responseCode === 0 && dealResponse === 1;
636
+ }
637
+ function isCardcomCallbackAuthorized(params) {
638
+ const responseCode = parseInt(params.ResponseCode ?? "1", 10);
639
+ const dealResponse = parseInt(params.DealResponse ?? "0", 10);
640
+ return responseCode === 0 && (dealResponse === 0 || dealResponse === 1);
641
+ }
642
+ function getCardcomCallbackError(params) {
643
+ const responseCode = parseInt(params.ResponseCode ?? "1", 10);
644
+ const dealResponse = parseInt(params.DealResponse ?? "0", 10);
645
+ if (responseCode === 0 && dealResponse === 1) {
646
+ return null;
647
+ }
648
+ if (dealResponse === 2) {
649
+ return "Payment declined by card issuer";
650
+ }
651
+ if (responseCode !== 0) {
652
+ return `Payment failed with code ${responseCode}`;
653
+ }
654
+ return "Payment processing error";
655
+ }
656
+ export {
657
+ CARDCOM_API_BASE,
658
+ CARDCOM_CURRENCY_CODES,
659
+ CARDCOM_DEAL_RESPONSE_ACTIONS,
660
+ CARDCOM_ENDPOINTS,
661
+ CARDCOM_LANGUAGE_CODES,
662
+ CARDCOM_RESPONSE_CODE_MAP,
663
+ CARDCOM_SUPPORTED_CURRENCIES,
664
+ CARDCOM_WEBHOOK_EVENTS,
665
+ CardcomOperation,
666
+ CardcomProvider,
667
+ CardcomTransactionType,
668
+ CardcomWebhookHandler,
669
+ getCardcomCallbackError,
670
+ getCurrencyCode,
671
+ isCardcomCallbackAuthorized,
672
+ isCardcomCallbackSuccess,
673
+ mapCardcomDealResponseToStatus,
674
+ mapCardcomError,
675
+ parseCardcomCallbackUrl,
676
+ validateCardcomCallback
677
+ };
678
+ //# sourceMappingURL=index.js.map