@dineway-ai/plugin-payment 0.2.5 → 0.2.7
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/package.json +3 -2
- package/src/admin/subscription-price-picker.tsx +264 -0
- package/src/admin/subscriptions.tsx +184 -59
- package/src/configuration/repository.ts +7 -3
- package/src/database/index.ts +12 -0
- package/src/database/migrations/001_stripe_configuration.ts +100 -0
- package/src/database/migrations/002_subscriptions.ts +168 -0
- package/src/database/migrations/003_purchases.ts +193 -0
- package/src/database/migrations/adoption.ts +27 -0
- package/src/database/types.ts +137 -0
- package/src/index.ts +2 -0
- package/src/subscriptions/funding.ts +256 -0
- package/src/subscriptions/index.ts +1 -0
- package/src/subscriptions/projection.ts +44 -8
- package/src/subscriptions/purchases.ts +329 -0
- package/src/subscriptions/refunds.ts +134 -0
- package/src/subscriptions/repository.ts +352 -13
- package/src/subscriptions/routes.ts +20 -0
- package/src/subscriptions/schemas.ts +70 -0
- package/src/subscriptions/service.ts +540 -202
- package/src/subscriptions/types.ts +105 -0
- package/src/types.ts +1 -0
|
@@ -90,6 +90,51 @@ export const checkoutSchema = z
|
|
|
90
90
|
})
|
|
91
91
|
.strict();
|
|
92
92
|
export const portalSchema = checkoutSchema.pick({ locale: true, returnPath: true });
|
|
93
|
+
export const billingSubjectSchema = z
|
|
94
|
+
.object({
|
|
95
|
+
realm: subscriptionCode.refine((value) => value !== "dineway", "The Dineway realm is reserved"),
|
|
96
|
+
id: z
|
|
97
|
+
.string()
|
|
98
|
+
.min(1)
|
|
99
|
+
.max(128)
|
|
100
|
+
.regex(/^[A-Za-z0-9_.:-]+$/),
|
|
101
|
+
email: z.string().trim().email().max(320),
|
|
102
|
+
emailVerified: z.literal(true),
|
|
103
|
+
})
|
|
104
|
+
.strict();
|
|
105
|
+
const purchaseKey = z
|
|
106
|
+
.string()
|
|
107
|
+
.min(1)
|
|
108
|
+
.max(160)
|
|
109
|
+
.regex(/^[A-Za-z0-9_.:-]+$/);
|
|
110
|
+
export const purchaseSchema = z
|
|
111
|
+
.object({
|
|
112
|
+
reference: purchaseKey,
|
|
113
|
+
groupKey: purchaseKey,
|
|
114
|
+
pricing: z.discriminatedUnion("kind", [
|
|
115
|
+
z
|
|
116
|
+
.object({
|
|
117
|
+
kind: z.literal("catalogue"),
|
|
118
|
+
planCode: subscriptionCode,
|
|
119
|
+
interval: z.enum(["month", "year"]),
|
|
120
|
+
})
|
|
121
|
+
.strict(),
|
|
122
|
+
z
|
|
123
|
+
.object({
|
|
124
|
+
kind: z.literal("dynamic"),
|
|
125
|
+
name: z.string().trim().min(1).max(160),
|
|
126
|
+
amount: z.number().int().min(1).max(99999999),
|
|
127
|
+
currency: z.string().regex(/^[a-z]{3}$/),
|
|
128
|
+
interval: z.enum(["day", "week", "month", "year"]),
|
|
129
|
+
intervalCount: z.number().int().min(1).max(365),
|
|
130
|
+
})
|
|
131
|
+
.strict(),
|
|
132
|
+
]),
|
|
133
|
+
firstPeriodCredit: z.number().int().min(0).max(99999999).default(0),
|
|
134
|
+
returnPath: subscriptionReturnPath,
|
|
135
|
+
locale: subscriptionLocale.default("auto"),
|
|
136
|
+
})
|
|
137
|
+
.strict();
|
|
93
138
|
export const memberListSchema = z
|
|
94
139
|
.object({
|
|
95
140
|
cursor: z.string().max(255).optional(),
|
|
@@ -99,3 +144,28 @@ export const memberListSchema = z
|
|
|
99
144
|
export const subscriptionIdSchema = z
|
|
100
145
|
.object({ subscriptionId: z.string().regex(/^sub_[A-Za-z0-9]+$/) })
|
|
101
146
|
.strict();
|
|
147
|
+
|
|
148
|
+
export const stripeProductListSchema = z
|
|
149
|
+
.object({
|
|
150
|
+
cursor: z
|
|
151
|
+
.string()
|
|
152
|
+
.regex(/^prod_[A-Za-z0-9]+$/)
|
|
153
|
+
.max(255)
|
|
154
|
+
.optional(),
|
|
155
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
156
|
+
})
|
|
157
|
+
.strict();
|
|
158
|
+
export const stripePriceListSchema = z
|
|
159
|
+
.object({
|
|
160
|
+
productId: z
|
|
161
|
+
.string()
|
|
162
|
+
.regex(/^prod_[A-Za-z0-9]+$/)
|
|
163
|
+
.max(255),
|
|
164
|
+
cursor: z
|
|
165
|
+
.string()
|
|
166
|
+
.regex(/^price_[A-Za-z0-9]+$/)
|
|
167
|
+
.max(255)
|
|
168
|
+
.optional(),
|
|
169
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
170
|
+
})
|
|
171
|
+
.strict();
|