@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.
- package/dist/errors/types.d.ts +3 -0
- package/dist/index.cjs +345 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +328 -1
- package/dist/index.js.map +1 -1
- package/dist/payments/currency/index.d.ts +37 -0
- package/dist/payments/events/emitter/index.d.ts +1 -0
- package/dist/payments/events/emitter/types.d.ts +333 -0
- package/dist/payments/events/enums.d.ts +110 -0
- package/dist/payments/events/index.d.ts +4 -0
- package/dist/payments/events/types.d.ts +151 -0
- package/dist/payments/events/unified-event/enums.d.ts +14 -0
- package/dist/payments/events/unified-event/index.d.ts +2 -0
- package/dist/payments/events/unified-event/types.d.ts +346 -0
- package/dist/payments/gateways/index.d.ts +2 -0
- package/dist/payments/gateways/provider/index.d.ts +1 -0
- package/dist/payments/gateways/provider/types.d.ts +435 -0
- package/dist/payments/gateways/routings/enums.d.ts +87 -0
- package/dist/payments/gateways/routings/index.d.ts +2 -0
- package/dist/payments/gateways/routings/types.d.ts +512 -0
- package/dist/payments/index.cjs +351 -0
- package/dist/payments/index.cjs.map +1 -0
- package/dist/payments/index.d.ts +7 -0
- package/dist/payments/index.js +332 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/payments/provider/adapter/index.d.ts +1 -0
- package/dist/payments/provider/adapter/types.d.ts +208 -0
- package/dist/payments/provider/core/index.d.ts +1 -0
- package/dist/payments/provider/core/types.d.ts +508 -0
- package/dist/payments/provider/index.d.ts +4 -0
- package/dist/payments/provider/payment-provider/index.d.ts +1 -0
- package/dist/payments/provider/payment-provider/types.d.ts +269 -0
- package/dist/payments/provider/provider-capability/enums.d.ts +116 -0
- package/dist/payments/provider/provider-capability/index.d.ts +1 -0
- package/dist/payments/request/enums.d.ts +19 -0
- package/dist/payments/request/index.d.ts +2 -0
- package/dist/payments/request/types.d.ts +221 -0
- package/dist/payments/service/index.d.ts +1 -0
- package/dist/payments/service/types.d.ts +48 -0
- package/dist/payments/transaction/index.d.ts +1 -0
- package/dist/payments/transaction/types.d.ts +120 -0
- package/package.json +6 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import type { CURRENCY } from '../../currency';
|
|
2
|
+
import type { FeeBreakdown, Money } from '../../transaction';
|
|
3
|
+
import type { PAYMENTMETHOD, PAYMENTPROVIDERTYPE, PAYMENTSTATUS } from '../provider-capability';
|
|
4
|
+
/**
|
|
5
|
+
* High-level configuration for initializing a payment provider.
|
|
6
|
+
*
|
|
7
|
+
* This configuration is passed to the provider adapter during initialization.
|
|
8
|
+
* It must contain everything required to:
|
|
9
|
+
* - Authenticate with the provider
|
|
10
|
+
* - Configure operational behavior
|
|
11
|
+
* - Enable webhook verification
|
|
12
|
+
* - Support different environments (sandbox, production, etc.)
|
|
13
|
+
*/
|
|
14
|
+
export interface PaymentProviderConfig<TExtra extends object = object, TCustomHeaders extends Record<string, string> = Record<string, string>> {
|
|
15
|
+
/** Provider type identifier (e.g., stripe, paypal) */
|
|
16
|
+
provider: PAYMENTPROVIDERTYPE;
|
|
17
|
+
/** Primary authentication */
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
secretKey?: string;
|
|
20
|
+
/** For Stripe client-side integrations */
|
|
21
|
+
publishableKey?: string;
|
|
22
|
+
/** Optional merchant/account identifiers */
|
|
23
|
+
merchantId?: string;
|
|
24
|
+
accountId?: string;
|
|
25
|
+
/** Optional API version pinning */
|
|
26
|
+
apiVersion?: string;
|
|
27
|
+
/** Environment */
|
|
28
|
+
environment: 'sandbox' | 'staging' | 'production';
|
|
29
|
+
apiBaseUrl?: string;
|
|
30
|
+
/** Currency and region support */
|
|
31
|
+
supportedCurrencies?: CURRENCY[];
|
|
32
|
+
supportedRegions?: string[];
|
|
33
|
+
/** Webhook configuration */
|
|
34
|
+
webhook?: {
|
|
35
|
+
url: string;
|
|
36
|
+
secret?: string;
|
|
37
|
+
/** Support multiple webhook endpoints if needed */
|
|
38
|
+
secrets?: Record<string, string>;
|
|
39
|
+
events?: string[];
|
|
40
|
+
tolerance?: number;
|
|
41
|
+
};
|
|
42
|
+
/** Request config */
|
|
43
|
+
requestTimeout?: number;
|
|
44
|
+
retryPolicy?: {
|
|
45
|
+
maxRetries: number;
|
|
46
|
+
backoffMs: number;
|
|
47
|
+
};
|
|
48
|
+
/** Debug and advanced options */
|
|
49
|
+
debug?: boolean;
|
|
50
|
+
customHeaders?: TCustomHeaders;
|
|
51
|
+
extra?: TExtra;
|
|
52
|
+
/** Optional secondary credentials (e.g., key rotation) */
|
|
53
|
+
secondaryCredentials?: {
|
|
54
|
+
apiKey?: string;
|
|
55
|
+
secretKey?: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Core parameters for initiating a payment transaction with any provider.
|
|
60
|
+
* This type is **provider-agnostic** and later normalized/translated
|
|
61
|
+
* inside the provider adapter.
|
|
62
|
+
*/
|
|
63
|
+
export interface CreatePaymentParams<TMetadata extends object = object> {
|
|
64
|
+
/** Amount to be charged, always in smallest currency unit */
|
|
65
|
+
amount: Money;
|
|
66
|
+
/** Payment method selected for this transaction */
|
|
67
|
+
method: PAYMENTMETHOD;
|
|
68
|
+
/** Currency of the transaction */
|
|
69
|
+
currency: CURRENCY;
|
|
70
|
+
/** Unique identifier for the user initiating the transaction */
|
|
71
|
+
userId: string;
|
|
72
|
+
/** Product or service being paid for */
|
|
73
|
+
productId: string;
|
|
74
|
+
/** Description for statement or receipt */
|
|
75
|
+
description?: string;
|
|
76
|
+
/** URL to redirect user after successful payment */
|
|
77
|
+
returnUrl?: string;
|
|
78
|
+
/** URL to redirect user after failed/cancelled payment */
|
|
79
|
+
cancelUrl?: string;
|
|
80
|
+
/** Optional idempotency key to prevent duplicate charges */
|
|
81
|
+
idempotencyKey?: string;
|
|
82
|
+
/** Additional metadata (campaign, subscription, geo info, etc.) */
|
|
83
|
+
metadata?: TMetadata;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parameters required to initiate a refund.
|
|
87
|
+
* Refunds can be full or partial.
|
|
88
|
+
*/
|
|
89
|
+
export interface RefundParams<TMetadata extends object = object> {
|
|
90
|
+
provider: string;
|
|
91
|
+
/** Internal Plyaz transaction ID */
|
|
92
|
+
transactionId: string;
|
|
93
|
+
/** Provider transaction ID (optional but useful for some providers) */
|
|
94
|
+
providerTransactionId?: string;
|
|
95
|
+
/** Amount to refund — required for partial refunds */
|
|
96
|
+
amount?: Money;
|
|
97
|
+
/** Reason for refund (optional, useful for reporting) */
|
|
98
|
+
reason?: string;
|
|
99
|
+
/** Initiator of refund (system, user, admin) */
|
|
100
|
+
initiatedBy?: 'system' | 'user' | 'admin';
|
|
101
|
+
/** Additional metadata for audit */
|
|
102
|
+
metadata?: TMetadata;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Result returned after processing a refund request.
|
|
106
|
+
*/
|
|
107
|
+
export interface RefundResult<TMetadata extends object = object> {
|
|
108
|
+
/** Unique refund transaction ID in Plyaz system */
|
|
109
|
+
refundId: string;
|
|
110
|
+
/** Provider-specific refund ID (if available) */
|
|
111
|
+
providerRefundId?: string;
|
|
112
|
+
/** Status of the refund transaction */
|
|
113
|
+
status: PAYMENTSTATUS;
|
|
114
|
+
/** Refunded amount */
|
|
115
|
+
amount: Money;
|
|
116
|
+
/** Any applicable refund fees (if provider charges fees on refunds) */
|
|
117
|
+
fees?: FeeBreakdown;
|
|
118
|
+
/** Message or reason in case of failure */
|
|
119
|
+
failureReason?: string;
|
|
120
|
+
/** Timestamp when refund was processed */
|
|
121
|
+
processedAt?: Date;
|
|
122
|
+
/** Raw provider response for debugging */
|
|
123
|
+
providerResponse?: TMetadata;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Result returned when checking payment transaction status from a provider.
|
|
127
|
+
*/
|
|
128
|
+
export interface PaymentStatusResult<TMetadata extends object = object> {
|
|
129
|
+
/** Current normalized payment status */
|
|
130
|
+
status: PAYMENTSTATUS;
|
|
131
|
+
/** Internal Plyaz transaction ID */
|
|
132
|
+
transactionId: string;
|
|
133
|
+
/** Provider transaction ID */
|
|
134
|
+
providerTransactionId?: string;
|
|
135
|
+
/** Amount charged */
|
|
136
|
+
amount: Money;
|
|
137
|
+
/** Any refund amount if already processed */
|
|
138
|
+
refundedAmount?: Money;
|
|
139
|
+
/** Timestamp of the latest status update */
|
|
140
|
+
updatedAt: Date;
|
|
141
|
+
/** Additional metadata or raw provider payload */
|
|
142
|
+
metadata?: TMetadata;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Generic webhook payload structure used for parsing
|
|
146
|
+
* incoming events from any payment provider.
|
|
147
|
+
*/
|
|
148
|
+
export interface WebhookPayload {
|
|
149
|
+
event: string;
|
|
150
|
+
/** Raw body of the webhook request */
|
|
151
|
+
rawBody: string;
|
|
152
|
+
/** Headers of the webhook request (for signature validation) */
|
|
153
|
+
headers: Record<string, string | string[]>;
|
|
154
|
+
/** Signature extracted from headers */
|
|
155
|
+
signature?: string;
|
|
156
|
+
/** Provider type (e.g., stripe, paypal, etc.) */
|
|
157
|
+
provider: PAYMENTPROVIDERTYPE;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Normalized webhook result returned after processing provider webhook.
|
|
161
|
+
*/
|
|
162
|
+
export interface WebhookResult<TMetadata extends object = object> {
|
|
163
|
+
/** Whether the webhook was successfully processed */
|
|
164
|
+
success: boolean;
|
|
165
|
+
/** Event type normalized to Plyaz domain */
|
|
166
|
+
eventType: string;
|
|
167
|
+
/** Transaction ID this event relates to */
|
|
168
|
+
transactionId?: string;
|
|
169
|
+
/** Updated payment status if applicable */
|
|
170
|
+
updatedStatus?: PAYMENTSTATUS;
|
|
171
|
+
/** Optional message for logging or auditing */
|
|
172
|
+
message?: string;
|
|
173
|
+
/** Raw provider webhook payload */
|
|
174
|
+
providerPayload?: TMetadata;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Options for calculating transaction fees before actual processing.
|
|
178
|
+
*/
|
|
179
|
+
export interface FeeCalculationOptions<TMetadata extends object = object> {
|
|
180
|
+
/** Indicates whether this is a test transaction */
|
|
181
|
+
testMode?: boolean;
|
|
182
|
+
/** Whether to include platform fees */
|
|
183
|
+
includePlatformFees?: boolean;
|
|
184
|
+
/** User location or region for tax/fee calculation */
|
|
185
|
+
geoInfo?: {
|
|
186
|
+
country: string;
|
|
187
|
+
region?: string;
|
|
188
|
+
city?: string;
|
|
189
|
+
};
|
|
190
|
+
/** Transaction metadata that can influence fees */
|
|
191
|
+
metadata?: TMetadata;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Parameters for creating a customer profile with a provider
|
|
195
|
+
* (only used if provider supports saving customer data).
|
|
196
|
+
*/
|
|
197
|
+
export interface CreateCustomerParams<TMetadata extends object = object> {
|
|
198
|
+
/** Unique Plyaz user ID */
|
|
199
|
+
userId: string;
|
|
200
|
+
/** Email address of the customer */
|
|
201
|
+
email: string;
|
|
202
|
+
/** Full name of the customer */
|
|
203
|
+
name?: string;
|
|
204
|
+
/** Optional phone number */
|
|
205
|
+
phone?: string;
|
|
206
|
+
/** Billing address */
|
|
207
|
+
address?: {
|
|
208
|
+
line1: string;
|
|
209
|
+
line2?: string;
|
|
210
|
+
city: string;
|
|
211
|
+
state?: string;
|
|
212
|
+
postalCode?: string;
|
|
213
|
+
country: string;
|
|
214
|
+
};
|
|
215
|
+
/** Additional metadata */
|
|
216
|
+
metadata?: TMetadata;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Result returned after successfully creating a customer with a provider.
|
|
220
|
+
*/
|
|
221
|
+
export interface CustomerResult<TMetadata extends object = object> {
|
|
222
|
+
/** Plyaz customer ID */
|
|
223
|
+
customerId: string;
|
|
224
|
+
/** Provider-specific customer ID */
|
|
225
|
+
providerCustomerId: string;
|
|
226
|
+
/** Confirmation message or notes */
|
|
227
|
+
message?: string;
|
|
228
|
+
/** Raw provider response */
|
|
229
|
+
providerResponse?: TMetadata;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Parameters for saving a payment method with a provider.
|
|
233
|
+
*/
|
|
234
|
+
export interface SavePaymentMethodParams<TMetadata extends object = object> {
|
|
235
|
+
/** Plyaz user ID */
|
|
236
|
+
userId: string;
|
|
237
|
+
/** Provider customer ID */
|
|
238
|
+
providerCustomerId: string;
|
|
239
|
+
/** Type of payment method (card, bank account, wallet, etc.) */
|
|
240
|
+
method: PAYMENTMETHOD;
|
|
241
|
+
/** Token or ID returned from provider after authorization */
|
|
242
|
+
paymentToken: string;
|
|
243
|
+
/** Whether this should be the default method for the user */
|
|
244
|
+
setDefault?: boolean;
|
|
245
|
+
/** Additional metadata */
|
|
246
|
+
metadata?: TMetadata;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Result returned after saving a payment method with a provider.
|
|
250
|
+
*/
|
|
251
|
+
export interface SavedPaymentMethodResult<TMetadata extends object = object> {
|
|
252
|
+
/** Internal ID for the saved payment method */
|
|
253
|
+
paymentMethodId: string;
|
|
254
|
+
/** Provider-specific payment method ID */
|
|
255
|
+
providerPaymentMethodId: string;
|
|
256
|
+
/** Last four digits (for cards) or display info */
|
|
257
|
+
displayInfo?: string;
|
|
258
|
+
/** Whether this method is set as default */
|
|
259
|
+
isDefault?: boolean;
|
|
260
|
+
/** Timestamp when method was saved */
|
|
261
|
+
savedAt: Date;
|
|
262
|
+
/** Raw provider response */
|
|
263
|
+
providerResponse?: TMetadata;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Query parameters for fetching transaction history from a provider.
|
|
267
|
+
*/
|
|
268
|
+
export interface TransactionHistoryParams {
|
|
269
|
+
/** Plyaz user ID */
|
|
270
|
+
userId: string;
|
|
271
|
+
/** Date range for transactions */
|
|
272
|
+
dateRange?: {
|
|
273
|
+
from: Date;
|
|
274
|
+
to: Date;
|
|
275
|
+
};
|
|
276
|
+
/** Filter by payment status */
|
|
277
|
+
status?: PAYMENTSTATUS;
|
|
278
|
+
/** Maximum number of records to return */
|
|
279
|
+
limit?: number;
|
|
280
|
+
/** Pagination cursor or token */
|
|
281
|
+
cursor?: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Transaction history result returned by provider.
|
|
285
|
+
*/
|
|
286
|
+
export interface TransactionHistory<TMetadata extends object = object> {
|
|
287
|
+
/** List of transactions */
|
|
288
|
+
transactions: Array<{
|
|
289
|
+
transactionId: string;
|
|
290
|
+
providerTransactionId?: string;
|
|
291
|
+
amount: Money;
|
|
292
|
+
status: PAYMENTSTATUS;
|
|
293
|
+
createdAt: Date;
|
|
294
|
+
updatedAt?: Date;
|
|
295
|
+
method: PAYMENTMETHOD;
|
|
296
|
+
metadata?: TMetadata;
|
|
297
|
+
}>;
|
|
298
|
+
/** Pagination cursor for next page */
|
|
299
|
+
nextCursor?: string;
|
|
300
|
+
/** Whether there are more records available */
|
|
301
|
+
hasMore: boolean;
|
|
302
|
+
}
|
|
303
|
+
export interface PaymentAdapterConfig<TExtra extends object = object> {
|
|
304
|
+
/** Default region used if no specific mapping is found */
|
|
305
|
+
defaultRegion?: string;
|
|
306
|
+
/** Region → Provider mapping */
|
|
307
|
+
regionProviderMapping?: Record<string, PAYMENTPROVIDERTYPE>;
|
|
308
|
+
/** Provider credentials and environment configuration */
|
|
309
|
+
providers: {
|
|
310
|
+
[key in PAYMENTPROVIDERTYPE]?: {
|
|
311
|
+
apiKey?: string;
|
|
312
|
+
secretKey?: string;
|
|
313
|
+
merchantId?: string;
|
|
314
|
+
apiBaseUrl?: string;
|
|
315
|
+
webhookUrl?: string;
|
|
316
|
+
webhookSecret?: string;
|
|
317
|
+
environment: 'sandbox' | 'staging' | 'production';
|
|
318
|
+
extra?: TExtra;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
/** Fallback configuration (optional) */
|
|
322
|
+
fallbackRules?: {
|
|
323
|
+
enabled: boolean;
|
|
324
|
+
strategy: 'round_robin' | 'priority' | 'failover';
|
|
325
|
+
priorityList?: PAYMENTPROVIDERTYPE[];
|
|
326
|
+
};
|
|
327
|
+
/** Global settings (timeouts, logging, etc.) */
|
|
328
|
+
globalSettings?: {
|
|
329
|
+
timeout?: number;
|
|
330
|
+
enableLogging?: boolean;
|
|
331
|
+
retryAttempts?: number;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
export interface NormalizedPaymentRequest<TMetadata extends object = object> {
|
|
335
|
+
/** Amount to charge */
|
|
336
|
+
amount: Money;
|
|
337
|
+
/** Payment method */
|
|
338
|
+
method: PAYMENTMETHOD;
|
|
339
|
+
/** Currency */
|
|
340
|
+
currency: CURRENCY;
|
|
341
|
+
/** User initiating the transaction */
|
|
342
|
+
userId: string;
|
|
343
|
+
/** Product or service being purchased */
|
|
344
|
+
productId: string;
|
|
345
|
+
/** Optional statement description */
|
|
346
|
+
description?: string;
|
|
347
|
+
/** Redirect URL after successful payment */
|
|
348
|
+
returnUrl?: string;
|
|
349
|
+
/** Redirect URL after failure/cancellation */
|
|
350
|
+
cancelUrl?: string;
|
|
351
|
+
/** Idempotency key to prevent duplicates */
|
|
352
|
+
idempotencyKey?: string;
|
|
353
|
+
/** Extra metadata for business logic */
|
|
354
|
+
metadata?: TMetadata;
|
|
355
|
+
}
|
|
356
|
+
export interface TransactionDetails<TMetadata extends object = object> {
|
|
357
|
+
/** Internal Plyaz transaction ID */
|
|
358
|
+
transactionId: string;
|
|
359
|
+
/** Provider transaction ID */
|
|
360
|
+
providerTransactionId?: string;
|
|
361
|
+
/** Current payment status */
|
|
362
|
+
status: PAYMENTSTATUS;
|
|
363
|
+
/** Total amount of the transaction */
|
|
364
|
+
amount: Money;
|
|
365
|
+
/** Refunded amount (if applicable) */
|
|
366
|
+
refundedAmount?: Money;
|
|
367
|
+
/** Fees applied to this transaction */
|
|
368
|
+
fees?: FeeBreakdown;
|
|
369
|
+
/** Payment method used */
|
|
370
|
+
method: PAYMENTMETHOD;
|
|
371
|
+
/** Currency of the transaction */
|
|
372
|
+
currency: CURRENCY;
|
|
373
|
+
/** Timestamp when transaction was created */
|
|
374
|
+
createdAt: Date;
|
|
375
|
+
/** Timestamp of the latest status update */
|
|
376
|
+
updatedAt: Date;
|
|
377
|
+
/** Optional description or statement text */
|
|
378
|
+
description?: string;
|
|
379
|
+
/** Metadata and raw provider response */
|
|
380
|
+
metadata?: TMetadata;
|
|
381
|
+
}
|
|
382
|
+
export interface FeeStructure {
|
|
383
|
+
/** Percentage fee applied (e.g. 0.029 = 2.9%) */
|
|
384
|
+
percentageFee: number;
|
|
385
|
+
/** Fixed fee applied per transaction */
|
|
386
|
+
fixedFee: Money;
|
|
387
|
+
/** Optional additional fees for special cases */
|
|
388
|
+
additionalFees?: Array<{
|
|
389
|
+
name: string;
|
|
390
|
+
amount: Money;
|
|
391
|
+
description?: string;
|
|
392
|
+
}>;
|
|
393
|
+
/** Whether this fee structure includes taxes or surcharges */
|
|
394
|
+
includesTaxes?: boolean;
|
|
395
|
+
/** Last updated timestamp for fee structure */
|
|
396
|
+
updatedAt: Date;
|
|
397
|
+
}
|
|
398
|
+
export interface AdapterConfiguration<TMetadata extends object = object> {
|
|
399
|
+
/** Provider type identifier */
|
|
400
|
+
provider: string;
|
|
401
|
+
/** Environment (sandbox, staging, production) */
|
|
402
|
+
environment: 'sandbox' | 'staging' | 'production';
|
|
403
|
+
/** Enabled capabilities/features */
|
|
404
|
+
features: Record<string, boolean>;
|
|
405
|
+
/** Webhook configuration */
|
|
406
|
+
webhook?: {
|
|
407
|
+
endpointUrl?: string;
|
|
408
|
+
secret?: string;
|
|
409
|
+
subscribedEvents?: string[];
|
|
410
|
+
};
|
|
411
|
+
/** Supported payment methods and currencies */
|
|
412
|
+
supportedMethods: PAYMENTMETHOD[];
|
|
413
|
+
supportedCurrencies: CURRENCY[];
|
|
414
|
+
/** Additional configuration or metadata */
|
|
415
|
+
metadata?: TMetadata;
|
|
416
|
+
}
|
|
417
|
+
export interface SavedPaymentMethod<TMetadata extends object = object> {
|
|
418
|
+
/** Internal ID for the saved payment method */
|
|
419
|
+
id: string;
|
|
420
|
+
/** Provider-specific payment method ID */
|
|
421
|
+
providerPaymentMethodId: string;
|
|
422
|
+
/** Type of payment method (card, wallet, etc.) */
|
|
423
|
+
method: PAYMENTMETHOD;
|
|
424
|
+
/** Display-friendly label (e.g. “Visa •••• 4242”) */
|
|
425
|
+
label?: string;
|
|
426
|
+
/** Whether this is the default payment method */
|
|
427
|
+
isDefault: boolean;
|
|
428
|
+
/** Date the method was saved */
|
|
429
|
+
savedAt: Date;
|
|
430
|
+
/** Extra provider-specific metadata */
|
|
431
|
+
metadata?: TMetadata;
|
|
432
|
+
}
|
|
433
|
+
export interface CreateSubscriptionParams<TMetadata extends object = object> {
|
|
434
|
+
/** Plyaz user ID */
|
|
435
|
+
userId: string;
|
|
436
|
+
/** Amount per billing cycle */
|
|
437
|
+
amount: Money;
|
|
438
|
+
/** Billing cycle (in ISO 8601 duration or custom format) */
|
|
439
|
+
billingCycle: string;
|
|
440
|
+
/** Payment method to charge */
|
|
441
|
+
paymentMethodId: string;
|
|
442
|
+
/** Optional trial period in days */
|
|
443
|
+
trialDays?: number;
|
|
444
|
+
/** Subscription metadata */
|
|
445
|
+
metadata?: TMetadata;
|
|
446
|
+
}
|
|
447
|
+
export interface SubscriptionResult<TMetadata extends object = object> {
|
|
448
|
+
/** Internal Plyaz subscription ID */
|
|
449
|
+
subscriptionId: string;
|
|
450
|
+
/** Provider subscription ID */
|
|
451
|
+
providerSubscriptionId?: string;
|
|
452
|
+
/** Current subscription status */
|
|
453
|
+
status: 'active' | 'trialing' | 'paused' | 'canceled' | 'expired';
|
|
454
|
+
/** Next billing date */
|
|
455
|
+
nextBillingDate?: Date;
|
|
456
|
+
/** Start date of subscription */
|
|
457
|
+
startedAt: Date;
|
|
458
|
+
/** Metadata and provider payload */
|
|
459
|
+
metadata?: TMetadata;
|
|
460
|
+
}
|
|
461
|
+
export interface PayoutParams<TMetadata extends object = object> {
|
|
462
|
+
/** Unique ID of the recipient (e.g. merchant ID) */
|
|
463
|
+
recipientId: string;
|
|
464
|
+
/** Amount to pay out */
|
|
465
|
+
amount: Money;
|
|
466
|
+
/** Currency of payout */
|
|
467
|
+
currency: CURRENCY;
|
|
468
|
+
/** Optional bank account / wallet ID at provider */
|
|
469
|
+
destinationId?: string;
|
|
470
|
+
/** Optional description */
|
|
471
|
+
description?: string;
|
|
472
|
+
/** Optional metadata */
|
|
473
|
+
metadata?: TMetadata;
|
|
474
|
+
}
|
|
475
|
+
export interface PayoutResult<TMetadata extends object = object> {
|
|
476
|
+
/** Plyaz payout ID */
|
|
477
|
+
payoutId: string;
|
|
478
|
+
/** Provider payout ID */
|
|
479
|
+
providerPayoutId?: string;
|
|
480
|
+
/** Payout status */
|
|
481
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
482
|
+
/** Timestamp of payout initiation */
|
|
483
|
+
createdAt: Date;
|
|
484
|
+
/** Timestamp of payout completion (if any) */
|
|
485
|
+
completedAt?: Date;
|
|
486
|
+
/** Metadata and provider response */
|
|
487
|
+
metadata?: TMetadata;
|
|
488
|
+
}
|
|
489
|
+
export interface SavedPaymentMethodInfo {
|
|
490
|
+
id: string;
|
|
491
|
+
label: string;
|
|
492
|
+
method: PAYMENTMETHOD;
|
|
493
|
+
isDefault: boolean;
|
|
494
|
+
}
|
|
495
|
+
export interface ReceiptData<TMetadata extends object = object> {
|
|
496
|
+
receiptId: string;
|
|
497
|
+
issuedAt: Date;
|
|
498
|
+
amount: Money;
|
|
499
|
+
currency: CURRENCY;
|
|
500
|
+
lineItems?: Array<{
|
|
501
|
+
name: string;
|
|
502
|
+
quantity: number;
|
|
503
|
+
unitAmount: Money;
|
|
504
|
+
}>;
|
|
505
|
+
tax?: Money;
|
|
506
|
+
total: Money;
|
|
507
|
+
providerMetadata?: TMetadata;
|
|
508
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|