@digilogiclabs/saas-factory-payments 0.2.0 → 0.2.1

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,204 @@
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
+ status: SubscriptionStatus;
22
+ items: SubscriptionItem[];
23
+ currentPeriodStart: Date;
24
+ currentPeriodEnd: Date;
25
+ cancelAtPeriodEnd: boolean;
26
+ trialEnd?: Date;
27
+ trialStart?: Date;
28
+ canceledAt?: Date;
29
+ endedAt?: Date;
30
+ metadata?: Record<string, string>;
31
+ created: Date;
32
+ updated: Date;
33
+ }
34
+ interface SubscriptionCreateParams {
35
+ customerId: string;
36
+ items: {
37
+ priceId: string;
38
+ quantity?: number;
39
+ }[];
40
+ trialPeriodDays?: number;
41
+ metadata?: Record<string, string>;
42
+ paymentBehavior?: 'default_incomplete' | 'error_if_incomplete' | 'allow_incomplete';
43
+ }
44
+ interface SubscriptionUpdateParams {
45
+ items?: {
46
+ priceId: string;
47
+ quantity?: number;
48
+ }[];
49
+ cancelAtPeriodEnd?: boolean;
50
+ metadata?: Record<string, string>;
51
+ }
52
+
53
+ interface Customer {
54
+ id: string;
55
+ email: string;
56
+ name?: string | null;
57
+ phone?: string | null;
58
+ stripeCustomerId?: string | null;
59
+ subscriptions: Subscription[];
60
+ defaultPaymentMethodId?: string | null;
61
+ paymentMethods: PaymentMethod[];
62
+ metadata?: Record<string, string>;
63
+ created: Date;
64
+ updated: Date;
65
+ }
66
+ interface CustomerCreateParams {
67
+ email: string;
68
+ name?: string;
69
+ phone?: string;
70
+ metadata?: Record<string, string>;
71
+ paymentMethod?: string;
72
+ }
73
+ interface CustomerUpdateParams {
74
+ email?: string;
75
+ name?: string;
76
+ phone?: string;
77
+ metadata?: Record<string, string>;
78
+ defaultPaymentMethod?: string;
79
+ }
80
+ interface PaymentMethod {
81
+ id: string;
82
+ type: 'card' | 'bank_account' | 'sepa_debit' | 'ideal' | 'sofort';
83
+ card?: {
84
+ brand: string;
85
+ last4: string;
86
+ expMonth: number;
87
+ expYear: number;
88
+ country?: string;
89
+ };
90
+ bankAccount?: {
91
+ last4: string;
92
+ bankName?: string;
93
+ accountType?: string;
94
+ };
95
+ billingDetails?: {
96
+ address?: BillingAddress;
97
+ email?: string;
98
+ name?: string;
99
+ phone?: string;
100
+ };
101
+ isDefault: boolean;
102
+ created: Date;
103
+ }
104
+ interface BillingAddress {
105
+ line1?: string;
106
+ line2?: string;
107
+ city?: string;
108
+ state?: string;
109
+ postalCode?: string;
110
+ country?: string;
111
+ }
112
+
113
+ interface StripeConfig {
114
+ publishableKey: string;
115
+ apiVersion?: string;
116
+ }
117
+ interface PricingPlan {
118
+ id: string;
119
+ name: string;
120
+ description?: string;
121
+ price: number;
122
+ currency: string;
123
+ interval: 'day' | 'week' | 'month' | 'year';
124
+ intervalCount?: number;
125
+ stripePriceId: string;
126
+ stripeProductId?: string;
127
+ features: string[];
128
+ popular?: boolean;
129
+ trialPeriodDays?: number;
130
+ metadata?: Record<string, string>;
131
+ }
132
+ interface CheckoutSessionParams {
133
+ priceId: string;
134
+ customerId?: string;
135
+ customerEmail?: string;
136
+ successUrl: string;
137
+ cancelUrl: string;
138
+ mode?: 'payment' | 'subscription' | 'setup';
139
+ allowPromotionCodes?: boolean;
140
+ billingAddressCollection?: 'auto' | 'required';
141
+ metadata?: Record<string, string>;
142
+ trialPeriodDays?: number;
143
+ }
144
+ interface PaymentIntentParams {
145
+ amount: number;
146
+ currency: string;
147
+ customerId?: string;
148
+ paymentMethodTypes?: string[];
149
+ metadata?: Record<string, string>;
150
+ description?: string;
151
+ }
152
+ interface WebhookEvent {
153
+ id: string;
154
+ type: string;
155
+ data: {
156
+ object: unknown;
157
+ previous_attributes?: unknown;
158
+ };
159
+ created: number;
160
+ livemode: boolean;
161
+ pending_webhooks: number;
162
+ request?: {
163
+ id: string;
164
+ idempotency_key?: string;
165
+ };
166
+ }
167
+ interface StripeError {
168
+ type: 'card_error' | 'invalid_request_error' | 'api_error' | 'authentication_error' | 'rate_limit_error';
169
+ code?: string;
170
+ message: string;
171
+ param?: string;
172
+ decline_code?: string;
173
+ }
174
+ interface Invoice {
175
+ id: string;
176
+ customerId: string;
177
+ subscriptionId?: string;
178
+ status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void';
179
+ amountDue: number;
180
+ amountPaid: number;
181
+ currency: string;
182
+ dueDate?: Date;
183
+ paidAt?: Date;
184
+ hostedInvoiceUrl?: string;
185
+ invoicePdf?: string;
186
+ metadata?: Record<string, string>;
187
+ }
188
+
189
+ type PaymentProviderType = 'stripe' | 'mock';
190
+ interface PaymentsConfig {
191
+ provider: PaymentProviderType;
192
+ publishableKey?: string;
193
+ secretKey?: string;
194
+ webhookSecret?: string;
195
+ environment: 'development' | 'production';
196
+ features?: {
197
+ customerPortal?: boolean;
198
+ paymentMethods?: string[];
199
+ currencies?: string[];
200
+ };
201
+ stripeConfig?: StripeConfig;
202
+ }
203
+
204
+ export { type BillingAddress as B, type Customer as C, type Invoice as I, type PaymentsConfig as P, type Subscription as S, type WebhookEvent as W, type CustomerCreateParams as a, type SubscriptionCreateParams as b, SubscriptionStatus as c, type SubscriptionUpdateParams as d, type PricingPlan as e, type SubscriptionItem as f, type CustomerUpdateParams as g, type PaymentMethod as h, type StripeConfig as i, type CheckoutSessionParams as j, type PaymentIntentParams as k, type StripeError as l, type PaymentProviderType as m };
@@ -0,0 +1,204 @@
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
+ status: SubscriptionStatus;
22
+ items: SubscriptionItem[];
23
+ currentPeriodStart: Date;
24
+ currentPeriodEnd: Date;
25
+ cancelAtPeriodEnd: boolean;
26
+ trialEnd?: Date;
27
+ trialStart?: Date;
28
+ canceledAt?: Date;
29
+ endedAt?: Date;
30
+ metadata?: Record<string, string>;
31
+ created: Date;
32
+ updated: Date;
33
+ }
34
+ interface SubscriptionCreateParams {
35
+ customerId: string;
36
+ items: {
37
+ priceId: string;
38
+ quantity?: number;
39
+ }[];
40
+ trialPeriodDays?: number;
41
+ metadata?: Record<string, string>;
42
+ paymentBehavior?: 'default_incomplete' | 'error_if_incomplete' | 'allow_incomplete';
43
+ }
44
+ interface SubscriptionUpdateParams {
45
+ items?: {
46
+ priceId: string;
47
+ quantity?: number;
48
+ }[];
49
+ cancelAtPeriodEnd?: boolean;
50
+ metadata?: Record<string, string>;
51
+ }
52
+
53
+ interface Customer {
54
+ id: string;
55
+ email: string;
56
+ name?: string | null;
57
+ phone?: string | null;
58
+ stripeCustomerId?: string | null;
59
+ subscriptions: Subscription[];
60
+ defaultPaymentMethodId?: string | null;
61
+ paymentMethods: PaymentMethod[];
62
+ metadata?: Record<string, string>;
63
+ created: Date;
64
+ updated: Date;
65
+ }
66
+ interface CustomerCreateParams {
67
+ email: string;
68
+ name?: string;
69
+ phone?: string;
70
+ metadata?: Record<string, string>;
71
+ paymentMethod?: string;
72
+ }
73
+ interface CustomerUpdateParams {
74
+ email?: string;
75
+ name?: string;
76
+ phone?: string;
77
+ metadata?: Record<string, string>;
78
+ defaultPaymentMethod?: string;
79
+ }
80
+ interface PaymentMethod {
81
+ id: string;
82
+ type: 'card' | 'bank_account' | 'sepa_debit' | 'ideal' | 'sofort';
83
+ card?: {
84
+ brand: string;
85
+ last4: string;
86
+ expMonth: number;
87
+ expYear: number;
88
+ country?: string;
89
+ };
90
+ bankAccount?: {
91
+ last4: string;
92
+ bankName?: string;
93
+ accountType?: string;
94
+ };
95
+ billingDetails?: {
96
+ address?: BillingAddress;
97
+ email?: string;
98
+ name?: string;
99
+ phone?: string;
100
+ };
101
+ isDefault: boolean;
102
+ created: Date;
103
+ }
104
+ interface BillingAddress {
105
+ line1?: string;
106
+ line2?: string;
107
+ city?: string;
108
+ state?: string;
109
+ postalCode?: string;
110
+ country?: string;
111
+ }
112
+
113
+ interface StripeConfig {
114
+ publishableKey: string;
115
+ apiVersion?: string;
116
+ }
117
+ interface PricingPlan {
118
+ id: string;
119
+ name: string;
120
+ description?: string;
121
+ price: number;
122
+ currency: string;
123
+ interval: 'day' | 'week' | 'month' | 'year';
124
+ intervalCount?: number;
125
+ stripePriceId: string;
126
+ stripeProductId?: string;
127
+ features: string[];
128
+ popular?: boolean;
129
+ trialPeriodDays?: number;
130
+ metadata?: Record<string, string>;
131
+ }
132
+ interface CheckoutSessionParams {
133
+ priceId: string;
134
+ customerId?: string;
135
+ customerEmail?: string;
136
+ successUrl: string;
137
+ cancelUrl: string;
138
+ mode?: 'payment' | 'subscription' | 'setup';
139
+ allowPromotionCodes?: boolean;
140
+ billingAddressCollection?: 'auto' | 'required';
141
+ metadata?: Record<string, string>;
142
+ trialPeriodDays?: number;
143
+ }
144
+ interface PaymentIntentParams {
145
+ amount: number;
146
+ currency: string;
147
+ customerId?: string;
148
+ paymentMethodTypes?: string[];
149
+ metadata?: Record<string, string>;
150
+ description?: string;
151
+ }
152
+ interface WebhookEvent {
153
+ id: string;
154
+ type: string;
155
+ data: {
156
+ object: unknown;
157
+ previous_attributes?: unknown;
158
+ };
159
+ created: number;
160
+ livemode: boolean;
161
+ pending_webhooks: number;
162
+ request?: {
163
+ id: string;
164
+ idempotency_key?: string;
165
+ };
166
+ }
167
+ interface StripeError {
168
+ type: 'card_error' | 'invalid_request_error' | 'api_error' | 'authentication_error' | 'rate_limit_error';
169
+ code?: string;
170
+ message: string;
171
+ param?: string;
172
+ decline_code?: string;
173
+ }
174
+ interface Invoice {
175
+ id: string;
176
+ customerId: string;
177
+ subscriptionId?: string;
178
+ status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void';
179
+ amountDue: number;
180
+ amountPaid: number;
181
+ currency: string;
182
+ dueDate?: Date;
183
+ paidAt?: Date;
184
+ hostedInvoiceUrl?: string;
185
+ invoicePdf?: string;
186
+ metadata?: Record<string, string>;
187
+ }
188
+
189
+ type PaymentProviderType = 'stripe' | 'mock';
190
+ interface PaymentsConfig {
191
+ provider: PaymentProviderType;
192
+ publishableKey?: string;
193
+ secretKey?: string;
194
+ webhookSecret?: string;
195
+ environment: 'development' | 'production';
196
+ features?: {
197
+ customerPortal?: boolean;
198
+ paymentMethods?: string[];
199
+ currencies?: string[];
200
+ };
201
+ stripeConfig?: StripeConfig;
202
+ }
203
+
204
+ export { type BillingAddress as B, type Customer as C, type Invoice as I, type PaymentsConfig as P, type Subscription as S, type WebhookEvent as W, type CustomerCreateParams as a, type SubscriptionCreateParams as b, SubscriptionStatus as c, type SubscriptionUpdateParams as d, type PricingPlan as e, type SubscriptionItem as f, type CustomerUpdateParams as g, type PaymentMethod as h, type StripeConfig as i, type CheckoutSessionParams as j, type PaymentIntentParams as k, type StripeError as l, type PaymentProviderType as m };
package/dist/index.d.mts CHANGED
@@ -1,193 +1,7 @@
1
+ import { C as Customer, S as Subscription, a as CustomerCreateParams, b as SubscriptionCreateParams, c as SubscriptionStatus, d as SubscriptionUpdateParams, P as PaymentsConfig, e as PricingPlan } from './config-D_pa7Av-.mjs';
2
+ export { B as BillingAddress, j as CheckoutSessionParams, g as CustomerUpdateParams, I as Invoice, k as PaymentIntentParams, h as PaymentMethod, m as PaymentProviderType, i as StripeConfig, l as StripeError, f as SubscriptionItem, W as WebhookEvent } from './config-D_pa7Av-.mjs';
1
3
  import React from 'react';
