@reeboot/strapi-payment-plugin 0.0.9 → 0.0.11
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/_chunks/{Analytics-kChERzX4.mjs → Analytics-CPXtqS6s.mjs} +1 -1
- package/dist/_chunks/{Analytics-DjXqUZy1.js → Analytics-ZpHHWBQt.js} +1 -1
- package/dist/_chunks/{App-D5x-l0Sz.mjs → App-CZNZ1JKf.mjs} +13 -7
- package/dist/_chunks/{App-BpwS5-wg.js → App-CsbyykNC.js} +13 -7
- package/dist/_chunks/{Customers-ChrS373z.js → Customers-D4RVSZ_m.js} +1 -1
- package/dist/_chunks/{Customers-BYQZcZeb.mjs → Customers-DMDEBpH9.mjs} +1 -1
- package/dist/_chunks/{Dashboard-DUWxJQ7q.mjs → Dashboard-D-ckyWDO.mjs} +1 -1
- package/dist/_chunks/{Dashboard-DANhyMZK.js → Dashboard-NNqGJmYw.js} +1 -1
- package/dist/_chunks/{Orders-BXyc3CTW.js → Orders-BELfgToU.js} +1 -1
- package/dist/_chunks/{Orders-B3GZULs3.mjs → Orders-BIkRttRZ.mjs} +1 -1
- package/dist/_chunks/{Payments-DmAzroEv.js → Payments-CIEb4f07.js} +1 -1
- package/dist/_chunks/{Payments-DL6hne_y.mjs → Payments-CKlL-PCV.mjs} +1 -1
- package/dist/_chunks/{Settings-Ck1G0iaS.mjs → Settings-BQXkYm-c.mjs} +1 -1
- package/dist/_chunks/{Settings-CMEzIMqt.js → Settings-CcY98Hyw.js} +1 -1
- package/dist/_chunks/Subscriptions--cI3HC2x.js +178 -0
- package/dist/_chunks/Subscriptions-Dq8Uk7sK.mjs +178 -0
- package/dist/_chunks/{index-Bo7VLX9i.mjs → index-BBarHYyt.mjs} +1 -1
- package/dist/_chunks/{index-Cmn7Tfmf.js → index-DBZ4rcUW.js} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/index.d.ts +22 -1
- package/dist/admin/src/pages/Subscriptions.d.ts +2 -0
- package/dist/admin/src/types/index.d.ts +20 -0
- package/dist/server/index.js +622 -46
- package/dist/server/index.mjs +622 -46
- package/dist/server/src/__tests__/setup.d.ts +316 -0
- package/dist/server/src/content-types/customer/index.d.ts +6 -0
- package/dist/server/src/content-types/index.d.ts +89 -0
- package/dist/server/src/content-types/subscription/index.d.ts +84 -0
- package/dist/server/src/controllers/index.d.ts +7 -0
- package/dist/server/src/controllers/stripe.d.ts +34 -2
- package/dist/server/src/index.d.ts +99 -6
- package/dist/server/src/middlewares/index.d.ts +3 -3
- package/dist/server/src/services/stripe.d.ts +50 -10
- package/dist/server/src/services/types/api.d.ts +24 -5
- package/dist/server/src/types/plugin-config.d.ts +360 -0
- package/package.json +6 -3
|
@@ -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<
|
|
314
|
-
rateLimiter: (ctx: import("koa").Context, next: () => Promise<
|
|
315
|
-
inputSanitizer: (ctx: import("koa").Context, next: () => Promise<
|
|
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<
|
|
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<
|
|
14
|
+
rateLimiter: (ctx: Context, next: () => Promise<void>) => Promise<any>;
|
|
15
15
|
/**
|
|
16
16
|
* Input sanitization middleware
|
|
17
17
|
*/
|
|
18
|
-
inputSanitizer: (ctx: Context, next: () => Promise<
|
|
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,
|
|
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?:
|
|
330
|
-
metadata?: Record<string,
|
|
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,
|
|
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,20 @@ 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:
|
|
349
|
-
updateStrapiCustomer(customerId: string, data:
|
|
350
|
-
createStrapiPaymentRecord(paymentIntent: Stripe.PaymentIntent): Promise<
|
|
351
|
-
createCustomerRecord(data:
|
|
352
|
-
createOrderRecord(data:
|
|
353
|
-
initializePaymentFlow(params:
|
|
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
|
+
setStripe(instance: Stripe): void;
|
|
389
|
+
createSubscription(params: CreateSubscriptionParams): Promise<Stripe.Subscription>;
|
|
390
|
+
cancelSubscription(stripeSubscriptionId: string, cancelAtPeriodEnd?: boolean): Promise<Stripe.Subscription>;
|
|
391
|
+
updateSubscription(stripeSubscriptionId: string, params: UpdateSubscriptionParams): Promise<Stripe.Subscription>;
|
|
392
|
+
retrieveSubscription(stripeSubscriptionId: string): Promise<Stripe.Subscription>;
|
|
393
|
+
createStrapiSubscriptionRecord(subscription: Stripe.Subscription, strapiCustomerId?: string): Promise<unknown>;
|
|
394
|
+
updateStrapiSubscription(stripeSubscriptionId: string, data: Partial<SubscriptionInput>): Promise<void>;
|
|
355
395
|
}
|
|
356
396
|
declare const stripeService: ({ strapi }: {
|
|
357
397
|
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?:
|
|
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:
|
|
21
|
-
metadata?:
|
|
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?:
|
|
30
|
-
metadata?:
|
|
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
|
}
|