@plyaz/types 1.11.3 → 1.12.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.
Files changed (43) hide show
  1. package/dist/errors/types.d.ts +3 -0
  2. package/dist/index.cjs +345 -0
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +328 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/payments/currency/index.d.ts +37 -0
  8. package/dist/payments/events/emitter/index.d.ts +1 -0
  9. package/dist/payments/events/emitter/types.d.ts +333 -0
  10. package/dist/payments/events/enums.d.ts +110 -0
  11. package/dist/payments/events/index.d.ts +4 -0
  12. package/dist/payments/events/types.d.ts +151 -0
  13. package/dist/payments/events/unified-event/enums.d.ts +14 -0
  14. package/dist/payments/events/unified-event/index.d.ts +2 -0
  15. package/dist/payments/events/unified-event/types.d.ts +346 -0
  16. package/dist/payments/gateways/index.d.ts +2 -0
  17. package/dist/payments/gateways/provider/index.d.ts +1 -0
  18. package/dist/payments/gateways/provider/types.d.ts +435 -0
  19. package/dist/payments/gateways/routings/enums.d.ts +87 -0
  20. package/dist/payments/gateways/routings/index.d.ts +2 -0
  21. package/dist/payments/gateways/routings/types.d.ts +512 -0
  22. package/dist/payments/index.cjs +351 -0
  23. package/dist/payments/index.cjs.map +1 -0
  24. package/dist/payments/index.d.ts +7 -0
  25. package/dist/payments/index.js +332 -0
  26. package/dist/payments/index.js.map +1 -0
  27. package/dist/payments/provider/adapter/index.d.ts +1 -0
  28. package/dist/payments/provider/adapter/types.d.ts +208 -0
  29. package/dist/payments/provider/core/index.d.ts +1 -0
  30. package/dist/payments/provider/core/types.d.ts +508 -0
  31. package/dist/payments/provider/index.d.ts +4 -0
  32. package/dist/payments/provider/payment-provider/index.d.ts +1 -0
  33. package/dist/payments/provider/payment-provider/types.d.ts +269 -0
  34. package/dist/payments/provider/provider-capability/enums.d.ts +116 -0
  35. package/dist/payments/provider/provider-capability/index.d.ts +1 -0
  36. package/dist/payments/request/enums.d.ts +19 -0
  37. package/dist/payments/request/index.d.ts +2 -0
  38. package/dist/payments/request/types.d.ts +221 -0
  39. package/dist/payments/service/index.d.ts +1 -0
  40. package/dist/payments/service/types.d.ts +48 -0
  41. package/dist/payments/transaction/index.d.ts +1 -0
  42. package/dist/payments/transaction/types.d.ts +120 -0
  43. package/package.json +6 -1
