@digilogiclabs/saas-factory-payments 2.0.0 → 5.0.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 CHANGED
@@ -1,22 +1,22 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 DigiLogicLabs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
1
+ MIT License
2
+
3
+ Copyright (c) 2024 DigiLogicLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digilogiclabs/saas-factory-payments",
3
- "version": "2.0.0",
3
+ "version": "5.0.0",
4
4
  "private": false,
5
5
  "description": "Modern cross-platform payments package for Next.js 15+ and React Native applications with multi-provider support (Stripe, PayPal, Apple Pay) and subscription analytics",
6
6
  "keywords": [
@@ -72,6 +72,20 @@
72
72
  "LICENSE"
73
73
  ],
74
74
  "sideEffects": false,
75
+ "scripts": {
76
+ "build": "tsup",
77
+ "dev": "tsup --watch",
78
+ "test": "vitest run",
79
+ "test:watch": "vitest",
80
+ "lint": "eslint src --ext .ts,.tsx",
81
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
82
+ "type-check": "tsc --noEmit",
83
+ "clean": "rimraf dist",
84
+ "prepublishOnly": "npm run clean && npm run build",
85
+ "changeset": "changeset",
86
+ "version-packages": "changeset version",
87
+ "release": "npm run build && changeset publish"
88
+ },
75
89
  "dependencies": {
76
90
  "immer": "^10.1.1",
77
91
  "stripe": "^16.12.0",
@@ -83,7 +97,7 @@
83
97
  "@stripe/stripe-js": "^4.0.0",
84
98
  "@stripe/react-stripe-js": "^2.0.0",
85
99
  "@stripe/stripe-react-native": ">=0.38.0 <1.0.0",
86
- "@digilogiclabs/platform-core": "1.2.0"
100
+ "@digilogiclabs/platform-core": "workspace:*"
87
101
  },
88
102
  "peerDependenciesMeta": {
89
103
  "react-native": {
@@ -103,6 +117,7 @@
103
117
  }
104
118
  },
105
119
  "devDependencies": {
120
+ "@digilogiclabs/platform-core": "workspace:*",
106
121
  "@changesets/cli": "^2.27.0",
107
122
  "@stripe/react-stripe-js": "^2.8.0",
108
123
  "@stripe/stripe-js": "^4.10.0",
@@ -127,8 +142,7 @@
127
142
  "react-native": "^0.76.0",
128
143
  "typescript": "^5.7.0",
129
144
  "typescript-eslint": "^8.39.1",
130
- "vitest": "^2.1.9",
131
- "@digilogiclabs/platform-core": "1.2.0"
145
+ "vitest": "^2.1.9"
132
146
  },
133
147
  "overrides": {
134
148
  "rollup": "^4.0.0",
@@ -144,18 +158,5 @@
144
158
  "@stripe/stripe-js": "^4.10.0",
145
159
  "@types/react": "^18.2.0"
146
160
  }
147
- },
148
- "scripts": {
149
- "build": "tsup",
150
- "dev": "tsup --watch",
151
- "test": "vitest run",
152
- "test:watch": "vitest",
153
- "lint": "eslint src --ext .ts,.tsx",
154
- "lint:fix": "eslint src --ext .ts,.tsx --fix",
155
- "type-check": "tsc --noEmit",
156
- "clean": "rimraf dist",
157
- "changeset": "changeset",
158
- "version-packages": "changeset version",
159
- "release": "npm run build && changeset publish"
160
161
  }
