@nehorai/payments 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/config/index.cjs +116 -0
- package/dist/config/index.cjs.map +1 -0
- package/dist/config/index.d.cts +125 -0
- package/dist/config/index.d.ts +125 -0
- package/dist/config/index.js +83 -0
- package/dist/config/index.js.map +1 -0
- package/dist/factory.cjs +807 -0
- package/dist/factory.cjs.map +1 -0
- package/dist/factory.d.cts +96 -0
- package/dist/factory.d.ts +96 -0
- package/dist/factory.js +777 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.cjs +1341 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +1260 -0
- package/dist/index.js.map +1 -0
- package/dist/payment-orchestrator-CPaLmDM5.d.ts +404 -0
- package/dist/payment-orchestrator-Co_X6T_V.d.cts +404 -0
- package/dist/payment-types-68W-PlGg.d.cts +211 -0
- package/dist/payment-types-68W-PlGg.d.ts +211 -0
- package/dist/providers/interfaces/index.cjs +19 -0
- package/dist/providers/interfaces/index.cjs.map +1 -0
- package/dist/providers/interfaces/index.d.cts +80 -0
- package/dist/providers/interfaces/index.d.ts +80 -0
- package/dist/providers/interfaces/index.js +1 -0
- package/dist/providers/interfaces/index.js.map +1 -0
- package/dist/repository/interfaces/index.cjs +19 -0
- package/dist/repository/interfaces/index.cjs.map +1 -0
- package/dist/repository/interfaces/index.d.cts +556 -0
- package/dist/repository/interfaces/index.d.ts +556 -0
- package/dist/repository/interfaces/index.js +1 -0
- package/dist/repository/interfaces/index.js.map +1 -0
- package/dist/routing-engine.interface-DJzGXor9.d.cts +194 -0
- package/dist/routing-engine.interface-h9_GmQ4b.d.ts +194 -0
- package/dist/services/index.cjs +806 -0
- package/dist/services/index.cjs.map +1 -0
- package/dist/services/index.d.cts +75 -0
- package/dist/services/index.d.ts +75 -0
- package/dist/services/index.js +763 -0
- package/dist/services/index.js.map +1 -0
- package/dist/state-machine-Cu6_qKnv.d.cts +109 -0
- package/dist/state-machine-Cu6_qKnv.d.ts +109 -0
- package/dist/types/index.cjs +173 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +127 -0
- package/dist/types/index.d.ts +127 -0
- package/dist/types/index.js +130 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.cjs +167 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +102 -0
- package/dist/utils/index.d.ts +102 -0
- package/dist/utils/index.js +127 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nehorai/payments - Core Payment Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the fundamental types for the payment system.
|
|
5
|
+
* Follows TypeScript conventions with literal union types.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported payment providers - extensible string identifier
|
|
9
|
+
*/
|
|
10
|
+
type PaymentProvider = string;
|
|
11
|
+
/**
|
|
12
|
+
* Types of payment transactions
|
|
13
|
+
*/
|
|
14
|
+
type TransactionType = 'one_time_purchase' | 'subscription_initial' | 'subscription_renewal' | 'refund';
|
|
15
|
+
/**
|
|
16
|
+
* Tax invoice status
|
|
17
|
+
*/
|
|
18
|
+
type TaxInvoiceStatus = 'pending' | 'generated' | 'sent' | 'failed';
|
|
19
|
+
/**
|
|
20
|
+
* Payment method types
|
|
21
|
+
*/
|
|
22
|
+
type PaymentMethodType = 'card' | 'bank_account' | 'paypal';
|
|
23
|
+
/**
|
|
24
|
+
* Card brands supported
|
|
25
|
+
*/
|
|
26
|
+
type CardBrand = 'visa' | 'mastercard' | 'amex' | 'discover' | 'isracard' | 'diners' | 'unknown';
|
|
27
|
+
/**
|
|
28
|
+
* Monetary amount in smallest currency unit (cents, agorot, etc.)
|
|
29
|
+
* Zero Trust: All amounts validated server-side, never trust client
|
|
30
|
+
*/
|
|
31
|
+
interface PaymentAmount {
|
|
32
|
+
/** Amount in smallest currency unit (e.g., 1000 = $10.00) */
|
|
33
|
+
amountMinor: number;
|
|
34
|
+
/** ISO 4217 currency code (e.g., 'USD', 'ILS') */
|
|
35
|
+
currency: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of currency conversion
|
|
39
|
+
*/
|
|
40
|
+
interface CurrencyConversion {
|
|
41
|
+
originalAmount: PaymentAmount;
|
|
42
|
+
convertedAmount: PaymentAmount;
|
|
43
|
+
exchangeRate: number;
|
|
44
|
+
convertedAt: Date;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parameters for creating a payment intent
|
|
48
|
+
*/
|
|
49
|
+
interface CreatePaymentIntentParams {
|
|
50
|
+
amount: PaymentAmount;
|
|
51
|
+
userId: string;
|
|
52
|
+
idempotencyKey: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
metadata?: PaymentMetadata;
|
|
55
|
+
returnUrl?: string;
|
|
56
|
+
paymentMethodId?: string;
|
|
57
|
+
/** If true, only authorize (J5 hold), don't capture */
|
|
58
|
+
captureMethod?: 'automatic' | 'manual';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Result from creating a payment intent
|
|
62
|
+
*/
|
|
63
|
+
interface PaymentIntentResult {
|
|
64
|
+
success: boolean;
|
|
65
|
+
/** Provider's payment intent ID */
|
|
66
|
+
providerIntentId?: string;
|
|
67
|
+
/** Client secret for frontend SDK (Stripe Elements) */
|
|
68
|
+
clientSecret?: string;
|
|
69
|
+
/** Redirect URL for redirect-based flows */
|
|
70
|
+
redirectUrl?: string;
|
|
71
|
+
/** Current status of the payment */
|
|
72
|
+
status?: string;
|
|
73
|
+
error?: string;
|
|
74
|
+
errorCode?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parameters for authorizing a payment (J5 hold)
|
|
78
|
+
*/
|
|
79
|
+
interface AuthorizePaymentParams {
|
|
80
|
+
providerIntentId: string;
|
|
81
|
+
idempotencyKey: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Result from authorization
|
|
85
|
+
*/
|
|
86
|
+
interface AuthorizationResult {
|
|
87
|
+
success: boolean;
|
|
88
|
+
/** Authorization code for capture */
|
|
89
|
+
authorizationCode?: string;
|
|
90
|
+
status?: string;
|
|
91
|
+
/** Deadline to capture before auth expires (typically 7 days) */
|
|
92
|
+
captureDeadline?: Date;
|
|
93
|
+
error?: string;
|
|
94
|
+
errorCode?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parameters for capturing an authorized payment
|
|
98
|
+
*/
|
|
99
|
+
interface CapturePaymentParams {
|
|
100
|
+
providerIntentId: string;
|
|
101
|
+
authorizationCode: string;
|
|
102
|
+
/** For partial capture */
|
|
103
|
+
amount?: PaymentAmount;
|
|
104
|
+
idempotencyKey: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Result from capture
|
|
108
|
+
*/
|
|
109
|
+
interface CaptureResult {
|
|
110
|
+
success: boolean;
|
|
111
|
+
providerTransactionId?: string;
|
|
112
|
+
status?: string;
|
|
113
|
+
capturedAmount?: PaymentAmount;
|
|
114
|
+
error?: string;
|
|
115
|
+
errorCode?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Parameters for voiding an authorization
|
|
119
|
+
*/
|
|
120
|
+
interface VoidPaymentParams {
|
|
121
|
+
providerIntentId: string;
|
|
122
|
+
authorizationCode: string;
|
|
123
|
+
idempotencyKey: string;
|
|
124
|
+
reason?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Result from void
|
|
128
|
+
*/
|
|
129
|
+
interface VoidResult {
|
|
130
|
+
success: boolean;
|
|
131
|
+
status?: string;
|
|
132
|
+
error?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Parameters for refunding a payment
|
|
136
|
+
*/
|
|
137
|
+
interface RefundParams {
|
|
138
|
+
providerTransactionId: string;
|
|
139
|
+
/** For partial refund */
|
|
140
|
+
amount?: PaymentAmount;
|
|
141
|
+
reason?: string;
|
|
142
|
+
idempotencyKey: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Result from refund
|
|
146
|
+
*/
|
|
147
|
+
interface RefundResult {
|
|
148
|
+
success: boolean;
|
|
149
|
+
providerRefundId?: string;
|
|
150
|
+
refundedAmount?: PaymentAmount;
|
|
151
|
+
status?: 'pending' | 'succeeded' | 'failed';
|
|
152
|
+
error?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Application-specific metadata attached to payments
|
|
156
|
+
*/
|
|
157
|
+
interface PaymentMetadata {
|
|
158
|
+
/** Credit package being purchased */
|
|
159
|
+
creditPackageId?: string;
|
|
160
|
+
/** Subscription plan being purchased */
|
|
161
|
+
subscriptionPlanId?: string;
|
|
162
|
+
/** Number of credits being purchased */
|
|
163
|
+
creditsAmount?: number;
|
|
164
|
+
/** Custom fields */
|
|
165
|
+
[key: string]: unknown;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Provider-specific metadata (raw response data)
|
|
169
|
+
*/
|
|
170
|
+
interface ProviderMetadata {
|
|
171
|
+
/** Raw response from provider for debugging */
|
|
172
|
+
rawResponse?: Record<string, unknown>;
|
|
173
|
+
/** Provider-specific transaction ID */
|
|
174
|
+
providerTransactionId?: string;
|
|
175
|
+
/** Provider-specific authorization code */
|
|
176
|
+
authorizationCode?: string;
|
|
177
|
+
/** Additional provider data */
|
|
178
|
+
[key: string]: unknown;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Provider health status for circuit breaker
|
|
182
|
+
*/
|
|
183
|
+
interface ProviderHealthStatus {
|
|
184
|
+
provider: PaymentProvider;
|
|
185
|
+
healthy: boolean;
|
|
186
|
+
lastChecked: Date;
|
|
187
|
+
/** Average response time in milliseconds */
|
|
188
|
+
avgLatencyMs?: number;
|
|
189
|
+
/** Error rate (0-1) */
|
|
190
|
+
errorRate?: number;
|
|
191
|
+
/** Whether circuit breaker is open */
|
|
192
|
+
circuitBreakerOpen: boolean;
|
|
193
|
+
/** When circuit breaker will attempt to close */
|
|
194
|
+
nextRetryAt?: Date;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Standardized payment error codes
|
|
198
|
+
*/
|
|
199
|
+
type PaymentErrorCode = 'insufficient_funds' | 'invalid_card' | 'expired_card' | 'card_declined' | 'processing_error' | 'provider_timeout' | 'provider_unavailable' | 'rate_limit' | 'webhook_signature_invalid' | 'idempotency_conflict' | 'invalid_amount' | 'invalid_currency' | 'authentication_required' | 'unknown';
|
|
200
|
+
/**
|
|
201
|
+
* Payment error with structured information
|
|
202
|
+
*/
|
|
203
|
+
interface PaymentError {
|
|
204
|
+
code: PaymentErrorCode;
|
|
205
|
+
message: string;
|
|
206
|
+
provider?: PaymentProvider;
|
|
207
|
+
retryable: boolean;
|
|
208
|
+
details?: Record<string, unknown>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type { AuthorizationResult as A, CapturePaymentParams as C, PaymentAmount as P, RefundParams as R, TaxInvoiceStatus as T, VoidPaymentParams as V, AuthorizePaymentParams as a, CaptureResult as b, CardBrand as c, CreatePaymentIntentParams as d, CurrencyConversion as e, PaymentError as f, PaymentErrorCode as g, PaymentIntentResult as h, PaymentMetadata as i, PaymentMethodType as j, PaymentProvider as k, ProviderHealthStatus as l, ProviderMetadata as m, RefundResult as n, TransactionType as o, VoidResult as p };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/providers/interfaces/index.ts
|
|
17
|
+
var interfaces_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/interfaces/index.ts"],"sourcesContent":["/**\r\n * @nehorai/payments - Provider Interfaces Exports\r\n */\r\n\r\n// Payment Provider Interface\r\nexport 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 './payment-provider.interface.js';\r\n\r\n// Webhook Handler Interface\r\nexport type {\r\n IWebhookHandler,\r\n ParsedWebhookEvent,\r\n ParseWebhookResult,\r\n EventHandler,\r\n EventHandlerMap,\r\n} from './webhook-handler.interface.js';\r\n\r\n// Routing Engine Interface\r\nexport type {\r\n IRoutingEngine,\r\n RoutingContext,\r\n RoutingDecision,\r\n} from './routing-engine.interface.js';\r\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export { C as CreateCustomerParams, a as CreateCustomerResult, b as CreateSetupIntentParams, D as DeletePaymentMethodResult, I as IPaymentProvider, c as IRoutingEngine, R as RoutingContext, d as RoutingDecision, S as SavePaymentMethodParams, e as SavePaymentMethodResult, f as SetupIntentResult } from '../../routing-engine.interface-DJzGXor9.cjs';
|
|
2
|
+
import { k as PaymentProvider } from '../../payment-types-68W-PlGg.cjs';
|
|
3
|
+
import { c as TransactionStatus } from '../../state-machine-Cu6_qKnv.cjs';
|
|
4
|
+
import { WebhookProcessingResult, ReconciliationResult } from '../../types/index.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @nehorai/payments - Webhook Handler Interface
|
|
8
|
+
*
|
|
9
|
+
* Defines the contract for processing incoming webhooks from payment providers.
|
|
10
|
+
* Handles idempotency, reconciliation, and event-to-action mapping.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parsed webhook event with standardized fields
|
|
15
|
+
*/
|
|
16
|
+
interface ParsedWebhookEvent {
|
|
17
|
+
/** Provider that sent the webhook */
|
|
18
|
+
provider: PaymentProvider;
|
|
19
|
+
/** Provider's unique event ID */
|
|
20
|
+
eventId: string;
|
|
21
|
+
/** Standardized event type */
|
|
22
|
+
eventType: string;
|
|
23
|
+
/** Associated payment intent/transaction ID */
|
|
24
|
+
providerTransactionId?: string;
|
|
25
|
+
/** Amount in minor units (if applicable) */
|
|
26
|
+
amountMinor?: number;
|
|
27
|
+
/** Currency (if applicable) */
|
|
28
|
+
currency?: string;
|
|
29
|
+
/** New status (if status change event) */
|
|
30
|
+
newStatus?: TransactionStatus;
|
|
31
|
+
/** Error details (if failure event) */
|
|
32
|
+
error?: {
|
|
33
|
+
code: string;
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
/** Original timestamp from provider */
|
|
37
|
+
timestamp: Date;
|
|
38
|
+
/** Full raw payload */
|
|
39
|
+
rawPayload: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of parsing a webhook event
|
|
43
|
+
*/
|
|
44
|
+
interface ParseWebhookResult {
|
|
45
|
+
success: boolean;
|
|
46
|
+
event?: ParsedWebhookEvent;
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Handler function for a specific event type
|
|
51
|
+
*/
|
|
52
|
+
type EventHandler = (event: ParsedWebhookEvent) => Promise<WebhookProcessingResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Map of event types to handler functions
|
|
55
|
+
*/
|
|
56
|
+
type EventHandlerMap = Map<string, EventHandler>;
|
|
57
|
+
/**
|
|
58
|
+
* Webhook Handler Interface
|
|
59
|
+
*
|
|
60
|
+
* Provider-specific webhook handlers implement this interface.
|
|
61
|
+
* Enables consistent webhook processing across all providers.
|
|
62
|
+
*/
|
|
63
|
+
interface IWebhookHandler {
|
|
64
|
+
/**
|
|
65
|
+
* Provider this handler is for
|
|
66
|
+
*/
|
|
67
|
+
readonly provider: PaymentProvider;
|
|
68
|
+
/**
|
|
69
|
+
* Event types this handler can process
|
|
70
|
+
*/
|
|
71
|
+
readonly supportedEventTypes: readonly string[];
|
|
72
|
+
parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult;
|
|
73
|
+
processEvent(event: ParsedWebhookEvent): Promise<WebhookProcessingResult>;
|
|
74
|
+
canHandle(eventType: string): boolean;
|
|
75
|
+
reconcile(transactionId: string, providerTransactionId: string): Promise<ReconciliationResult>;
|
|
76
|
+
mapEventType(providerEventType: string): string;
|
|
77
|
+
mapStatus(providerStatus: string): TransactionStatus | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type { EventHandler, EventHandlerMap, IWebhookHandler, ParseWebhookResult, ParsedWebhookEvent };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export { C as CreateCustomerParams, a as CreateCustomerResult, b as CreateSetupIntentParams, D as DeletePaymentMethodResult, I as IPaymentProvider, c as IRoutingEngine, R as RoutingContext, d as RoutingDecision, S as SavePaymentMethodParams, e as SavePaymentMethodResult, f as SetupIntentResult } from '../../routing-engine.interface-h9_GmQ4b.js';
|
|
2
|
+
import { k as PaymentProvider } from '../../payment-types-68W-PlGg.js';
|
|
3
|
+
import { c as TransactionStatus } from '../../state-machine-Cu6_qKnv.js';
|
|
4
|
+
import { WebhookProcessingResult, ReconciliationResult } from '../../types/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @nehorai/payments - Webhook Handler Interface
|
|
8
|
+
*
|
|
9
|
+
* Defines the contract for processing incoming webhooks from payment providers.
|
|
10
|
+
* Handles idempotency, reconciliation, and event-to-action mapping.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parsed webhook event with standardized fields
|
|
15
|
+
*/
|
|
16
|
+
interface ParsedWebhookEvent {
|
|
17
|
+
/** Provider that sent the webhook */
|
|
18
|
+
provider: PaymentProvider;
|
|
19
|
+
/** Provider's unique event ID */
|
|
20
|
+
eventId: string;
|
|
21
|
+
/** Standardized event type */
|
|
22
|
+
eventType: string;
|
|
23
|
+
/** Associated payment intent/transaction ID */
|
|
24
|
+
providerTransactionId?: string;
|
|
25
|
+
/** Amount in minor units (if applicable) */
|
|
26
|
+
amountMinor?: number;
|
|
27
|
+
/** Currency (if applicable) */
|
|
28
|
+
currency?: string;
|
|
29
|
+
/** New status (if status change event) */
|
|
30
|
+
newStatus?: TransactionStatus;
|
|
31
|
+
/** Error details (if failure event) */
|
|
32
|
+
error?: {
|
|
33
|
+
code: string;
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
/** Original timestamp from provider */
|
|
37
|
+
timestamp: Date;
|
|
38
|
+
/** Full raw payload */
|
|
39
|
+
rawPayload: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of parsing a webhook event
|
|
43
|
+
*/
|
|
44
|
+
interface ParseWebhookResult {
|
|
45
|
+
success: boolean;
|
|
46
|
+
event?: ParsedWebhookEvent;
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Handler function for a specific event type
|
|
51
|
+
*/
|
|
52
|
+
type EventHandler = (event: ParsedWebhookEvent) => Promise<WebhookProcessingResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Map of event types to handler functions
|
|
55
|
+
*/
|
|
56
|
+
type EventHandlerMap = Map<string, EventHandler>;
|
|
57
|
+
/**
|
|
58
|
+
* Webhook Handler Interface
|
|
59
|
+
*
|
|
60
|
+
* Provider-specific webhook handlers implement this interface.
|
|
61
|
+
* Enables consistent webhook processing across all providers.
|
|
62
|
+
*/
|
|
63
|
+
interface IWebhookHandler {
|
|
64
|
+
/**
|
|
65
|
+
* Provider this handler is for
|
|
66
|
+
*/
|
|
67
|
+
readonly provider: PaymentProvider;
|
|
68
|
+
/**
|
|
69
|
+
* Event types this handler can process
|
|
70
|
+
*/
|
|
71
|
+
readonly supportedEventTypes: readonly string[];
|
|
72
|
+
parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult;
|
|
73
|
+
processEvent(event: ParsedWebhookEvent): Promise<WebhookProcessingResult>;
|
|
74
|
+
canHandle(eventType: string): boolean;
|
|
75
|
+
reconcile(transactionId: string, providerTransactionId: string): Promise<ReconciliationResult>;
|
|
76
|
+
mapEventType(providerEventType: string): string;
|
|
77
|
+
mapStatus(providerStatus: string): TransactionStatus | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type { EventHandler, EventHandlerMap, IWebhookHandler, ParseWebhookResult, ParsedWebhookEvent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/repository/interfaces/index.ts
|
|
17
|
+
var interfaces_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/repository/interfaces/index.ts"],"sourcesContent":["/**\r\n * @nehorai/payments Repository - Interface Exports\r\n *\r\n * All repository interfaces for database-agnostic payment operations.\r\n * Implement these interfaces to integrate with your database.\r\n */\r\n\r\n// ============================================================================\r\n// Imports for Aggregate Interface\r\n// ============================================================================\r\n\r\nimport type { ITransactionRepository } from './transaction.repository.js'\r\nimport type { IPaymentMethodRepository } from './payment-method.repository.js'\r\nimport type { IWebhookEventRepository } from './webhook-event.repository.js'\r\nimport type { IAuditLogRepository } from './audit-log.repository.js'\r\nimport type { IProviderHealthRepository } from './provider-health.repository.js'\r\n\r\n// ============================================================================\r\n// Base Types\r\n// ============================================================================\r\n\r\nexport type {\r\n PaginationParams,\r\n PaginatedResult,\r\n DateRangeFilter,\r\n SortDirection,\r\n SortParam,\r\n IBaseRepository,\r\n} from './base.interface.js'\r\n\r\n// ============================================================================\r\n// Transaction Repository\r\n// ============================================================================\r\n\r\nexport type {\r\n TransactionStatus,\r\n TransactionType,\r\n TaxInvoiceStatus,\r\n ProviderName,\r\n Transaction,\r\n CreateTransactionInput,\r\n UpdateTransactionInput,\r\n TransactionFilter,\r\n ITransactionRepository,\r\n} from './transaction.repository.js'\r\n\r\n// ============================================================================\r\n// Payment Method Repository\r\n// ============================================================================\r\n\r\nexport type {\r\n PaymentMethodType,\r\n CardBrand,\r\n PaymentMethod,\r\n CreatePaymentMethodInput,\r\n UpdatePaymentMethodInput,\r\n PaymentMethodFilter,\r\n IPaymentMethodRepository,\r\n} from './payment-method.repository.js'\r\n\r\n// ============================================================================\r\n// Webhook Event Repository\r\n// ============================================================================\r\n\r\nexport type {\r\n WebhookEventStatus,\r\n WebhookEvent,\r\n CreateWebhookEventInput,\r\n UpdateWebhookEventInput,\r\n WebhookEventFilter,\r\n IWebhookEventRepository,\r\n} from './webhook-event.repository.js'\r\n\r\n// ============================================================================\r\n// Audit Log Repository\r\n// ============================================================================\r\n\r\nexport type {\r\n AuditLogAction,\r\n AuditLogTrigger,\r\n AuditLogEntry,\r\n CreateAuditLogInput,\r\n AuditLogFilter,\r\n IAuditLogRepository,\r\n} from './audit-log.repository.js'\r\n\r\n// ============================================================================\r\n// Provider Health Repository\r\n// ============================================================================\r\n\r\nexport type {\r\n CircuitBreakerState,\r\n HealthCheckResult,\r\n ProviderHealth,\r\n CreateProviderHealthInput,\r\n UpdateProviderHealthInput,\r\n IProviderHealthRepository,\r\n} from './provider-health.repository.js'\r\n\r\n// ============================================================================\r\n// Aggregate Repository Interface\r\n// ============================================================================\r\n\r\n/**\r\n * Combined repository interface for all payment operations.\r\n * Implement this interface to provide a complete database adapter.\r\n */\r\nexport interface IPaymentRepositories {\r\n transactions: ITransactionRepository\r\n paymentMethods: IPaymentMethodRepository\r\n webhookEvents: IWebhookEventRepository\r\n auditLog: IAuditLogRepository\r\n providerHealth: IProviderHealthRepository\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|