@reeboot/strapi-payment-plugin 0.0.9 → 0.0.10

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 (36) hide show
  1. package/dist/_chunks/{Analytics-kChERzX4.mjs → Analytics-CPXtqS6s.mjs} +1 -1
  2. package/dist/_chunks/{Analytics-DjXqUZy1.js → Analytics-ZpHHWBQt.js} +1 -1
  3. package/dist/_chunks/{App-D5x-l0Sz.mjs → App-CZNZ1JKf.mjs} +13 -7
  4. package/dist/_chunks/{App-BpwS5-wg.js → App-CsbyykNC.js} +13 -7
  5. package/dist/_chunks/{Customers-ChrS373z.js → Customers-D4RVSZ_m.js} +1 -1
  6. package/dist/_chunks/{Customers-BYQZcZeb.mjs → Customers-DMDEBpH9.mjs} +1 -1
  7. package/dist/_chunks/{Dashboard-DUWxJQ7q.mjs → Dashboard-D-ckyWDO.mjs} +1 -1
  8. package/dist/_chunks/{Dashboard-DANhyMZK.js → Dashboard-NNqGJmYw.js} +1 -1
  9. package/dist/_chunks/{Orders-BXyc3CTW.js → Orders-BELfgToU.js} +1 -1
  10. package/dist/_chunks/{Orders-B3GZULs3.mjs → Orders-BIkRttRZ.mjs} +1 -1
  11. package/dist/_chunks/{Payments-DmAzroEv.js → Payments-CIEb4f07.js} +1 -1
  12. package/dist/_chunks/{Payments-DL6hne_y.mjs → Payments-CKlL-PCV.mjs} +1 -1
  13. package/dist/_chunks/{Settings-Ck1G0iaS.mjs → Settings-BQXkYm-c.mjs} +1 -1
  14. package/dist/_chunks/{Settings-CMEzIMqt.js → Settings-CcY98Hyw.js} +1 -1
  15. package/dist/_chunks/Subscriptions--cI3HC2x.js +178 -0
  16. package/dist/_chunks/Subscriptions-Dq8Uk7sK.mjs +178 -0
  17. package/dist/_chunks/{index-Bo7VLX9i.mjs → index-BBarHYyt.mjs} +1 -1
  18. package/dist/_chunks/{index-Cmn7Tfmf.js → index-DBZ4rcUW.js} +1 -1
  19. package/dist/admin/index.js +1 -1
  20. package/dist/admin/index.mjs +1 -1
  21. package/dist/admin/src/index.d.ts +22 -1
  22. package/dist/admin/src/pages/Subscriptions.d.ts +2 -0
  23. package/dist/admin/src/types/index.d.ts +20 -0
  24. package/dist/server/index.js +618 -46
  25. package/dist/server/index.mjs +618 -46
  26. package/dist/server/src/content-types/customer/index.d.ts +6 -0
  27. package/dist/server/src/content-types/index.d.ts +89 -0
  28. package/dist/server/src/content-types/subscription/index.d.ts +84 -0
  29. package/dist/server/src/controllers/index.d.ts +7 -0
  30. package/dist/server/src/controllers/stripe.d.ts +34 -2
  31. package/dist/server/src/index.d.ts +99 -6
  32. package/dist/server/src/middlewares/index.d.ts +3 -3
  33. package/dist/server/src/services/stripe.d.ts +49 -10
  34. package/dist/server/src/services/types/api.d.ts +24 -5
  35. package/dist/server/src/types/plugin-config.d.ts +360 -0
  36. package/package.json +1 -1
@@ -63,6 +63,12 @@ declare const _default: {
63
63
  target: string;
64
64
  mappedBy: string;
65
65
  };
66
+ subscriptions: {
67
+ type: string;
68
+ relation: string;
69
+ target: string;
70
+ mappedBy: string;
71
+ };
66
72
  };
67
73
  };
68
74
  };
@@ -64,6 +64,12 @@ declare const _default: {
64
64
  target: string;
65
65
  mappedBy: string;
66
66
  };