@@ -0,0 +1,435 @@
1
+ import type { CURRENCY } from '../../currency';
2
+ import type { PAYMENTMETHOD, PAYMENTPROVIDERTYPE } from '../../provider';
3
+ /**
4
+ * Base configuration interface that all payment providers must implement.
5
+ * This ensures consistent configuration structure across all providers.
6
+ */
7
+ export interface BaseProviderConfig<TProviderSpecific extends object> {
8
+ /** Provider identification */
9
+ provider: PAYMENTPROVIDERTYPE;
10
+ /** Display name for this provider */
11
+ displayName: string;
12
+ /** Whether this provider is currently enabled */
13
+ enabled: boolean;
14
+ /** Environment configuration */
15
+ environment: ProviderEnvironment;
16
+ /** Provider credentials and API keys */
17
+ credentials: ProviderCredentials;
18
+ /** Webhook configuration */
19
+ webhooks: WebhookConfiguration;
20
+ /** Feature flags specific to this provider */
21
+ features: ProviderFeatureFlags;
22
+ /** Fee structure configuration */
23
+ fees: ProviderFeeConfiguration;
24
+ /** Operational limits and constraints */
25
+ limits: ProviderLimitsConfiguration;
26
+ /** Performance and reliability settings */
27
+ performance: ProviderPerformanceConfiguration;
28
+ /** Regional availability and restrictions */
29
+ /** Monitoring and alerting configuration */
30
+ /** Provider-specific custom settings */
31
+ customSettings: TProviderSpecific;
32
+ }
33
+ /**
34
+ * Provider environment configuration.
35
+ */
36
+ export interface ProviderEnvironment {
37
+ /** Current environment */
38
+ current: 'sandbox' | 'staging' | 'production';
39
+ /** API base URLs for different environments */
40
+ apiUrls: {
41
+ sandbox: string;
42
+ staging?: string;
43
+ production: string;
44
+ };
45
+ /** Environment-specific feature overrides */
46
+ environmentOverrides: {
47
+ sandbox?: Partial<ProviderFeatureFlags>;
48
+ staging?: Partial<ProviderFeatureFlags>;
49
+ production?: Partial<ProviderFeatureFlags>;
50
+ };
51
+ /** Debug mode settings */
52
+ debug: {
53
+ enabled: boolean;
54
+ logLevel: 'error' | 'warn' | 'info' | 'debug' | 'trace';
55
+ logRequests: boolean;
56
+ logResponses: boolean;
57
+ };
58
+ }
59
+ /**
60
+ * Provider credentials interface with encryption support.
61
+ */
62
+ export interface ProviderCredentials {
63
+ /** Primary API key or client ID */
64
+ apiKey: string;
65
+ /** Secret key or client secret */
66
+ secretKey: string;
67
+ /** Additional authentication credentials */
68
+ additionalCredentials?: {
69
+ /** Merchant ID for providers that require it */
70
+ merchantId?: string;
71
+ /** Partner ID for marketplace integrations */
72
+ partnerId?: string;
73
+ /** Application ID for OAuth flows */
74
+ applicationId?: string;
75
+ /** Webhook verification key */
76
+ webhookSecret?: string;
77
+ /** Additional key-value pairs */
78
+ [key: string]: string | undefined;
79
+ };
80
+ /** Credential rotation configuration */
81
+ rotation: {
82
+ /** Whether automatic rotation is enabled */
83
+ enabled: boolean;
84
+ /** Rotation interval in days */
85
+ intervalDays: number;
86
+ /** Warning period before expiration */
87
+ warningDays: number;
88
+ /** Last rotation timestamp */
89
+ lastRotated?: Date;
90
+ /** Next scheduled rotation */
91
+ nextRotation?: Date;
92
+ };
93
+ /** Encryption information */
94
+ encryption: {
95
+ /** Whether credentials are encrypted */
96
+ encrypted: boolean;
97
+ /** Encryption algorithm used */
98
+ algorithm?: string;
99
+ /** Key version for rotation */
100
+ keyVersion?: string;
101
+ };
102
+ }
103
+ /**
104
+ * Webhook configuration for provider integrations.
105
+ */
106
+ export interface WebhookConfiguration {
107
+ /** Whether webhooks are enabled for this provider */
108
+ enabled: boolean;
109
+ /** Webhook endpoint URLs */
110
+ endpoints: {
111
+ /** Primary webhook endpoint */
112
+ primary: string;
113
+ /** Fallback webhook endpoint */
114
+ fallback?: string;
115
+ /** Specific endpoints for different event types */
116
+ eventSpecific?: Record<string, string>;
117
+ };
118
+ /** Webhook security configuration */
119
+ security: {
120
+ /** Signature verification method */
121
+ signatureMethod: 'hmac_sha256' | 'hmac_sha512' | 'rsa' | 'custom';
122
+ /** Signature header name */
123
+ signatureHeader: string;
124
+ /** Timestamp header name for replay protection */
125
+ timestampHeader?: string;
126
+ /** Webhook secret for signature verification */
127
+ secret: string;
128
+ /** Tolerance for timestamp validation (seconds) */
129
+ timestampTolerance: number;
130
+ /** IP whitelist for webhook sources */
131
+ allowedIPs?: string[];
132
+ };
133
+ /** Event subscription configuration */
134
+ events: {
135
+ /** Events to subscribe to */
136
+ subscribed: string[];
137
+ /** Events to explicitly ignore */
138
+ ignored?: string[];
139
+ };
140
+ /** Retry and reliability configuration */
141
+ reliability: {
142
+ /** Enable automatic retries for failed deliveries */
143
+ retryEnabled: boolean;
144
+ /** Maximum retry attempts */
145
+ maxRetries: number;
146
+ /** Retry delay progression (milliseconds) */
147
+ retryDelays: number[];
148
+ /** Timeout for webhook processing */
149
+ timeout: number;
150
+ /** Dead letter queue configuration */
151
+ deadLetterQueue?: {
152
+ enabled: boolean;
153
+ retentionDays: number;
154
+ };
155
+ };
156
+ }
157
+ /**
158
+ * Provider-specific feature flags.
159
+ */
160
+ export interface ProviderFeatureFlags {
161
+ /** Core payment features */
162
+ payments: {
163
+ /** Enable payment processing */
164
+ enabled: boolean;
165
+ /** Enable subscription payments */
166
+ subscriptions: boolean;
167
+ /** Enable pre-authorization */
168
+ preauthorization: boolean;
169
+ /** Enable payment cancellation */
170
+ cancellation: boolean;
171
+ /** Enable payment updates */
172
+ updates: boolean;
173
+ };
174
+ /** Refund features */
175
+ refunds: {
176
+ /** Enable refund processing */
177
+ enabled: boolean;
178
+ /** Enable partial refunds */
179
+ partial: boolean;
180
+ /** Enable instant refunds */
181
+ instant: boolean;
182
+ /** Enable refund scheduling */
183
+ scheduled: boolean;
184
+ };
185
+ /** Security features */
186
+ security: {
187
+ /** Enable 3D Secure verification */
188
+ threeDS: boolean;
189
+ /** Enable fraud detection */
190
+ fraudDetection: boolean;
191
+ /** Enable velocity checking */
192
+ velocityChecking: boolean;
193
+ /** Enable payment tokenization */
194
+ tokenization: boolean;
195
+ };
196
+ /** Customer features */
197
+ customers: {
198
+ /** Enable customer profiles */
199
+ profiles: boolean;
200
+ /** Enable saved payment methods */
201
+ savedMethods: boolean;
202
+ /** Enable customer authentication */
203
+ authentication: boolean;
204
+ };
205
+ /** Marketplace features */
206
+ marketplace: {
207
+ /** Enable marketplace payments */
208
+ enabled: boolean;
209
+ /** Enable split payments */
210
+ splitPayments: boolean;
211
+ /** Enable connected accounts */
212
+ connectedAccounts: boolean;
213
+ /** Enable instant payouts */
214
+ instantPayouts: boolean;
215
+ };
216
+ /** Advanced features */
217
+ advanced: {
218
+ /** Enable multi-currency support */
219
+ multiCurrency: boolean;
220
+ /** Enable currency conversion */
221
+ currencyConversion: boolean;
222
+ /** Enable payment routing */
223
+ smartRouting: boolean;
224
+ /** Enable cost optimization */
225
+ costOptimization: boolean;
226
+ /** Enable A/B testing */
227
+ abTesting: boolean;
228
+ };
229
+ }
230
+ /**
231
+ * Provider fee configuration for cost optimization.
232
+ */
233
+ export interface ProviderFeeConfiguration {
234
+ /** Base fee structure */
235
+ baseFees: {
236
+ /** Percentage fee (e.g., 2.9 for 2.9%) */
237
+ percentage: number;
238
+ /** Fixed fee per transaction (in cents) */
239
+ fixed: number;
240
+ /** Currency for fixed fees */
241
+ currency: CURRENCY;
242
+ };
243
+ /** Payment method specific fees */
244
+ methodFees: Record<PAYMENTMETHOD, {
245
+ percentage: number;
246
+ fixed: number;
247
+ currency: CURRENCY;
248
+ }>;
249
+ /** Volume-based fee tiers */
250
+ volumeTiers: VolumeTier[];
251
+ /** Regional fee variations */
252
+ regionalFees: Record<string, {
253
+ percentage: number;
254
+ fixed: number;
255
+ currency: CURRENCY;
256
+ }>;
257
+ /** Additional fee types */
258
+ additionalFees: {
259
+ /** Cross-border transaction fees */
260
+ crossBorder?: {
261
+ percentage: number;
262
+ fixed?: number;
263
+ };
264
+ /** Currency conversion fees */
265
+ currencyConversion?: {
266
+ percentage: number;
267
+ minimumFee?: number;
268
+ };
269
+ /** Chargeback fees */
270
+ chargeback?: {
271
+ amount: number;
272
+ currency: CURRENCY;
273
+ };
274
+ /** Refund processing fees */
275
+ refund?: {
276
+ percentage: number;
277
+ fixed?: number;
278
+ };
279
+ };
280
+ /** Fee calculation configuration */
281
+ calculation: {
282
+ /** Rounding method for calculated fees */
283
+ rounding: 'up' | 'down' | 'nearest';
284
+ /** Minimum fee amount */
285
+ minimumFee?: {
286
+ amount: number;
287
+ currency: CURRENCY;
288
+ };
289
+ /** Maximum fee amount */
290
+ maximumFee?: {
291
+ amount: number;
292
+ currency: CURRENCY;
293
+ };
294
+ };
295
+ }
296
+ /**
297
+ * Volume tier configuration for fee optimization.
298
+ */
299
+ export interface VolumeTier {
300
+ /** Tier name */
301
+ name: string;
302
+ /** Minimum monthly volume to qualify */
303
+ minimumVolume: {
304
+ amount: number;
305
+ currency: CURRENCY;
306
+ };
307
+ /** Fee rates for this tier */
308
+ feeRates: {
309
+ percentage: number;
310
+ fixed: number;
311
+ currency: CURRENCY;
312
+ };
313
+ /** Tier benefits */
314
+ benefits?: string[];
315
+ /** Tier requirements */
316
+ requirements?: string[];
317
+ }
318
+ /**
319
+ * Provider limits configuration.
320
+ */
321
+ export interface ProviderLimitsConfiguration<TProviderSpecific extends object = Record<string, never>> {
322
+ /** Transaction amount limits */
323
+ amounts: {
324
+ /** Minimum transaction amount */
325
+ minimum: Record<PAYMENTMETHOD, {
326
+ amount: number;
327
+ currency: CURRENCY;
328
+ }>;
329
+ /** Maximum transaction amount */
330
+ maximum: Record<PAYMENTMETHOD, {
331
+ amount: number;
332
+ currency: CURRENCY;
333
+ }>;
334
+ };
335
+ /** Velocity limits */
336
+ velocity: {
337
+ /** Daily transaction limits */
338
+ daily: {
339
+ /** Maximum number of transactions */
340
+ maxTransactions: number;
341
+ /** Maximum total amount */
342
+ maxAmount: {
343
+ amount: number;
344
+ currency: CURRENCY;
345
+ };
346
+ };
347
+ /** Monthly transaction limits */
348
+ monthly: {
349
+ maxTransactions: number;
350
+ maxAmount: {
351
+ amount: number;
352
+ currency: CURRENCY;
353
+ };
354
+ };
355
+ };
356
+ /** API rate limits */
357
+ apiLimits: {
358
+ /** Requests per second */
359
+ requestsPerSecond: number;
360
+ /** Requests per minute */
361
+ requestsPerMinute: number;
362
+ /** Requests per hour */
363
+ requestsPerHour: number;
364
+ /** Burst capacity */
365
+ burstCapacity?: number;
366
+ };
367
+ /** Provider-specific limits */
368
+ providerSpecific: TProviderSpecific;
369
+ }
370
+ /**
371
+ * Provider performance configuration.
372
+ */
373
+ export interface ProviderPerformanceConfiguration {
374
+ /** Timeout configurations */
375
+ timeouts: {
376
+ /** Connection timeout (milliseconds) */
377
+ connection: number;
378
+ /** Request timeout (milliseconds) */
379
+ request: number;
380
+ /** Total timeout including retries */
381
+ total: number;
382
+ };
383
+ /** Retry configuration */
384
+ retries: {
385
+ /** Enable automatic retries */
386
+ enabled: boolean;
387
+ /** Maximum retry attempts */
388
+ maxAttempts: number;
389
+ /** Retry delay strategy */
390
+ strategy: 'fixed' | 'exponential' | 'linear';
391
+ /** Base delay for retry strategy */
392
+ baseDelay: number;
393
+ /** Maximum delay between retries */
394
+ maxDelay: number;
395
+ /** Jitter to prevent thundering herd */
396
+ jitter: boolean;
397
+ /** Status codes that trigger retries */
398
+ retryableStatusCodes: number[];
399
+ };
400
+ /** Circuit breaker configuration */
401
+ circuitBreaker: {
402
+ /** Enable circuit breaker */
403
+ enabled: boolean;
404
+ /** Failure threshold to open circuit */
405
+ failureThreshold: number;
406
+ /** Time window for failure counting */
407
+ windowSize: number;
408
+ /** Timeout before attempting to close circuit */
409
+ timeout: number;
410
+ /** Minimum requests before circuit can open */
411
+ minimumRequests: number;
412
+ };
413
+ /** Connection pooling */
414
+ connectionPool: {
415
+ /** Maximum number of connections */
416
+ maxConnections: number;
417
+ /** Minimum number of connections */
418
+ minConnections: number;
419
+ /** Connection idle timeout */
420
+ idleTimeout: number;
421
+ /** Connection validation interval */
422
+ validationInterval: number;
423
+ };
424
+ /** Caching configuration */
425
+ caching: {
426
+ /** Enable response caching */
427
+ enabled: boolean;
428
+ /** Cache TTL for different operation types */
429
+ ttl: Record<string, number>;
430
+ /** Cache size limits */
431
+ maxSize: number;
432
+ /** Cache eviction strategy */
433
+ evictionStrategy: 'lru' | 'lfu' | 'ttl';
434
+ };
435
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Cost optimization strategies.
3
+ */
4
+ export declare enum COSTOPTIMIZATIONSTRATEGY {
5
+ /** Always use cheapest option */
6
+ Aggressive = "aggressive",
7
+ /** Balance cost with reliability */
8
+ Balanced = "balanced",
9
+ /** Prefer reliability over cost */
10
+ Conservative = "conservative",
11
+ /** Optimize for specific cost components */
12
+ Targeted = "targeted"
13
+ }
14
+ /**
15
+ * Failover strategies.
16
+ */
17
+ export declare enum FAILOVERSTRATEGY {
18
+ /** Use predefined provider order */
19
+ PriorityOrder = "priority_order",
20
+ /** Failover to next available provider */
21
+ NextAvailable = "next_available",
22
+ /** Failover based on performance metrics */
23
+ PerformanceBased = "performance_based",
24
+ /** Failover to least loaded provider */
25
+ LoadBalanced = "load_balanced",
26
+ /** Geographic failover preference */
27
+ Geographic = "geographic"
28
+ }
29
+ /**
30
+ * Regulatory frameworks.
31
+ */
32
+ export declare enum REGULATORYFRAMEWORK {
33
+ PciDss = "pci_dss",
34
+ Gdpr = "gdpr",
35
+ Psd2 = "psd2",
36
+ Sox = "sox",
37
+ Aml = "aml",
38
+ Kyc = "kyc",
39
+ Ccpa = "ccpa",
40
+ LocalBanking = "local_banking"
41
+ }
42
+ /**
43
+ * Load balancing strategies.
44
+ */
45
+ export declare enum LOADBALANCINGSTRATEGY {
46
+ /** Rotate through providers evenly */
47
+ RoundRobin = "round_robin",
48
+ /** Use weighted distribution */
49
+ Weighted = "weighted",
50
+ /** Choose provider with least active traffic */
51
+ LeastConnections = "least_connections",
52
+ /** Choose based on best performance metrics */
53
+ PerformanceBased = "performance_based",
54
+ /** Custom strategy defined by merchant */
55
+ Custom = "custom"
56
+ }
57
+ /**
58
+ * Types of performance metrics.
59
+ */
60
+ export declare enum PERFORMANCEMETRICTYPE {
61
+ Latency = "latency",
62
+ SuccessRate = "success_rate",
63
+ ErrorRate = "error_rate",
64
+ Throughput = "throughput",
65
+ Retries = "retries",
66
+ Availability = "availability",
67
+ Cost = "cost"
68
+ }
69
+ /**
70
+ * Primary routing strategies.
71
+ */
72
+ export declare enum ROUTINGSTRATEGY {
73
+ /** Optimize for lowest total cost */
74
+ CostOptimized = "cost_optimized",
75
+ /** Optimize for highest reliability */
76
+ ReliabilityFirst = "reliability_first",
77
+ /** Optimize for fastest processing */
78
+ PerformanceFirst = "performance_first",
79
+ /** Balance cost, reliability, and performance */
80
+ Balanced = "balanced",
81
+ /** Use user or region preferences */
82
+ UserPreference = "user_preference",
83
+ /** Distribute load evenly */
84
+ RoundRobin = "round_robin",
85
+ /** Custom routing logic */
86
+ Custom = "custom"
87
+ }
@@ -0,0 +1,2 @@
1
+ export type * from './types';
2
+ export * from './enums';