161
- }
162
+ }
@@ -1,520 +0,0 @@
1
- declare enum SubscriptionStatus {
2
- ACTIVE = "active",
3
- CANCELED = "canceled",
4
- PAST_DUE = "past_due",
5
- UNPAID = "unpaid",
6
- INCOMPLETE = "incomplete",
7
- INCOMPLETE_EXPIRED = "incomplete_expired",
8
- TRIALING = "trialing",
9
- ENDED = "ended",// Custom status for ended subscriptions
10
- ALL = "all"
11
- }
12
- interface SubscriptionItem {
13
- id: string;
14
- priceId: string;
15
- quantity: number;
16
- metadata?: Record<string, string>;
17
- }
18
- interface Subscription {
19
- id: string;
20
- customerId: string;
21
- customer_id?: string;
22
- status: SubscriptionStatus;
23
- items?: SubscriptionItem[];
24
- price_id?: string;
25
- currentPeriodStart: Date;
26
- current_period_start?: Date;
27
- currentPeriodEnd: Date;
28
- current_period_end?: Date;
29
- cancelAtPeriodEnd: boolean;
30
- cancel_at_period_end?: boolean;
31
- trialEnd?: Date;
32
- trial_end?: Date;
33
- trialStart?: Date;
34
- trial_start?: Date;
35
- canceledAt?: Date;
36
- canceled_at?: Date;
37
- endedAt?: Date;
38
- metadata?: Record<string, string>;
39
- created: Date;
40
- updated?: Date;
41
- amount?: number;
42
- currency?: string;
43
- interval?: string;
44
- interval_unit?: string;
45
- planName?: string;
46
- planId?: string;
47
- }
48
- interface SubscriptionCreateParams {
49
- customerId: string;
50
- items?: {
51
- priceId: string;
52
- quantity?: number;
53
- }[];
54
- priceId?: string;
55
- trialPeriodDays?: number;
56
- metadata?: Record<string, string>;
57
- paymentBehavior?: 'default_incomplete' | 'error_if_incomplete' | 'allow_incomplete';
58
- customerEmail?: string;
59
- customerName?: string;
60
- successUrl?: string;
61
- cancelUrl?: string;
62
- }
63
- interface SubscriptionUpdateParams {
64
- items?: {
65
- priceId: string;
66
- quantity?: number;
67
- }[];
68
- priceId?: string;
69
- quantity?: number;
70
- cancelAtPeriodEnd?: boolean;
71
- metadata?: Record<string, string>;
72
- }
73
- type ActiveSubscriptionStatus = SubscriptionStatus.ACTIVE | SubscriptionStatus.TRIALING;
74
- type InactiveSubscriptionStatus = SubscriptionStatus.CANCELED | SubscriptionStatus.ENDED;
75
- type ProblematicSubscriptionStatus = SubscriptionStatus.PAST_DUE | SubscriptionStatus.UNPAID;
76
- type IncompleteSubscriptionStatus = SubscriptionStatus.INCOMPLETE | SubscriptionStatus.INCOMPLETE_EXPIRED;
77
- declare const ACTIVE_STATUSES: ActiveSubscriptionStatus[];
78
- declare const INACTIVE_STATUSES: InactiveSubscriptionStatus[];
79
- declare const PROBLEMATIC_STATUSES: ProblematicSubscriptionStatus[];
80
- declare const INCOMPLETE_STATUSES: IncompleteSubscriptionStatus[];
81
- declare const isActiveSubscription: (status: SubscriptionStatus) => status is ActiveSubscriptionStatus;
82
- declare const isInactiveSubscription: (status: SubscriptionStatus) => status is InactiveSubscriptionStatus;
83
- declare const isProblematicSubscription: (status: SubscriptionStatus) => status is ProblematicSubscriptionStatus;
84
- declare const isIncompleteSubscription: (status: SubscriptionStatus) => status is IncompleteSubscriptionStatus;
85
-
86
- interface Customer {
87
- id: string;
88
- email: string;
89
- name?: string | null;
90
- phone?: string | null;
91
- stripeCustomerId?: string | null;
92
- subscriptions: Subscription[];
93
- defaultPaymentMethodId?: string | null;
94
- paymentMethods: PaymentMethod[];
95
- metadata?: Record<string, string>;
96
- created: Date;
97
- updated: Date;
98
- }
99
- interface CustomerCreateParams {
100
- email: string;
101
- name?: string;
102
- phone?: string;
103
- metadata?: Record<string, string>;
104
- paymentMethod?: string;
105
- }
106
- interface CustomerUpdateParams {
107
- email?: string;
108
- name?: string;
109
- phone?: string;
110
- metadata?: Record<string, string>;
111
- defaultPaymentMethod?: string;
112
- }
113
- interface PaymentMethod {
114
- id: string;
115
- type: 'card' | 'bank_account' | 'sepa_debit' | 'ideal' | 'sofort';
116
- card?: {
117
- brand: string;
118
- last4: string;
119
- expMonth: number;
120
- expYear: number;
121
- country?: string;
122
- };
123
- bankAccount?: {
124
- last4: string;
125
- bankName?: string;
126
- accountType?: string;
127
- };
128
- billingDetails?: {
129
- address?: BillingAddress;
130
- email?: string;
131
- name?: string;
132
- phone?: string;
133
- };
134
- isDefault: boolean;
135
- created: Date;
136
- }
137
- interface BillingAddress {
138
- line1?: string;
139
- line2?: string;
140
- city?: string;
141
- state?: string;
142
- postalCode?: string;
143
- country?: string;
144
- }
145
-
146
- interface StripeConfig {
147
- publishableKey: string;
148
- apiVersion?: string;
149
- }
150
- interface PricingPlan {
151
- id: string;
152
- name: string;
153
- description?: string;
154
- price: number;
155
- currency: string;
156
- interval: 'day' | 'week' | 'month' | 'year';
157
- intervalCount?: number;
158
- stripePriceId: string;
159
- stripeProductId?: string;
160
- features: string[];
161
- popular?: boolean;
162
- trialPeriodDays?: number;
163
- metadata?: Record<string, string>;
164
- }
165
- interface CheckoutSessionParams {
166
- priceId: string;
167
- customerId?: string;
168
- customerEmail?: string;
169
- successUrl: string;
170
- cancelUrl: string;
171
- mode?: 'payment' | 'subscription' | 'setup';
172
- allowPromotionCodes?: boolean;
173
- billingAddressCollection?: 'auto' | 'required';
174
- metadata?: Record<string, string>;
175
- trialPeriodDays?: number;
176
- }
177
- interface PaymentIntentParams {
178
- amount: number;
179
- currency: string;
180
- customerId?: string;
181
- paymentMethodTypes?: string[];
182
- metadata?: Record<string, string>;
183
- description?: string;
184
- }
185
- interface WebhookEvent {
186
- id: string;
187
- type: string;
188
- data: {
189
- object: unknown;
190
- previous_attributes?: unknown;
191
- };
192
- created: number;
193
- livemode: boolean;
194
- pending_webhooks: number;
195
- request?: {
196
- id: string;
197
- idempotency_key?: string;
198
- };
199
- }
200
- interface StripeError {
201
- type: 'card_error' | 'invalid_request_error' | 'api_error' | 'authentication_error' | 'rate_limit_error';
202
- code?: string;
203
- message: string;
204
- param?: string;
205
- decline_code?: string;
206
- }
207
- interface Invoice {
208
- id: string;
209
- customerId: string;
210
- subscriptionId?: string;
211
- status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void';
212
- amountDue: number;
213
- amountPaid: number;
214
- currency: string;
215
- dueDate?: Date;
216
- paidAt?: Date;
217
- hostedInvoiceUrl?: string;
218
- invoicePdf?: string;
219
- metadata?: Record<string, string>;
220
- }
221
-
222
- interface CheckoutParams {
223
- priceId: string;
224
- mode?: 'payment' | 'subscription';
225
- customerId?: string;
226
- customerEmail?: string;
227
- allowPromotionCodes?: boolean;
228
- successUrl?: string;
229
- cancelUrl?: string;
230
- metadata?: Record<string, string | number | null>;
231
- amount?: number;
232
- currency?: string;
233
- description?: string;
234
- }
235
- interface CheckoutSession {
236
- id: string;
237
- url?: string | null;
238
- clientSecret?: string;
239
- status: 'open' | 'complete' | 'expired';
240
- amountTotal?: number;
241
- currency?: string;
242
- customerEmail?: string;
243
- subscriptionId?: string;
244
- customer_id?: string;
245
- amount_total?: number;
246
- mode?: 'payment' | 'subscription';
247
- payment_status?: 'paid' | 'unpaid';
248
- expires_at?: Date;
249
- metadata?: Record<string, any>;
250
- }
251
-
252
- interface PayPalConfig {
253
- clientId: string;
254
- clientSecret?: string;
255
- environment: 'sandbox' | 'production';
256
- intent?: 'capture' | 'authorize';
257
- currency?: string;
258
- locale?: string;
259
- enableFunding?: PayPalFundingSource[];
260
- disableFunding?: PayPalFundingSource[];
261
- merchantName?: string;
262
- }
263
- type PayPalFundingSource = 'paypal' | 'card' | 'credit' | 'paylater' | 'venmo' | 'applepay' | 'itau' | 'mercadopago';
264
-
265
- interface ApplePayConfig {
266
- merchantId: string;
267
- merchantName: string;
268
- countryCode: string;
269
- currencyCode: string;
270
- supportedNetworks?: ApplePayNetwork[];
271
- merchantCapabilities?: ApplePayMerchantCapability[];
272
- requiredBillingContactFields?: ApplePayContactField[];
273
- requiredShippingContactFields?: ApplePayContactField[];
274
- shippingType?: ApplePayShippingType;
275
- environment: 'production' | 'sandbox';
276
- }
277
- type ApplePayNetwork = 'amex' | 'chinaUnionPay' | 'discover' | 'eftpos' | 'electron' | 'elo' | 'idCredit' | 'interac' | 'jcb' | 'mada' | 'maestro' | 'masterCard' | 'privateLabel' | 'quicPay' | 'suica' | 'visa' | 'vPay';
278
- type ApplePayMerchantCapability = 'supports3DS' | 'supportsCredit' | 'supportsDebit' | 'supportsEMV';
279
- type ApplePayContactField = 'postalAddress' | 'phone' | 'email' | 'name' | 'phoneticName';
280
- type ApplePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
281
- interface ApplePayPaymentRequest {
282
- countryCode: string;
283
- currencyCode: string;
284
- merchantCapabilities: ApplePayMerchantCapability[];
285
- supportedNetworks: ApplePayNetwork[];
286
- total: ApplePayLineItem;
287
- lineItems?: ApplePayLineItem[];
288
- requiredBillingContactFields?: ApplePayContactField[];
289
- requiredShippingContactFields?: ApplePayContactField[];
290
- billingContact?: ApplePayPaymentContact;
291
- shippingContact?: ApplePayPaymentContact;
292
- applicationData?: string;
293
- supportedCountries?: string[];
294
- shippingType?: ApplePayShippingType;
295
- shippingMethods?: ApplePayShippingMethod[];
296
- recurringPaymentRequest?: ApplePayRecurringPaymentRequest;
297
- automaticReloadPaymentRequest?: ApplePayAutomaticReloadPaymentRequest;
298
- multiTokenContexts?: ApplePayPaymentTokenContext[];
299
- }
300
- interface ApplePayLineItem {
301
- label: string;
302
- amount: string;
303
- type?: 'final' | 'pending';
304
- }
305
- interface ApplePayPaymentContact {
306
- phoneNumber?: string;
307
- emailAddress?: string;
308
- givenName?: string;
309
- familyName?: string;
310
- phoneticGivenName?: string;
311
- phoneticFamilyName?: string;
312
- addressLines?: string[];
313
- locality?: string;
314
- postalCode?: string;
315
- administrativeArea?: string;
316
- country?: string;
317
- countryCode?: string;
318
- subLocality?: string;
319
- subAdministrativeArea?: string;
320
- }
321
- interface ApplePayShippingMethod {
322
- label: string;
323
- amount: string;
324
- type?: 'final' | 'pending';
325
- identifier?: string;
326
- detail?: string;
327
- }
328
- interface ApplePayRecurringPaymentRequest {
329
- paymentDescription: string;
330
- regularBilling: ApplePayLineItem;
331
- managementURL: string;
332
- billingAgreement?: string;
333
- trialBilling?: ApplePayLineItem;
334
- tokenNotificationURL?: string;
335
- }
336
- interface ApplePayAutomaticReloadPaymentRequest {
337
- paymentDescription: string;
338
- automaticReloadBilling: ApplePayLineItem;
339
- managementURL: string;
340
- billingAgreement?: string;
341
- tokenNotificationURL?: string;
342
- }
343
- interface ApplePayPaymentTokenContext {
344
- merchantID: string;
345
- externalIdentifier: string;
346
- merchantName: string;
347
- merchantDomain?: string;
348
- amount: string;
349
- }
350
- interface ApplePayPayment {
351
- token: ApplePayPaymentToken;
352
- billingContact?: ApplePayPaymentContact;
353
- shippingContact?: ApplePayPaymentContact;
354
- shippingMethod?: ApplePayShippingMethod;
355
- }
356
- interface ApplePayPaymentToken {
357
- paymentData: ApplePayPaymentData;
358
- paymentMethod: ApplePayPaymentMethod;
359
- transactionIdentifier: string;
360
- }
361
- interface ApplePayPaymentData {
362
- version: string;
363
- data: string;
364
- signature: string;
365
- header: ApplePayPaymentDataHeader;
366
- }
367
- interface ApplePayPaymentDataHeader {
368
- ephemeralPublicKey?: string;
369
- publicKeyHash?: string;
370
- transactionId: string;
371
- wrappedKey?: string;
372
- }
373
- interface ApplePayPaymentMethod {
374
- displayName?: string;
375
- network?: string;
376
- type: 'debit' | 'credit' | 'prepaid' | 'store';
377
- paymentPass?: ApplePayPaymentPass;
378
- billingContact?: ApplePayPaymentContact;
379
- }
380
- interface ApplePayPaymentPass {
381
- primaryAccountIdentifier: string;
382
- primaryAccountNumberSuffix: string;
383
- deviceAccountIdentifier?: string;
384
- deviceAccountNumberSuffix?: string;
385
- activationState: 'activated' | 'requiresActivation' | 'activating' | 'suspended' | 'deactivated';
386
- }
387
- interface ApplePayPaymentAuthorizationResult {
388
- status: ApplePayPaymentAuthorizationStatus;
389
- errors?: ApplePayError[];
390
- }
391
- type ApplePayPaymentAuthorizationStatus = 'success' | 'failure' | 'invalidBillingPostalAddress' | 'invalidShippingPostalAddress' | 'invalidShippingContact' | 'requiresPin';
392
- interface ApplePayError {
393
- code: ApplePayErrorCode;
394
- contactField?: ApplePayContactField;
395
- localizedDescription: string;
396
- }
397
- type ApplePayErrorCode = 'billingContactInvalid' | 'shippingContactInvalid' | 'addressUnserviceable' | 'unknown';
398
- interface ApplePaySession {
399
- canMakePayments(): boolean;
400
- canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise<boolean>;
401
- begin(): void;
402
- abort(): void;
403
- completeMerchantValidation(merchantSession: any): void;
404
- completeShippingMethodSelection(update: ApplePayShippingMethodUpdate): void;
405
- completeShippingContactSelection(update: ApplePayShippingContactUpdate): void;
406
- completePayment(result: ApplePayPaymentAuthorizationResult): void;
407
- onvalidatemerchant?: (event: ApplePayValidateMerchantEvent) => void;
408
- onpaymentmethodselected?: (event: ApplePayPaymentMethodSelectedEvent) => void;
409
- onshippingmethodselected?: (event: ApplePayShippingMethodSelectedEvent) => void;
410
- onshippingcontactselected?: (event: ApplePayShippingContactSelectedEvent) => void;
411
- onpaymentauthorized?: (event: ApplePayPaymentAuthorizedEvent) => void;
412
- oncancel?: (event: Event) => void;
413
- }
414
- interface ApplePayValidateMerchantEvent extends Event {
415
- validationURL: string;
416
- }
417
- interface ApplePayPaymentMethodSelectedEvent extends Event {
418
- paymentMethod: ApplePayPaymentMethod;
419
- }
420
- interface ApplePayShippingMethodSelectedEvent extends Event {
421
- shippingMethod: ApplePayShippingMethod;
422
- }
423
- interface ApplePayShippingContactSelectedEvent extends Event {
424
- shippingContact: ApplePayPaymentContact;
425
- }
426
- interface ApplePayPaymentAuthorizedEvent extends Event {
427
- payment: ApplePayPayment;
428
- }
429
- interface ApplePayShippingMethodUpdate {
430
- newTotal: ApplePayLineItem;
431
- newLineItems?: ApplePayLineItem[];
432
- }
433
- interface ApplePayShippingContactUpdate {
434
- newTotal: ApplePayLineItem;
435
- newLineItems?: ApplePayLineItem[];
436
- newShippingMethods?: ApplePayShippingMethod[];
437
- errors?: ApplePayError[];
438
- }
439
- interface ApplePayJS {
440
- canMakePayments(): boolean;
441
- canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise<boolean>;
442
- Session: {
443
- new (version: number, paymentRequest: ApplePayPaymentRequest): ApplePaySession;
444
- };
445
- }
446
- declare global {
447
- interface Window {
448
- ApplePaySession?: ApplePayJS;
449
- }
450
- }
451
-
452
- type PaymentProviderType = 'stripe' | 'paypal' | 'applepay' | 'mock';
453
- interface PaymentsConfig {
454
- provider: PaymentProviderType;
455
- publishableKey?: string;
456
- secretKey?: string;
457
- webhookSecret?: string;
458
- environment: 'development' | 'production';
459
- features?: {
460
- customerPortal?: boolean;
461
- paymentMethods?: string[];
462
- currencies?: string[];
463
- };
464
- stripeConfig?: StripeConfig;
465
- paypalConfig?: PayPalConfig;
466
- applePayConfig?: ApplePayConfig;
467
- }
468
-
469
- declare enum PaymentErrorType {
470
- CARD_DECLINED = "CARD_DECLINED",
471
- INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
472
- CUSTOMER_NOT_FOUND = "CUSTOMER_NOT_FOUND",
473
- SUBSCRIPTION_NOT_FOUND = "SUBSCRIPTION_NOT_FOUND",
474
- NETWORK_ERROR = "NETWORK_ERROR",
475
- CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
476
- WEBHOOK_ERROR = "WEBHOOK_ERROR",
477
- VALIDATION_ERROR = "VALIDATION_ERROR",
478
- PROVIDER_NOT_CONFIGURED = "PROVIDER_NOT_CONFIGURED",
479
- UNKNOWN_ERROR = "UNKNOWN_ERROR",
480
- INITIALIZATION_ERROR = "INITIALIZATION_ERROR",
481
- AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR",
482
- NOT_FOUND = "NOT_FOUND",
483
- INVALID_REQUEST = "INVALID_REQUEST",
484
- API_ERROR = "API_ERROR",
485
- PERMISSION_DENIED = "PERMISSION_DENIED",
486
- WEBHOOK_VERIFICATION_FAILED = "WEBHOOK_VERIFICATION_FAILED"
487
- }
488
- interface PaymentError extends Error {
489
- type: PaymentErrorType;
490
- code?: string;
491
- details?: Record<string, unknown>;
492
- }
493
- declare class PaymentsError extends Error implements PaymentError {
494
- type: PaymentErrorType;
495
- code?: string;
496
- details?: Record<string, unknown>;
497
- constructor(type: PaymentErrorType, message: string, code?: string, details?: Record<string, unknown>);
498
- }
499
-
500
- type PaymentEvent = {
501
- type: 'checkoutSuccess';
502
- session: CheckoutSession;
503
- } | {
504
- type: 'paymentMethodAdded';
505
- customer: Customer;
506
- } | {
507
- type: 'subscriptionCreated';
508
- subscription: Subscription;
509
- } | {
510
- type: 'subscriptionUpdated';
511
- subscription: Subscription;
512
- } | {
513
- type: 'subscriptionCanceled';
514
- subscription: Subscription;
515
- } | {
516
- type: 'error';
517
- error: PaymentError;
518
- };
519
-
520
- export { type ActiveSubscriptionStatus as A, type BillingAddress as B, type CheckoutParams as C, type StripeError as D, type Invoice as E, type PaymentEvent as F, type PaymentError as G, type InactiveSubscriptionStatus as I, type PricingPlan as P, SubscriptionStatus as S, type WebhookEvent as W, type PaymentsConfig as a, type PaymentProviderType as b, type CheckoutSession as c, type CustomerCreateParams as d, type Customer as e, type SubscriptionCreateParams as f, type Subscription as g, type SubscriptionUpdateParams as h, PaymentErrorType as i, PaymentsError as j, type PaymentMethod as k, type SubscriptionItem as l, type ProblematicSubscriptionStatus as m, type IncompleteSubscriptionStatus as n, ACTIVE_STATUSES as o, INACTIVE_STATUSES as p, PROBLEMATIC_STATUSES as q, INCOMPLETE_STATUSES as r, isActiveSubscription as s, isInactiveSubscription as t, isProblematicSubscription as u, isIncompleteSubscription as v, type CustomerUpdateParams as w, type StripeConfig as x, type CheckoutSessionParams as y, type PaymentIntentParams as z };