67
+ subscriptions: {
68
+ type: string;
69
+ relation: string;
70
+ target: string;
71
+ mappedBy: string;
72
+ };
67
73
  };
68
74
  };
69
75
  };
@@ -211,5 +217,88 @@ declare const _default: {
211
217
  };
212
218
  };
213
219
  };
220
+ subscription: {
221
+ schema: {
222
+ kind: string;
223
+ collectionName: string;
224
+ info: {
225
+ singularName: string;
226
+ pluralName: string;
227
+ displayName: string;
228
+ description: string;
229
+ };
230
+ options: {
231
+ draftAndPublish: boolean;
232
+ };
233
+ attributes: {
234
+ stripe_subscription_id: {
235
+ type: string;
236
+ unique: boolean;
237
+ required: boolean;
238
+ configurable: boolean;
239
+ };
240
+ stripe_customer_id: {
241
+ type: string;
242
+ required: boolean;
243
+ configurable: boolean;
244
+ };
245
+ stripe_price_id: {
246
+ type: string;
247
+ required: boolean;
248
+ configurable: boolean;
249
+ };
250
+ stripe_product_id: {
251
+ type: string;
252
+ configurable: boolean;
253
+ };
254
+ status: {
255
+ type: string;
256
+ enum: string[];
257
+ required: boolean;
258
+ default: string;
259
+ configurable: boolean;
260
+ };
261
+ current_period_start: {
262
+ type: string;
263
+ configurable: boolean;
264
+ };
265
+ current_period_end: {
266
+ type: string;
267
+ configurable: boolean;
268
+ };
269
+ cancel_at_period_end: {
270
+ type: string;
271
+ default: boolean;
272
+ configurable: boolean;
273
+ };
274
+ canceled_at: {
275
+ type: string;
276
+ configurable: boolean;
277
+ };
278
+ trial_start: {
279
+ type: string;
280
+ configurable: boolean;
281
+ };
282
+ trial_end: {
283
+ type: string;
284
+ configurable: boolean;
285
+ };
286
+ latest_invoice_id: {
287
+ type: string;
288
+ configurable: boolean;
289
+ };
290
+ metadata: {
291
+ type: string;
292
+ configurable: boolean;
293
+ };
294
+ customer: {
295
+ type: string;
296
+ relation: string;
297
+ target: string;
298
+ inversedBy: string;
299
+ };
300
+ };
301
+ };
302
+ };
214
303
  };
215
304
  export default _default;
@@ -0,0 +1,84 @@
1
+ declare const _default: {
2
+ schema: {
3
+ kind: string;
4
+ collectionName: string;
5
+ info: {
6
+ singularName: string;
7
+ pluralName: string;
8
+ displayName: string;
9
+ description: string;
10
+ };
11
+ options: {
12
+ draftAndPublish: boolean;
13
+ };
14
+ attributes: {
15
+ stripe_subscription_id: {
16
+ type: string;
17
+ unique: boolean;
18
+ required: boolean;
19
+ configurable: boolean;
20
+ };
21
+ stripe_customer_id: {
22
+ type: string;
23
+ required: boolean;
24
+ configurable: boolean;
25
+ };
26
+ stripe_price_id: {
27
+ type: string;
28
+ required: boolean;
29
+ configurable: boolean;
30
+ };
31
+ stripe_product_id: {
32
+ type: string;
33
+ configurable: boolean;
34
+ };
35
+ status: {
36
+ type: string;
37
+ enum: string[];
38
+ required: boolean;
39
+ default: string;
40
+ configurable: boolean;
41
+ };
42
+ current_period_start: {
43
+ type: string;
44
+ configurable: boolean;
45
+ };
46
+ current_period_end: {
47
+ type: string;
48
+ configurable: boolean;
49
+ };
50
+ cancel_at_period_end: {
51
+ type: string;
52
+ default: boolean;
53
+ configurable: boolean;
54
+ };
55
+ canceled_at: {
56
+ type: string;
57
+ configurable: boolean;
58
+ };
59
+ trial_start: {
60
+ type: string;
61
+ configurable: boolean;
62
+ };
63
+ trial_end: {
64
+ type: string;
65
+ configurable: boolean;
66
+ };
67
+ latest_invoice_id: {
68
+ type: string;
69
+ configurable: boolean;
70
+ };
71
+ metadata: {
72
+ type: string;
73
+ configurable: boolean;
74
+ };
75
+ customer: {
76
+ type: string;
77
+ relation: string;
78
+ target: string;
79
+ inversedBy: string;
80
+ };
81
+ };
82
+ };
83
+ };
84
+ export default _default;
@@ -6,6 +6,13 @@ declare const _default: {
6
6
  index(ctx: any): void;
7
7
  };
