@forklaunch/implementation-billing-stripe 0.0.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.
- package/LICENSE +21 -0
- package/lib/domain/index.d.mts +189 -0
- package/lib/domain/index.d.ts +189 -0
- package/lib/domain/index.js +231 -0
- package/lib/domain/index.mjs +201 -0
- package/lib/eject/domain/schemas/billingPortal.schema.ts +37 -0
- package/lib/eject/domain/schemas/checkoutSession.schema.ts +74 -0
- package/lib/eject/domain/schemas/index.ts +5 -0
- package/lib/eject/domain/schemas/paymentLink.schema.ts +62 -0
- package/lib/eject/domain/schemas/plan.schema.ts +68 -0
- package/lib/eject/domain/schemas/subscription.schema.ts +78 -0
- package/lib/eject/services/billingPortal.service.ts +185 -0
- package/lib/eject/services/checkoutSession.service.ts +179 -0
- package/lib/eject/services/index.ts +6 -0
- package/lib/eject/services/paymentLink.service.ts +239 -0
- package/lib/eject/services/plan.service.ts +219 -0
- package/lib/eject/services/subscription.service.ts +285 -0
- package/lib/eject/services/webhook.service.ts +272 -0
- package/lib/eject/types/index.ts +2 -0
- package/lib/eject/types/stripe.dto.types.ts +214 -0
- package/lib/eject/types/stripe.entity.types.ts +83 -0
- package/lib/schemas/index.d.mts +376 -0
- package/lib/schemas/index.d.ts +376 -0
- package/lib/schemas/index.js +704 -0
- package/lib/schemas/index.mjs +737 -0
- package/lib/services/index.d.mts +223 -0
- package/lib/services/index.d.ts +223 -0
- package/lib/services/index.js +788 -0
- package/lib/services/index.mjs +776 -0
- package/lib/types/index.d.mts +121 -0
- package/lib/types/index.d.ts +121 -0
- package/lib/types/index.js +18 -0
- package/lib/types/index.mjs +0 -0
- package/package.json +74 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// domain/enums/billingProvider.enum.ts
|
|
2
|
+
var BillingProviderEnum = /* @__PURE__ */ ((BillingProviderEnum2) => {
|
|
3
|
+
BillingProviderEnum2["STRIPE"] = "stripe";
|
|
4
|
+
return BillingProviderEnum2;
|
|
5
|
+
})(BillingProviderEnum || {});
|
|
6
|
+
|
|
7
|
+
// domain/enums/currency.enum.ts
|
|
8
|
+
var CurrencyEnum = /* @__PURE__ */ ((CurrencyEnum2) => {
|
|
9
|
+
CurrencyEnum2["USD"] = "USD";
|
|
10
|
+
CurrencyEnum2["AED"] = "AED";
|
|
11
|
+
CurrencyEnum2["AFN"] = "AFN";
|
|
12
|
+
CurrencyEnum2["ALL"] = "ALL";
|
|
13
|
+
CurrencyEnum2["AMD"] = "AMD";
|
|
14
|
+
CurrencyEnum2["ANG"] = "ANG";
|
|
15
|
+
CurrencyEnum2["AOA"] = "AOA";
|
|
16
|
+
CurrencyEnum2["ARS"] = "ARS";
|
|
17
|
+
CurrencyEnum2["AUD"] = "AUD";
|
|
18
|
+
CurrencyEnum2["AWG"] = "AWG";
|
|
19
|
+
CurrencyEnum2["AZN"] = "AZN";
|
|
20
|
+
CurrencyEnum2["BAM"] = "BAM";
|
|
21
|
+
CurrencyEnum2["BBD"] = "BBD";
|
|
22
|
+
CurrencyEnum2["BDT"] = "BDT";
|
|
23
|
+
CurrencyEnum2["BGN"] = "BGN";
|
|
24
|
+
CurrencyEnum2["BIF"] = "BIF";
|
|
25
|
+
CurrencyEnum2["BMD"] = "BMD";
|
|
26
|
+
CurrencyEnum2["BND"] = "BND";
|
|
27
|
+
CurrencyEnum2["BOB"] = "BOB";
|
|
28
|
+
CurrencyEnum2["BRL"] = "BRL";
|
|
29
|
+
CurrencyEnum2["BSD"] = "BSD";
|
|
30
|
+
CurrencyEnum2["BWP"] = "BWP";
|
|
31
|
+
CurrencyEnum2["BYN"] = "BYN";
|
|
32
|
+
CurrencyEnum2["BZD"] = "BZD";
|
|
33
|
+
CurrencyEnum2["CAD"] = "CAD";
|
|
34
|
+
CurrencyEnum2["CDF"] = "CDF";
|
|
35
|
+
CurrencyEnum2["CHF"] = "CHF";
|
|
36
|
+
CurrencyEnum2["CLP"] = "CLP";
|
|
37
|
+
CurrencyEnum2["CNY"] = "CNY";
|
|
38
|
+
CurrencyEnum2["COP"] = "COP";
|
|
39
|
+
CurrencyEnum2["CRC"] = "CRC";
|
|
40
|
+
CurrencyEnum2["CVE"] = "CVE";
|
|
41
|
+
CurrencyEnum2["CZK"] = "CZK";
|
|
42
|
+
CurrencyEnum2["DJF"] = "DJF";
|
|
43
|
+
CurrencyEnum2["DKK"] = "DKK";
|
|
44
|
+
CurrencyEnum2["DOP"] = "DOP";
|
|
45
|
+
CurrencyEnum2["DZD"] = "DZD";
|
|
46
|
+
CurrencyEnum2["EGP"] = "EGP";
|
|
47
|
+
CurrencyEnum2["ETB"] = "ETB";
|
|
48
|
+
CurrencyEnum2["EUR"] = "EUR";
|
|
49
|
+
CurrencyEnum2["FJD"] = "FJD";
|
|
50
|
+
CurrencyEnum2["FKP"] = "FKP";
|
|
51
|
+
CurrencyEnum2["GBP"] = "GBP";
|
|
52
|
+
CurrencyEnum2["GEL"] = "GEL";
|
|
53
|
+
CurrencyEnum2["GIP"] = "GIP";
|
|
54
|
+
CurrencyEnum2["GMD"] = "GMD";
|
|
55
|
+
CurrencyEnum2["GNF"] = "GNF";
|
|
56
|
+
CurrencyEnum2["GTQ"] = "GTQ";
|
|
57
|
+
CurrencyEnum2["GYD"] = "GYD";
|
|
58
|
+
CurrencyEnum2["HKD"] = "HKD";
|
|
59
|
+
CurrencyEnum2["HNL"] = "HNL";
|
|
60
|
+
CurrencyEnum2["HTG"] = "HTG";
|
|
61
|
+
CurrencyEnum2["HUF"] = "HUF";
|
|
62
|
+
CurrencyEnum2["IDR"] = "IDR";
|
|
63
|
+
CurrencyEnum2["ILS"] = "ILS";
|
|
64
|
+
CurrencyEnum2["INR"] = "INR";
|
|
65
|
+
CurrencyEnum2["ISK"] = "ISK";
|
|
66
|
+
CurrencyEnum2["JMD"] = "JMD";
|
|
67
|
+
CurrencyEnum2["JPY"] = "JPY";
|
|
68
|
+
CurrencyEnum2["KES"] = "KES";
|
|
69
|
+
CurrencyEnum2["KGS"] = "KGS";
|
|
70
|
+
CurrencyEnum2["KHR"] = "KHR";
|
|
71
|
+
CurrencyEnum2["KMF"] = "KMF";
|
|
72
|
+
CurrencyEnum2["KRW"] = "KRW";
|
|
73
|
+
CurrencyEnum2["KYD"] = "KYD";
|
|
74
|
+
CurrencyEnum2["KZT"] = "KZT";
|
|
75
|
+
CurrencyEnum2["LAK"] = "LAK";
|
|
76
|
+
CurrencyEnum2["LBP"] = "LBP";
|
|
77
|
+
CurrencyEnum2["LKR"] = "LKR";
|
|
78
|
+
CurrencyEnum2["LRD"] = "LRD";
|
|
79
|
+
CurrencyEnum2["LSL"] = "LSL";
|
|
80
|
+
CurrencyEnum2["MAD"] = "MAD";
|
|
81
|
+
CurrencyEnum2["MDL"] = "MDL";
|
|
82
|
+
CurrencyEnum2["MGA"] = "MGA";
|
|
83
|
+
CurrencyEnum2["MKD"] = "MKD";
|
|
84
|
+
CurrencyEnum2["MMK"] = "MMK";
|
|
85
|
+
CurrencyEnum2["MNT"] = "MNT";
|
|
86
|
+
CurrencyEnum2["MOP"] = "MOP";
|
|
87
|
+
CurrencyEnum2["MUR"] = "MUR";
|
|
88
|
+
CurrencyEnum2["MVR"] = "MVR";
|
|
89
|
+
CurrencyEnum2["MWK"] = "MWK";
|
|
90
|
+
CurrencyEnum2["MXN"] = "MXN";
|
|
91
|
+
CurrencyEnum2["MYR"] = "MYR";
|
|
92
|
+
CurrencyEnum2["MZN"] = "MZN";
|
|
93
|
+
CurrencyEnum2["NAD"] = "NAD";
|
|
94
|
+
CurrencyEnum2["NGN"] = "NGN";
|
|
95
|
+
CurrencyEnum2["NIO"] = "NIO";
|
|
96
|
+
CurrencyEnum2["NOK"] = "NOK";
|
|
97
|
+
CurrencyEnum2["NPR"] = "NPR";
|
|
98
|
+
CurrencyEnum2["NZD"] = "NZD";
|
|
99
|
+
CurrencyEnum2["PAB"] = "PAB";
|
|
100
|
+
CurrencyEnum2["PEN"] = "PEN";
|
|
101
|
+
CurrencyEnum2["PGK"] = "PGK";
|
|
102
|
+
CurrencyEnum2["PHP"] = "PHP";
|
|
103
|
+
CurrencyEnum2["PKR"] = "PKR";
|
|
104
|
+
CurrencyEnum2["PLN"] = "PLN";
|
|
105
|
+
CurrencyEnum2["PYG"] = "PYG";
|
|
106
|
+
CurrencyEnum2["QAR"] = "QAR";
|
|
107
|
+
CurrencyEnum2["RON"] = "RON";
|
|
108
|
+
CurrencyEnum2["RSD"] = "RSD";
|
|
109
|
+
CurrencyEnum2["RUB"] = "RUB";
|
|
110
|
+
CurrencyEnum2["RWF"] = "RWF";
|
|
111
|
+
CurrencyEnum2["SAR"] = "SAR";
|
|
112
|
+
CurrencyEnum2["SBD"] = "SBD";
|
|
113
|
+
CurrencyEnum2["SCR"] = "SCR";
|
|
114
|
+
CurrencyEnum2["SEK"] = "SEK";
|
|
115
|
+
CurrencyEnum2["SGD"] = "SGD";
|
|
116
|
+
CurrencyEnum2["SHP"] = "SHP";
|
|
117
|
+
CurrencyEnum2["SLE"] = "SLE";
|
|
118
|
+
CurrencyEnum2["SOS"] = "SOS";
|
|
119
|
+
CurrencyEnum2["SRD"] = "SRD";
|
|
120
|
+
CurrencyEnum2["STD"] = "STD";
|
|
121
|
+
CurrencyEnum2["SZL"] = "SZL";
|
|
122
|
+
CurrencyEnum2["THB"] = "THB";
|
|
123
|
+
CurrencyEnum2["TJS"] = "TJS";
|
|
124
|
+
CurrencyEnum2["TOP"] = "TOP";
|
|
125
|
+
CurrencyEnum2["TRY"] = "TRY";
|
|
126
|
+
CurrencyEnum2["TTD"] = "TTD";
|
|
127
|
+
CurrencyEnum2["TWD"] = "TWD";
|
|
128
|
+
CurrencyEnum2["TZS"] = "TZS";
|
|
129
|
+
CurrencyEnum2["UAH"] = "UAH";
|
|
130
|
+
CurrencyEnum2["UGX"] = "UGX";
|
|
131
|
+
CurrencyEnum2["UYU"] = "UYU";
|
|
132
|
+
CurrencyEnum2["UZS"] = "UZS";
|
|
133
|
+
CurrencyEnum2["VND"] = "VND";
|
|
134
|
+
CurrencyEnum2["VUV"] = "VUV";
|
|
135
|
+
CurrencyEnum2["WST"] = "WST";
|
|
136
|
+
CurrencyEnum2["XAF"] = "XAF";
|
|
137
|
+
CurrencyEnum2["XCD"] = "XCD";
|
|
138
|
+
CurrencyEnum2["XCG"] = "XCG";
|
|
139
|
+
CurrencyEnum2["XOF"] = "XOF";
|
|
140
|
+
CurrencyEnum2["XPF"] = "XPF";
|
|
141
|
+
CurrencyEnum2["YER"] = "YER";
|
|
142
|
+
CurrencyEnum2["ZAR"] = "ZAR";
|
|
143
|
+
CurrencyEnum2["ZMW"] = "ZMW";
|
|
144
|
+
return CurrencyEnum2;
|
|
145
|
+
})(CurrencyEnum || {});
|
|
146
|
+
|
|
147
|
+
// domain/enums/paymentMethod.enum.ts
|
|
148
|
+
var PaymentMethodEnum = /* @__PURE__ */ ((PaymentMethodEnum2) => {
|
|
149
|
+
PaymentMethodEnum2["AFFIRM"] = "affirm";
|
|
150
|
+
PaymentMethodEnum2["AFTERPAY_CLEARPAY"] = "afterpay_clearpay";
|
|
151
|
+
PaymentMethodEnum2["ALIPAY"] = "alipay";
|
|
152
|
+
PaymentMethodEnum2["ALMA"] = "alma";
|
|
153
|
+
PaymentMethodEnum2["AU_BECS_DEBIT"] = "au_becs_debit";
|
|
154
|
+
PaymentMethodEnum2["BACS_DEBIT"] = "bacs_debit";
|
|
155
|
+
PaymentMethodEnum2["BANCONTACT"] = "bancontact";
|
|
156
|
+
PaymentMethodEnum2["BILLIE"] = "billie";
|
|
157
|
+
PaymentMethodEnum2["BLIK"] = "blik";
|
|
158
|
+
PaymentMethodEnum2["BOLETO"] = "boleto";
|
|
159
|
+
PaymentMethodEnum2["CARD"] = "card";
|
|
160
|
+
PaymentMethodEnum2["CASHAPP"] = "cashapp";
|
|
161
|
+
PaymentMethodEnum2["EPS"] = "eps";
|
|
162
|
+
PaymentMethodEnum2["FPX"] = "fpx";
|
|
163
|
+
PaymentMethodEnum2["GIROPAY"] = "giropay";
|
|
164
|
+
PaymentMethodEnum2["GRABPAY"] = "grabpay";
|
|
165
|
+
PaymentMethodEnum2["IDEAL"] = "ideal";
|
|
166
|
+
PaymentMethodEnum2["KLARNA"] = "klarna";
|
|
167
|
+
PaymentMethodEnum2["KONBINI"] = "konbini";
|
|
168
|
+
PaymentMethodEnum2["LINK"] = "link";
|
|
169
|
+
PaymentMethodEnum2["MOBILEPAY"] = "mobilepay";
|
|
170
|
+
PaymentMethodEnum2["MULTIBANCO"] = "multibanco";
|
|
171
|
+
PaymentMethodEnum2["OXXO"] = "oxxo";
|
|
172
|
+
PaymentMethodEnum2["P24"] = "p24";
|
|
173
|
+
PaymentMethodEnum2["PAY_BY_BANK"] = "pay_by_bank";
|
|
174
|
+
PaymentMethodEnum2["PAYNOW"] = "paynow";
|
|
175
|
+
PaymentMethodEnum2["PAYPAL"] = "paypal";
|
|
176
|
+
PaymentMethodEnum2["PIX"] = "pix";
|
|
177
|
+
PaymentMethodEnum2["PROMPTPAY"] = "promptpay";
|
|
178
|
+
PaymentMethodEnum2["SATISPAY"] = "satispay";
|
|
179
|
+
PaymentMethodEnum2["SEPA_DEBIT"] = "sepa_debit";
|
|
180
|
+
PaymentMethodEnum2["SOFORT"] = "sofort";
|
|
181
|
+
PaymentMethodEnum2["SWISH"] = "swish";
|
|
182
|
+
PaymentMethodEnum2["TWINT"] = "twint";
|
|
183
|
+
PaymentMethodEnum2["US_BANK_ACCOUNT"] = "us_bank_account";
|
|
184
|
+
PaymentMethodEnum2["WECHAT_PAY"] = "wechat_pay";
|
|
185
|
+
PaymentMethodEnum2["ZIP"] = "zip";
|
|
186
|
+
return PaymentMethodEnum2;
|
|
187
|
+
})(PaymentMethodEnum || {});
|
|
188
|
+
|
|
189
|
+
// domain/enums/planCadence.enum.ts
|
|
190
|
+
var PlanCadenceEnum = /* @__PURE__ */ ((PlanCadenceEnum2) => {
|
|
191
|
+
PlanCadenceEnum2["WEEKLY"] = "week";
|
|
192
|
+
PlanCadenceEnum2["MONTHLY"] = "month";
|
|
193
|
+
PlanCadenceEnum2["ANNUALLY"] = "year";
|
|
194
|
+
return PlanCadenceEnum2;
|
|
195
|
+
})(PlanCadenceEnum || {});
|
|
196
|
+
export {
|
|
197
|
+
BillingProviderEnum,
|
|
198
|
+
CurrencyEnum,
|
|
199
|
+
PaymentMethodEnum,
|
|
200
|
+
PlanCadenceEnum
|
|
201
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { date, optional, string, type } from '@{{app_name}}/core';
|
|
2
|
+
import {
|
|
3
|
+
StripeBillingPortalDto,
|
|
4
|
+
StripeCreateBillingPortalDto,
|
|
5
|
+
StripeUpdateBillingPortalDto
|
|
6
|
+
} from '../../types/stripe.dto.types';
|
|
7
|
+
|
|
8
|
+
export const CreateBillingPortalSchema = {
|
|
9
|
+
id: optional(string),
|
|
10
|
+
customerId: string,
|
|
11
|
+
uri: optional(string),
|
|
12
|
+
expiresAt: date,
|
|
13
|
+
stripeFields: type<StripeCreateBillingPortalDto['stripeFields']>()
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const UpdateBillingPortalSchema = {
|
|
17
|
+
id: string,
|
|
18
|
+
uri: optional(string),
|
|
19
|
+
expiresAt: optional(date),
|
|
20
|
+
stripeFields: optional(type<StripeUpdateBillingPortalDto['stripeFields']>())
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const BillingPortalSchema = {
|
|
24
|
+
id: string,
|
|
25
|
+
customerId: string,
|
|
26
|
+
uri: optional(string),
|
|
27
|
+
expiresAt: date,
|
|
28
|
+
stripeFields: type<StripeBillingPortalDto['stripeFields']>(),
|
|
29
|
+
createdAt: optional(date),
|
|
30
|
+
updatedAt: optional(date)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const StripeBillingPortalServiceSchemas = {
|
|
34
|
+
CreateBillingPortalSchema,
|
|
35
|
+
UpdateBillingPortalSchema,
|
|
36
|
+
BillingPortalSchema
|
|
37
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { LiteralSchema } from '@forklaunch/validator';
|
|
2
|
+
import {
|
|
3
|
+
array,
|
|
4
|
+
date,
|
|
5
|
+
enum_,
|
|
6
|
+
optional,
|
|
7
|
+
string,
|
|
8
|
+
type,
|
|
9
|
+
unknown
|
|
10
|
+
} from '@{{app_name}}/core';
|
|
11
|
+
import { CurrencyEnum } from '../../domain/enums/currency.enum';
|
|
12
|
+
import { PaymentMethodEnum } from '../../domain/enums/paymentMethod.enum';
|
|
13
|
+
import {
|
|
14
|
+
StripeCheckoutSessionDto,
|
|
15
|
+
StripeCreateCheckoutSessionDto,
|
|
16
|
+
StripeUpdateCheckoutSessionDto
|
|
17
|
+
} from '../../types/stripe.dto.types';
|
|
18
|
+
|
|
19
|
+
export const CreateCheckoutSessionSchema = <
|
|
20
|
+
T extends Record<string, LiteralSchema>
|
|
21
|
+
>(
|
|
22
|
+
StatusEnum: T
|
|
23
|
+
) => ({
|
|
24
|
+
id: optional(string),
|
|
25
|
+
customerId: string,
|
|
26
|
+
currency: enum_(CurrencyEnum),
|
|
27
|
+
paymentMethods: array(enum_(PaymentMethodEnum)),
|
|
28
|
+
successRedirectUri: optional(string),
|
|
29
|
+
cancelRedirectUri: optional(string),
|
|
30
|
+
expiresAt: date,
|
|
31
|
+
status: enum_(StatusEnum),
|
|
32
|
+
stripeFields: type<StripeCreateCheckoutSessionDto<T>['stripeFields']>()
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const UpdateCheckoutSessionSchema = <
|
|
36
|
+
T extends Record<string, LiteralSchema>
|
|
37
|
+
>(
|
|
38
|
+
StatusEnum: T
|
|
39
|
+
) => ({
|
|
40
|
+
id: string,
|
|
41
|
+
customerId: optional(string),
|
|
42
|
+
currency: optional(enum_(CurrencyEnum)),
|
|
43
|
+
paymentMethods: optional(array(enum_(PaymentMethodEnum))),
|
|
44
|
+
successRedirectUri: optional(string),
|
|
45
|
+
cancelRedirectUri: optional(string),
|
|
46
|
+
expiresAt: optional(date),
|
|
47
|
+
status: optional(enum_(StatusEnum)),
|
|
48
|
+
stripeFields: optional(
|
|
49
|
+
type<StripeUpdateCheckoutSessionDto<T>['stripeFields']>()
|
|
50
|
+
)
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const CheckoutSessionSchema = <T extends Record<string, LiteralSchema>>(
|
|
54
|
+
StatusEnum: T
|
|
55
|
+
) => ({
|
|
56
|
+
id: string,
|
|
57
|
+
customerId: string,
|
|
58
|
+
currency: enum_(CurrencyEnum),
|
|
59
|
+
metadata: optional(unknown),
|
|
60
|
+
paymentMethods: array(enum_(PaymentMethodEnum)),
|
|
61
|
+
successRedirectUri: optional(string),
|
|
62
|
+
cancelRedirectUri: optional(string),
|
|
63
|
+
expiresAt: date,
|
|
64
|
+
status: enum_(StatusEnum),
|
|
65
|
+
stripeFields: type<StripeCheckoutSessionDto<T>['stripeFields']>(),
|
|
66
|
+
createdAt: optional(date),
|
|
67
|
+
updatedAt: optional(date)
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const StripeCheckoutSessionServiceSchemas = {
|
|
71
|
+
CreateCheckoutSessionSchema,
|
|
72
|
+
UpdateCheckoutSessionSchema,
|
|
73
|
+
CheckoutSessionSchema
|
|
74
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { LiteralSchema } from '@forklaunch/validator';
|
|
2
|
+
import {
|
|
3
|
+
array,
|
|
4
|
+
date,
|
|
5
|
+
enum_,
|
|
6
|
+
number,
|
|
7
|
+
optional,
|
|
8
|
+
string,
|
|
9
|
+
type
|
|
10
|
+
} from '@{{app_name}}/core';
|
|
11
|
+
import { CurrencyEnum } from '../../domain/enums/currency.enum';
|
|
12
|
+
import { PaymentMethodEnum } from '../../domain/enums/paymentMethod.enum';
|
|
13
|
+
import {
|
|
14
|
+
StripeCreatePaymentLinkDto,
|
|
15
|
+
StripePaymentLinkDto,
|
|
16
|
+
StripeUpdatePaymentLinkDto
|
|
17
|
+
} from '../../types/stripe.dto.types';
|
|
18
|
+
|
|
19
|
+
export const CreatePaymentLinkSchema = <
|
|
20
|
+
T extends Record<string, LiteralSchema>
|
|
21
|
+
>(
|
|
22
|
+
StatusEnum: T
|
|
23
|
+
) => ({
|
|
24
|
+
id: optional(string),
|
|
25
|
+
amount: number,
|
|
26
|
+
currency: enum_(CurrencyEnum),
|
|
27
|
+
paymentMethods: array(enum_(PaymentMethodEnum)),
|
|
28
|
+
status: enum_(StatusEnum),
|
|
29
|
+
stripeFields: type<StripeCreatePaymentLinkDto<T>['stripeFields']>()
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const UpdatePaymentLinkSchema = <
|
|
33
|
+
T extends Record<string, LiteralSchema>
|
|
34
|
+
>(
|
|
35
|
+
StatusEnum: T
|
|
36
|
+
) => ({
|
|
37
|
+
id: string,
|
|
38
|
+
amount: optional(number),
|
|
39
|
+
currency: optional(enum_(CurrencyEnum)),
|
|
40
|
+
paymentMethods: optional(array(enum_(PaymentMethodEnum))),
|
|
41
|
+
status: optional(enum_(StatusEnum)),
|
|
42
|
+
stripeFields: optional(type<StripeUpdatePaymentLinkDto<T>['stripeFields']>())
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const PaymentLinkSchema = <T extends Record<string, LiteralSchema>>(
|
|
46
|
+
StatusEnum: T
|
|
47
|
+
) => ({
|
|
48
|
+
id: string,
|
|
49
|
+
amount: number,
|
|
50
|
+
currency: enum_(CurrencyEnum),
|
|
51
|
+
paymentMethods: array(enum_(PaymentMethodEnum)),
|
|
52
|
+
status: enum_(StatusEnum),
|
|
53
|
+
stripeFields: type<StripePaymentLinkDto<T>['stripeFields']>(),
|
|
54
|
+
createdAt: optional(date),
|
|
55
|
+
updatedAt: optional(date)
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const StripePaymentLinkServiceSchemas = {
|
|
59
|
+
CreatePaymentLinkSchema,
|
|
60
|
+
UpdatePaymentLinkSchema,
|
|
61
|
+
PaymentLinkSchema
|
|
62
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
boolean,
|
|
4
|
+
date,
|
|
5
|
+
enum_,
|
|
6
|
+
number,
|
|
7
|
+
optional,
|
|
8
|
+
string,
|
|
9
|
+
type
|
|
10
|
+
} from '@{{app_name}}/core';
|
|
11
|
+
import { BillingProviderEnum } from '../../domain/enums/billingProvider.enum';
|
|
12
|
+
import { CurrencyEnum } from '../../domain/enums/currency.enum';
|
|
13
|
+
import { PlanCadenceEnum } from '../../domain/enums/planCadence.enum';
|
|
14
|
+
import {
|
|
15
|
+
StripeCreatePlanDto,
|
|
16
|
+
StripePlanDto,
|
|
17
|
+
StripeUpdatePlanDto
|
|
18
|
+
} from '../../types/stripe.dto.types';
|
|
19
|
+
|
|
20
|
+
export const CreatePlanSchema = {
|
|
21
|
+
id: optional(string),
|
|
22
|
+
name: string,
|
|
23
|
+
description: optional(string),
|
|
24
|
+
price: number,
|
|
25
|
+
cadence: enum_(PlanCadenceEnum),
|
|
26
|
+
currency: enum_(CurrencyEnum),
|
|
27
|
+
features: optional(array(string)),
|
|
28
|
+
stripeFields: type<StripeCreatePlanDto['stripeFields']>(),
|
|
29
|
+
externalId: string,
|
|
30
|
+
billingProvider: optional(enum_(BillingProviderEnum)),
|
|
31
|
+
active: boolean
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const UpdatePlanSchema = {
|
|
35
|
+
id: string,
|
|
36
|
+
name: optional(string),
|
|
37
|
+
description: optional(string),
|
|
38
|
+
price: optional(number),
|
|
39
|
+
cadence: optional(enum_(PlanCadenceEnum)),
|
|
40
|
+
currency: optional(enum_(CurrencyEnum)),
|
|
41
|
+
features: optional(array(string)),
|
|
42
|
+
stripeFields: optional(type<StripeUpdatePlanDto['stripeFields']>()),
|
|
43
|
+
externalId: optional(string),
|
|
44
|
+
billingProvider: optional(enum_(BillingProviderEnum)),
|
|
45
|
+
active: optional(boolean)
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const PlanSchema = {
|
|
49
|
+
id: string,
|
|
50
|
+
name: string,
|
|
51
|
+
description: optional(string),
|
|
52
|
+
price: number,
|
|
53
|
+
cadence: enum_(PlanCadenceEnum),
|
|
54
|
+
currency: enum_(CurrencyEnum),
|
|
55
|
+
features: optional(array(string)),
|
|
56
|
+
stripeFields: type<StripePlanDto['stripeFields']>(),
|
|
57
|
+
externalId: string,
|
|
58
|
+
billingProvider: optional(enum_(BillingProviderEnum)),
|
|
59
|
+
active: boolean,
|
|
60
|
+
createdAt: optional(date),
|
|
61
|
+
updatedAt: optional(date)
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const StripePlanServiceSchemas = {
|
|
65
|
+
CreatePlanSchema,
|
|
66
|
+
UpdatePlanSchema,
|
|
67
|
+
PlanSchema
|
|
68
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { LiteralSchema } from '@forklaunch/validator';
|
|
2
|
+
import {
|
|
3
|
+
boolean,
|
|
4
|
+
date,
|
|
5
|
+
enum_,
|
|
6
|
+
optional,
|
|
7
|
+
string,
|
|
8
|
+
type
|
|
9
|
+
} from '@{{app_name}}/core';
|
|
10
|
+
import { BillingProviderEnum } from '../../domain/enums/billingProvider.enum';
|
|
11
|
+
import {
|
|
12
|
+
StripeCreateSubscriptionDto,
|
|
13
|
+
StripeSubscriptionDto,
|
|
14
|
+
StripeUpdateSubscriptionDto
|
|
15
|
+
} from '../../types/stripe.dto.types';
|
|
16
|
+
|
|
17
|
+
export const CreateSubscriptionSchema = <
|
|
18
|
+
T extends Record<string, LiteralSchema>
|
|
19
|
+
>(
|
|
20
|
+
PartyEnum: T
|
|
21
|
+
) => ({
|
|
22
|
+
id: optional(string),
|
|
23
|
+
partyId: string,
|
|
24
|
+
partyType: enum_(PartyEnum),
|
|
25
|
+
productId: string,
|
|
26
|
+
description: optional(string),
|
|
27
|
+
active: boolean,
|
|
28
|
+
externalId: string,
|
|
29
|
+
startDate: date,
|
|
30
|
+
endDate: optional(date),
|
|
31
|
+
status: string,
|
|
32
|
+
billingProvider: optional(enum_(BillingProviderEnum)),
|
|
33
|
+
stripeFields: type<StripeCreateSubscriptionDto<T>['stripeFields']>()
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const UpdateSubscriptionSchema = <
|
|
37
|
+
T extends Record<string, LiteralSchema>
|
|
38
|
+
>(
|
|
39
|
+
PartyEnum: T
|
|
40
|
+
) => ({
|
|
41
|
+
id: string,
|
|
42
|
+
partyId: optional(string),
|
|
43
|
+
partyType: optional(enum_(PartyEnum)),
|
|
44
|
+
productId: optional(string),
|
|
45
|
+
description: optional(string),
|
|
46
|
+
active: optional(boolean),
|
|
47
|
+
externalId: optional(string),
|
|
48
|
+
startDate: optional(date),
|
|
49
|
+
endDate: optional(date),
|
|
50
|
+
status: optional(string),
|
|
51
|
+
billingProvider: optional(enum_(BillingProviderEnum)),
|
|
52
|
+
stripeFields: optional(type<StripeUpdateSubscriptionDto<T>['stripeFields']>())
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const SubscriptionSchema = <T extends Record<string, LiteralSchema>>(
|
|
56
|
+
PartyEnum: T
|
|
57
|
+
) => ({
|
|
58
|
+
id: string,
|
|
59
|
+
partyId: string,
|
|
60
|
+
partyType: enum_(PartyEnum),
|
|
61
|
+
productId: string,
|
|
62
|
+
description: optional(string),
|
|
63
|
+
active: boolean,
|
|
64
|
+
externalId: string,
|
|
65
|
+
startDate: date,
|
|
66
|
+
endDate: optional(date),
|
|
67
|
+
status: string,
|
|
68
|
+
billingProvider: optional(enum_(BillingProviderEnum)),
|
|
69
|
+
stripeFields: type<StripeSubscriptionDto<T>['stripeFields']>(),
|
|
70
|
+
createdAt: optional(date),
|
|
71
|
+
updatedAt: optional(date)
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const StripeSubscriptionServiceSchemas = {
|
|
75
|
+
CreateSubscriptionSchema,
|
|
76
|
+
UpdateSubscriptionSchema,
|
|
77
|
+
SubscriptionSchema
|
|
78
|
+
};
|