2
4
 
3
- declare enum SubscriptionStatus {
4
- ACTIVE = "active",
5
- CANCELED = "canceled",
6
- PAST_DUE = "past_due",
7
- UNPAID = "unpaid",
8
- INCOMPLETE = "incomplete",
9
- INCOMPLETE_EXPIRED = "incomplete_expired",
10
- TRIALING = "trialing",
11
- ENDED = "ended",// Custom status for ended subscriptions
12
- ALL = "all"
13
- }
14
- interface SubscriptionItem {
15
- id: string;
16
- priceId: string;
17
- quantity: number;
18
- metadata?: Record<string, string>;
19
- }
20
- interface Subscription {
21
- id: string;
22
- customerId: string;
23
- status: SubscriptionStatus;
24
- items: SubscriptionItem[];
25
- currentPeriodStart: Date;
26
- currentPeriodEnd: Date;
27
- cancelAtPeriodEnd: boolean;
28
- trialEnd?: Date;
29
- trialStart?: Date;
30
- canceledAt?: Date;
31
- endedAt?: Date;
32
- metadata?: Record<string, string>;
33
- created: Date;
34
- updated: Date;
35
- }
36
- interface SubscriptionCreateParams {
37
- customerId: string;
38
- items: {
39
- priceId: string;
40
- quantity?: number;
41
- }[];
42
- trialPeriodDays?: number;
43
- metadata?: Record<string, string>;
44
- paymentBehavior?: 'default_incomplete' | 'error_if_incomplete' | 'allow_incomplete';
45
- }
46
- interface SubscriptionUpdateParams {
47
- items?: {
48
- priceId: string;
49
- quantity?: number;
50
- }[];
51
- cancelAtPeriodEnd?: boolean;
52
- metadata?: Record<string, string>;
53
- }
54
-
55
- interface Customer {
56
- id: string;
57
- email: string;
58
- name?: string | null;
59
- phone?: string | null;
60
- stripeCustomerId?: string | null;
61
- subscriptions: Subscription[];
62
- defaultPaymentMethodId?: string | null;
63
- paymentMethods: PaymentMethod[];
64
- metadata?: Record<string, string>;
65
- created: Date;
66
- updated: Date;
67
- }
68
- interface CustomerCreateParams {
69
- email: string;
70
- name?: string;
71
- phone?: string;
72
- metadata?: Record<string, string>;
73
- paymentMethod?: string;
74
- }
75
- interface CustomerUpdateParams {
76
- email?: string;
77
- name?: string;
78
- phone?: string;
79
- metadata?: Record<string, string>;
80
- defaultPaymentMethod?: string;
81
- }
82
- interface PaymentMethod {
83
- id: string;
84
- type: 'card' | 'bank_account' | 'sepa_debit' | 'ideal' | 'sofort';
85
- card?: {
86
- brand: string;
87
- last4: string;
88
- expMonth: number;
89
- expYear: number;
90
- country?: string;
91
- };
92
- bankAccount?: {
93
- last4: string;
94
- bankName?: string;
95
- accountType?: string;
96
- };
97
- billingDetails?: {
98
- address?: BillingAddress;
99
- email?: string;
100
- name?: string;
101
- phone?: string;
102
- };
103
- isDefault: boolean;
104
- created: Date;
105
- }
106
- interface BillingAddress {
107
- line1?: string;
108
- line2?: string;
109
- city?: string;
110
- state?: string;
111
- postalCode?: string;
112
- country?: string;
113
- }
114
-
115
- interface StripeConfig {
116
- publishableKey: string;
117
- apiVersion?: string;
118
- }
119
- interface PricingPlan {
120
- id: string;
121
- name: string;
122
- description?: string;
123
- price: number;
124
- currency: string;
125
- interval: 'day' | 'week' | 'month' | 'year';
126
- intervalCount?: number;
127
- stripePriceId: string;
128
- stripeProductId?: string;
129
- features: string[];
130
- popular?: boolean;
131
- trialPeriodDays?: number;
132
- metadata?: Record<string, string>;
133
- }
134
- interface CheckoutSessionParams {
135
- priceId: string;
136
- customerId?: string;
137
- customerEmail?: string;
138
- successUrl: string;
139
- cancelUrl: string;
140
- mode?: 'payment' | 'subscription' | 'setup';
141
- allowPromotionCodes?: boolean;
142
- billingAddressCollection?: 'auto' | 'required';
143
- metadata?: Record<string, string>;
144
- trialPeriodDays?: number;
145
- }
146
- interface PaymentIntentParams {
147
- amount: number;
148
- currency: string;
149
- customerId?: string;
150
- paymentMethodTypes?: string[];
151
- metadata?: Record<string, string>;
152
- description?: string;
153
- }
154
- interface WebhookEvent {
155
- id: string;
156
- type: string;
157
- data: {
158
- object: unknown;
159
- previous_attributes?: unknown;
160
- };
161
- created: number;
162
- livemode: boolean;
163
- pending_webhooks: number;
164
- request?: {
165
- id: string;
166
- idempotency_key?: string;
167
- };
168
- }
169
- interface StripeError {
170
- type: 'card_error' | 'invalid_request_error' | 'api_error' | 'authentication_error' | 'rate_limit_error';
171
- code?: string;
172
- message: string;
173
- param?: string;
174
- decline_code?: string;
175
- }
176
- interface Invoice {
177
- id: string;
178
- customerId: string;
179
- subscriptionId?: string;
180
- status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void';
181
- amountDue: number;
182
- amountPaid: number;
183
- currency: string;
184
- dueDate?: Date;
185
- paidAt?: Date;
186
- hostedInvoiceUrl?: string;
187
- invoicePdf?: string;
188
- metadata?: Record<string, string>;
189
- }
190
-
191
5
  interface CheckoutParams {
192
6
  priceId: string;
193
7
  mode?: 'payment' | 'subscription';
@@ -209,21 +23,6 @@ interface CheckoutSession {
209
23
  subscriptionId?: string;
210
24
  }
211
25
 
212
- type PaymentProviderType = 'stripe' | 'mock';
213
- interface PaymentsConfig {
214
- provider: PaymentProviderType;
215
- publishableKey?: string;
216
- secretKey?: string;
217
- webhookSecret?: string;
218
- environment: 'development' | 'production';
219
- features?: {
220
- customerPortal?: boolean;
221
- paymentMethods?: string[];
222
- currencies?: string[];
223
- };
224
- stripeConfig?: StripeConfig;
225
- }
226
-
227
26
  declare enum PaymentErrorType {
228
27
  CARD_DECLINED = "CARD_DECLINED",
229
28
  INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
@@ -507,4 +306,4 @@ interface UsePaymentsStore {
507
306
  }
508
307
  declare const usePayments: () => UsePaymentsStore;
509
308
 
510
- export { BILLING_INTERVALS, type BillingAddress, CHECKOUT_MODE, CURRENCY_SYMBOLS, type CheckoutParams, type CheckoutSession, type CheckoutSessionParams, type Customer, type CustomerCreateParams, type CustomerUpdateParams, DEFAULT_CURRENCY, ERROR_MESSAGES, type EnvironmentConfig, INVOICE_STATUS, type Invoice, PAYMENT_METHODS, type PaymentError, PaymentErrorType, type PaymentEvent, type PaymentIntentParams, type PaymentMethod, type PaymentProvider, type PaymentProviderType, type PaymentsConfig, PaymentsError, PaymentsProvider, type PaymentsProviderActions, type PaymentsProviderState, type PaymentsStore, type PricingPlan, STRIPE_API_VERSION, SUBSCRIPTION_STATUS, type StripeConfig, type StripeError, type Subscription, type SubscriptionCreateParams, type SubscriptionItem, SubscriptionStatus, type SubscriptionUpdateParams, WEBHOOK_EVENTS, type WebhookEvent, formatBillingInterval, formatCardBrand, formatCurrency, formatDate, formatPaymentMethodDisplay, formatPricingPlan, formatRelativeTime, formatSubscriptionStatus, formatTrialPeriod, getEnvironmentConfig, isClient, isDevelopment, isProduction, isServer, truncateText, usePayments, usePaymentsContext, validateAmount, validateCurrentEnvironment, validateEmail, validateEnvironment, validatePaymentsConfig, validatePhoneNumber, validatePricingPlan, validateStripeId };
309
+ export { BILLING_INTERVALS, CHECKOUT_MODE, CURRENCY_SYMBOLS, type CheckoutParams, type CheckoutSession, Customer, CustomerCreateParams, DEFAULT_CURRENCY, ERROR_MESSAGES, type EnvironmentConfig, INVOICE_STATUS, PAYMENT_METHODS, type PaymentError, PaymentErrorType, type PaymentEvent, type PaymentProvider, PaymentsConfig, PaymentsError, PaymentsProvider, type PaymentsProviderActions, type PaymentsProviderState, type PaymentsStore, PricingPlan, STRIPE_API_VERSION, SUBSCRIPTION_STATUS, Subscription, SubscriptionCreateParams, SubscriptionStatus, SubscriptionUpdateParams, WEBHOOK_EVENTS, formatBillingInterval, formatCardBrand, formatCurrency, formatDate, formatPaymentMethodDisplay, formatPricingPlan, formatRelativeTime, formatSubscriptionStatus, formatTrialPeriod, getEnvironmentConfig, isClient, isDevelopment, isProduction, isServer, truncateText, usePayments, usePaymentsContext, validateAmount, validateCurrentEnvironment, validateEmail, validateEnvironment, validatePaymentsConfig, validatePhoneNumber, validatePricingPlan, validateStripeId };