8
8
  stripe: {
9
+ createSubscription(ctx: import("koa").Context): Promise<import("koa").Context>;
10
+ cancelSubscription(ctx: import("koa").Context): Promise<void>;
11
+ updateSubscription(ctx: import("koa").Context): Promise<void>;
12
+ getSubscriptionDetails(ctx: import("koa").Context): Promise<import("koa").Context>;
13
+ listSubscriptions(ctx: import("koa").Context): Promise<void>;
14
+ adminListSubscriptions(ctx: import("koa").Context): Promise<void>;
15
+ adminCancelSubscription(ctx: import("koa").Context): Promise<void>;
9
16
  createPaymentIntent(ctx: import("koa").Context): Promise<import("koa").Context>;
10
17
  confirmPayment(ctx: import("koa").Context): Promise<import("koa").Context>;
11
18
  createCustomer(ctx: import("koa").Context): Promise<import("koa").Context>;
@@ -1,5 +1,37 @@
1
1
  import type { Context } from 'koa';
2
- declare const stripeController: {
2
+ declare const stripeControllerFull: {
3
+ /**
4
+ * POST /subscriptions
5
+ * Body: { stripeCustomerId, priceId, trialPeriodDays?, metadata?, defaultPaymentMethod? }
6
+ */
7
+ createSubscription(ctx: Context): Promise<Context>;
8
+ /**
9
+ * POST /subscriptions/:id/cancel
10
+ * Body: { cancelAtPeriodEnd? }
11
+ */
12
+ cancelSubscription(ctx: Context): Promise<void>;
13
+ /**
14
+ * PUT /subscriptions/:id
15
+ * Body: { priceId?, cancelAtPeriodEnd?, trialEnd?, metadata?, defaultPaymentMethod? }
16
+ */
17
+ updateSubscription(ctx: Context): Promise<void>;
18
+ /**
19
+ * GET /subscriptions/:id
20
+ */
21
+ getSubscriptionDetails(ctx: Context): Promise<Context>;
22
+ /**
23
+ * GET /subscriptions
24
+ * Query: page, pageSize, status, stripeCustomerId
25
+ */
26
+ listSubscriptions(ctx: Context): Promise<void>;
27
+ /**
28
+ * GET /admin/subscriptions (admin only)
29
+ */
30
+ adminListSubscriptions(ctx: Context): Promise<void>;
31
+ /**
32
+ * POST /admin/subscriptions/:id/cancel (admin only)
33
+ */
34
+ adminCancelSubscription(ctx: Context): Promise<void>;
3
35
  /**
4
36
  * Create a payment intent
5
37
  */
@@ -101,4 +133,4 @@ declare const stripeController: {
101
133
  */
102
134
  createSamplePayment(ctx: Context): Promise<void>;
103
135
  };
104
- export default stripeController;
136
+ export default stripeControllerFull;
@@ -20,6 +20,13 @@ declare const _default: {
20
20
  index(ctx: any): void;
21
21
  };
22
22
  stripe: {
23
+ createSubscription(ctx: import("koa").Context): Promise<import("koa").Context>;
24
+ cancelSubscription(ctx: import("koa").Context): Promise<void>;
25
+ updateSubscription(ctx: import("koa").Context): Promise<void>;
26
+ getSubscriptionDetails(ctx: import("koa").Context): Promise<import("koa").Context>;
27
+ listSubscriptions(ctx: import("koa").Context): Promise<void>;
28
+ adminListSubscriptions(ctx: import("koa").Context): Promise<void>;
29
+ adminCancelSubscription(ctx: import("koa").Context): Promise<void>;
23
30
  createPaymentIntent(ctx: import("koa").Context): Promise<import("koa").Context>;
24
31
  confirmPayment(ctx: import("koa").Context): Promise<import("koa").Context>;
25
32
  createCustomer(ctx: import("koa").Context): Promise<import("koa").Context>;
@@ -155,6 +162,12 @@ declare const _default: {
155
162
  target: string;
156
163
  mappedBy: string;
157
164
  };
165
+ subscriptions: {
166
+ type: string;
167
+ relation: string;
168
+ target: string;
169
+ mappedBy: string;
170
+ };
158
171
  };
159
172
  };
160
173
  };
@@ -234,9 +247,6 @@ declare const _default: {
234
247
  };
235
248
  };
236
249
  };
237
- /**
238
- * Plugin server methods
239
- */
240
250
  payment: {
241
251
  schema: {
242
252
  kind: string;
@@ -305,14 +315,97 @@ declare const _default: {
305
315
  };
306
316
  };
307
317
  };
318
+ subscription: {
319
+ schema: {
320
+ kind: string;
321
+ collectionName: string;
322
+ info: {
323
+ singularName: string;
324
+ pluralName: string;
325
+ displayName: string;
326
+ description: string;
327
+ };
328
+ options: {
329
+ draftAndPublish: boolean;
330
+ };
331
+ attributes: {
332
+ stripe_subscription_id: {
333
+ type: string;
334
+ unique: boolean;
335
+ required: boolean;
336
+ configurable: boolean;
337
+ };
338
+ stripe_customer_id: {
339
+ type: string;
340
+ required: boolean;
341
+ configurable: boolean;
342
+ };
343
+ stripe_price_id: {
344
+ type: string;
345
+ required: boolean;
346
+ configurable: boolean;
347
+ };
348
+ stripe_product_id: {
349
+ type: string;
350
+ configurable: boolean;
351
+ };
352
+ status: {
353
+ type: string;
354
+ enum: string[];
355
+ required: boolean;
356
+ default: string;
357
+ configurable: boolean;
358
+ };
359
+ current_period_start: {
360
+ type: string;
361
+ configurable: boolean;
362
+ };
363
+ current_period_end: {
364
+ type: string;
365
+ configurable: boolean;
366
+ };
367
+ cancel_at_period_end: {
368
+ type: string;
369
+ default: boolean;
370
+ configurable: boolean;
371
+ };
372
+ canceled_at: {
373
+ type: string;
374
+ configurable: boolean;
375
+ };
376
+ trial_start: {
377
+ type: string;
378
+ configurable: boolean;
379
+ };
380
+ trial_end: {
381
+ type: string;
382
+ configurable: boolean;
383
+ };
384
+ latest_invoice_id: {
385
+ type: string;
386
+ configurable: boolean;
387
+ };
388
+ metadata: {
389
+ type: string;
390
+ configurable: boolean;
391
+ };
392
+ customer: {
393
+ type: string;
394
+ relation: string;
395
+ target: string;
396
+ inversedBy: string;
397
+ };
398
+ };
399
+ };
400
+ };
308
401
  };
309
402
  policies: {
310
403
  isAuthenticated: (ctx: any) => boolean;
311
404
  };
312
405
  middlewares: {
313
- 'webhook-validator': (ctx: import("koa").Context, next: () => Promise<any>) => Promise<import("koa").Context>;
314
- rateLimiter: (ctx: import("koa").Context, next: () => Promise<any>) => Promise<any>;
315
- inputSanitizer: (ctx: import("koa").Context, next: () => Promise<any>) => Promise<void>;
406
+ 'webhook-validator': (ctx: import("koa").Context, next: () => Promise<void>) => Promise<import("koa").Context>;
407
+ rateLimiter: (ctx: import("koa").Context, next: () => Promise<void>) => Promise<any>;
408
+ inputSanitizer: (ctx: import("koa").Context, next: () => Promise<void>) => Promise<void>;
316
409
  };
317
410
  };
318
411
  export default _default;
@@ -7,14 +7,14 @@ declare const _default: {
7
7
  /**
8
8
  * Webhook signature validator
9
9
  */
10
- 'webhook-validator': (ctx: Context, next: () => Promise<any>) => Promise<Context>;
10
+ 'webhook-validator': (ctx: Context, next: () => Promise<void>) => Promise<Context>;
11
11
  /**
12
12
  * Rate limiter middleware for sensitive operations
13
13
  */
14
- rateLimiter: (ctx: Context, next: () => Promise<any>) => Promise<any>;
14
+ rateLimiter: (ctx: Context, next: () => Promise<void>) => Promise<any>;
15
15
  /**
16
16
  * Input sanitization middleware
17
17
  */
18
- inputSanitizer: (ctx: Context, next: () => Promise<any>) => Promise<void>;
18
+ inputSanitizer: (ctx: Context, next: () => Promise<void>) => Promise<void>;
19
19
  };
20
20
  export default _default;
@@ -311,10 +311,12 @@
311
311
  /// <reference types="stripe/types/net/net" />
312
312
  import Stripe from 'stripe';
313
313
  import type { Core } from '@strapi/strapi';
314
+ import type { OrderInput, CustomerInput, SubscriptionInput } from './types';
315
+ import { type StripeAddress, type OrderItem } from '../types/plugin-config';
314
316
  interface PaymentIntentParams {
315
317
  amount: number;
316
318
  currency: string;
317
- metadata?: Record<string, any>;
319
+ metadata?: Record<string, string>;
318
320
  customer?: string;
319
321
  orderId?: string;
320
322
  customerId?: string;
@@ -326,15 +328,46 @@ interface CreateCustomerParams {
326
328
  firstName: string;
327
329
  lastName: string;
328
330
  phone?: string;
329
- address?: Record<string, any>;
330
- metadata?: Record<string, any>;
331
+ address?: StripeAddress;
332
+ metadata?: Record<string, string>;
331
333
  strapiCustomerId?: string;
332
334
  }
333
335
  interface RefundParams {
334
336
  paymentIntentId: string;
335
337
  amount?: number;
336
338
  reason?: Stripe.RefundCreateParams.Reason;
337
- metadata?: Record<string, any>;
339
+ metadata?: Record<string, string>;
340
+ }
341
+ interface InitializePaymentFlowParams {
342
+ amount: number;
343
+ currency: string;
344
+ email: string;
345
+ firstName: string;
346
+ lastName: string;
347
+ items?: OrderItem[];
348
+ metadata?: Record<string, string>;
349
+ confirm?: boolean;
350
+ payment_method?: string;
351
+ orderNumber?: string;
352
+ }
353
+ type CreateOrderData = Omit<OrderInput, 'order_status' | 'payment_status'> & {
354
+ order_status?: OrderInput['order_status'];
355
+ payment_status?: OrderInput['payment_status'];
356
+ };
357
+ export interface CreateSubscriptionParams {
358
+ strapiCustomerId: string;
359
+ stripeCustomerId: string;
360
+ priceId: string;
361
+ trialPeriodDays?: number;
362
+ metadata?: Record<string, string>;
363
+ defaultPaymentMethod?: string;
364
+ }
365
+ export interface UpdateSubscriptionParams {
366
+ priceId?: string;
367
+ cancelAtPeriodEnd?: boolean;
368
+ trialEnd?: number | 'now';
369
+ metadata?: Record<string, string>;
370
+ defaultPaymentMethod?: string;
338
371
  }
339
372
  export interface StripeService {
340
373
  initializeStripe(): Promise<Stripe>;
@@ -345,13 +378,19 @@ export interface StripeService {
345
378
  createRefund(params: RefundParams): Promise<Stripe.Refund>;
346
379
  handleWebhook(event: Stripe.Event): Promise<void>;
347
380
  constructEvent(payload: string | Buffer, signature: string): Promise<Stripe.Event>;
348
- updateStrapiOrder(orderId: string, data: any): Promise<void>;
349
- updateStrapiCustomer(customerId: string, data: any): Promise<void>;
350
- createStrapiPaymentRecord(paymentIntent: Stripe.PaymentIntent): Promise<any>;
351
- createCustomerRecord(data: any): Promise<any>;
352
- createOrderRecord(data: any): Promise<any>;
353
- initializePaymentFlow(params: any): Promise<any>;
381
+ updateStrapiOrder(orderId: string, data: Partial<OrderInput>): Promise<void>;
382
+ updateStrapiCustomer(customerId: string, data: Partial<CustomerInput>): Promise<void>;
383
+ createStrapiPaymentRecord(paymentIntent: Stripe.PaymentIntent): Promise<unknown>;
384
+ createCustomerRecord(data: CustomerInput): Promise<unknown>;
385
+ createOrderRecord(data: CreateOrderData): Promise<unknown>;
386
+ initializePaymentFlow(params: InitializePaymentFlowParams): Promise<unknown>;
354
387
  getStripe(): Stripe | null;
388
+ createSubscription(params: CreateSubscriptionParams): Promise<Stripe.Subscription>;
389
+ cancelSubscription(stripeSubscriptionId: string, cancelAtPeriodEnd?: boolean): Promise<Stripe.Subscription>;
390
+ updateSubscription(stripeSubscriptionId: string, params: UpdateSubscriptionParams): Promise<Stripe.Subscription>;
391
+ retrieveSubscription(stripeSubscriptionId: string): Promise<Stripe.Subscription>;
392
+ createStrapiSubscriptionRecord(subscription: Stripe.Subscription, strapiCustomerId?: string): Promise<unknown>;
393
+ updateStrapiSubscription(stripeSubscriptionId: string, data: Partial<SubscriptionInput>): Promise<void>;
355
394
  }
356
395
  declare const stripeService: ({ strapi }: {
357
396
  strapi: Core.Strapi;
@@ -1,12 +1,15 @@
1
+ import type { StripeAddress, OrderItem } from '../../types/plugin-config';
1
2
  export type PaymentStatus = 'pending' | 'succeeded' | 'failed' | 'canceled' | 'refunded';
2
3
  export type OrderStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'refunded';
4
+ export type SubscriptionStatus = 'active' | 'canceled' | 'incomplete' | 'incomplete_expired' | 'past_due' | 'paused' | 'trialing' | 'unpaid';
5
+ export type StripeMetadata = Record<string, string>;
3
6
  export interface PaymentInput {
4
7
  stripe_payment_intent_id: string;
5
8
  amount: number;
6
9
  currency: string;
7
10
  payment_status: PaymentStatus;
8
11
  payment_method?: string;
9
- metadata?: Record<string, any>;
12
+ metadata?: StripeMetadata;
10
13
  customer?: string;
11
14
  order?: string;
12
15
  }
@@ -17,8 +20,8 @@ export interface OrderInput {
17
20
  order_status: OrderStatus;
18
21
  payment_status: 'unpaid' | 'paid' | 'partially_paid' | 'refunded';
19
22
  customer?: string;
20
- items: Record<string, any>;
21
- metadata?: Record<string, any>;
23
+ items: OrderItem[];
24
+ metadata?: StripeMetadata;
22
25
  }
23
26
  export interface CustomerInput {
24
27
  email: string;
@@ -26,6 +29,22 @@ export interface CustomerInput {
26
29
  first_name: string;
27
30
  last_name: string;
28
31
  phone?: string;
29
- address?: Record<string, any>;
30
- metadata?: Record<string, any>;
32
+ address?: StripeAddress;
33
+ metadata?: StripeMetadata;
34
+ }
35
+ export interface SubscriptionInput {
36
+ stripe_subscription_id: string;
37
+ stripe_customer_id: string;
38
+ stripe_price_id: string;
39
+ stripe_product_id?: string;
40
+ status: SubscriptionStatus;
41
+ current_period_start?: string;
42
+ current_period_end?: string;
43
+ cancel_at_period_end?: boolean;
44
+ canceled_at?: string | null;
45
+ trial_start?: string | null;
46
+ trial_end?: string | null;
47
+ latest_invoice_id?: string;
48
+ metadata?: StripeMetadata;
49
+ customer?: string;
31
50
  }