@stamhoofd/backend 2.105.0 → 2.106.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/package.json +10 -10
- package/src/crons.ts +39 -5
- package/src/endpoints/global/members/GetMembersEndpoint.test.ts +953 -47
- package/src/endpoints/global/members/GetMembersEndpoint.ts +1 -1
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +142 -0
- package/src/endpoints/global/registration/GetRegistrationsEndpoint.ts +1 -1
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +163 -8
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +2 -0
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.test.ts +108 -0
- package/src/endpoints/organization/dashboard/billing/GetPackagesEndpoint.ts +40 -0
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +8 -1
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +8 -1
- package/src/helpers/AdminPermissionChecker.ts +30 -6
- package/src/helpers/AuthenticatedStructures.ts +2 -2
- package/src/helpers/MemberUserSyncer.test.ts +400 -1
- package/src/helpers/MemberUserSyncer.ts +15 -10
- package/src/helpers/ServiceFeeHelper.ts +63 -0
- package/src/helpers/StripeHelper.ts +7 -4
- package/src/helpers/StripePayoutChecker.ts +1 -1
- package/src/seeds/0000000001-development-user.ts +2 -2
- package/src/seeds/0000000004-single-organization.ts +60 -0
- package/src/seeds/1754560914-groups-prices.test.ts +3023 -0
- package/src/seeds/1754560914-groups-prices.ts +408 -0
- package/src/seeds/{1722344162-sync-member-users.ts → 1761665607-sync-member-users.ts} +1 -1
- package/src/sql-filters/members.ts +1 -1
- package/tests/init/initAdmin.ts +19 -5
- package/tests/init/initPermissionRole.ts +14 -4
- package/tests/init/initPlatformRecordCategory.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.106.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@simonbackx/simple-encoding": "2.22.0",
|
|
46
46
|
"@simonbackx/simple-endpoints": "1.20.1",
|
|
47
47
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
48
|
-
"@stamhoofd/backend-i18n": "2.
|
|
49
|
-
"@stamhoofd/backend-middleware": "2.
|
|
50
|
-
"@stamhoofd/email": "2.
|
|
51
|
-
"@stamhoofd/models": "2.
|
|
52
|
-
"@stamhoofd/queues": "2.
|
|
53
|
-
"@stamhoofd/sql": "2.
|
|
54
|
-
"@stamhoofd/structures": "2.
|
|
55
|
-
"@stamhoofd/utility": "2.
|
|
48
|
+
"@stamhoofd/backend-i18n": "2.106.1",
|
|
49
|
+
"@stamhoofd/backend-middleware": "2.106.1",
|
|
50
|
+
"@stamhoofd/email": "2.106.1",
|
|
51
|
+
"@stamhoofd/models": "2.106.1",
|
|
52
|
+
"@stamhoofd/queues": "2.106.1",
|
|
53
|
+
"@stamhoofd/sql": "2.106.1",
|
|
54
|
+
"@stamhoofd/structures": "2.106.1",
|
|
55
|
+
"@stamhoofd/utility": "2.106.1",
|
|
56
56
|
"archiver": "^7.0.1",
|
|
57
57
|
"axios": "^1.8.2",
|
|
58
58
|
"cookie": "^0.7.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "301b0e54aa05d6369752f2eeaa80d2c31918e5e8"
|
|
74
74
|
}
|
package/src/crons.ts
CHANGED
|
@@ -121,13 +121,14 @@ async function checkWebshopDNS() {
|
|
|
121
121
|
lastWebshopDNSId = webshops[webshops.length - 1].id;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
//
|
|
124
|
+
// 11 min - 2 hours
|
|
125
125
|
async function checkPayments() {
|
|
126
126
|
if (STAMHOOFD.environment === 'development') {
|
|
127
127
|
// return;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const timeout = 60 * 1000 *
|
|
130
|
+
const timeout = 60 * 1000 * 11;
|
|
131
|
+
const timeout2 = 60 * 1000 * 60 * 2;
|
|
131
132
|
|
|
132
133
|
// TODO: only select the ID + organizationId
|
|
133
134
|
const payments = await Payment.select()
|
|
@@ -136,7 +137,8 @@ async function checkPayments() {
|
|
|
136
137
|
PaymentMethod.Bancontact, PaymentMethod.iDEAL, PaymentMethod.Payconiq, PaymentMethod.CreditCard,
|
|
137
138
|
])
|
|
138
139
|
.and('status', [PaymentStatus.Created, PaymentStatus.Pending])
|
|
139
|
-
.and('createdAt', '<', new Date(new Date().getTime() - timeout))
|
|
140
|
+
.and('createdAt', '<', new Date(new Date().getTime() - timeout))
|
|
141
|
+
.and('createdAt', '>', new Date(new Date().getTime() - timeout2)),
|
|
140
142
|
)
|
|
141
143
|
// For payconiq payments, we have a shorter timeout of 1 minute if they are still in the 'created' state (not scanned)
|
|
142
144
|
.orWhere(
|
|
@@ -144,14 +146,45 @@ async function checkPayments() {
|
|
|
144
146
|
PaymentMethod.Payconiq,
|
|
145
147
|
])
|
|
146
148
|
.and('status', [PaymentStatus.Created])
|
|
147
|
-
.and('createdAt', '<', new Date(new Date().getTime() - 60 * 1000))
|
|
149
|
+
.and('createdAt', '<', new Date(new Date().getTime() - 60 * 1000))
|
|
150
|
+
.and('createdAt', '>', new Date(new Date().getTime() - timeout2)),
|
|
148
151
|
)
|
|
149
152
|
.orderBy('createdAt', 'ASC')
|
|
150
|
-
.limit(
|
|
153
|
+
.limit(500)
|
|
151
154
|
.fetch();
|
|
152
155
|
|
|
153
156
|
console.log('[DELAYED PAYMENTS] Checking pending payments: ' + payments.length);
|
|
157
|
+
await doCheckPayments(payments);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 2 hours - 3 days
|
|
161
|
+
async function checkOldPayments() {
|
|
162
|
+
if (STAMHOOFD.environment === 'development') {
|
|
163
|
+
// return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const timeout = 60 * 1000 * 60 * 2;
|
|
167
|
+
const timeout2 = 60 * 1000 * 60 * 24 * 3;
|
|
168
|
+
|
|
169
|
+
// TODO: only select the ID + organizationId
|
|
170
|
+
const payments = await Payment.select()
|
|
171
|
+
.where(
|
|
172
|
+
SQL.where('method', [
|
|
173
|
+
PaymentMethod.Bancontact, PaymentMethod.iDEAL, PaymentMethod.Payconiq, PaymentMethod.CreditCard,
|
|
174
|
+
])
|
|
175
|
+
.and('status', [PaymentStatus.Created, PaymentStatus.Pending])
|
|
176
|
+
.and('createdAt', '<', new Date(new Date().getTime() - timeout))
|
|
177
|
+
.and('createdAt', '>', new Date(new Date().getTime() - timeout2)),
|
|
178
|
+
)
|
|
179
|
+
.orderBy('createdAt', 'ASC')
|
|
180
|
+
.limit(500)
|
|
181
|
+
.fetch();
|
|
182
|
+
|
|
183
|
+
console.log('[DELAYED PAYMENTS] Checking old pending payments: ' + payments.length);
|
|
184
|
+
await doCheckPayments(payments);
|
|
185
|
+
}
|
|
154
186
|
|
|
187
|
+
async function doCheckPayments(payments: Payment[]) {
|
|
155
188
|
for (const payment of payments) {
|
|
156
189
|
try {
|
|
157
190
|
if (payment.organizationId) {
|
|
@@ -348,6 +381,7 @@ registerCron('checkReservedUntil', checkReservedUntil);
|
|
|
348
381
|
registerCron('checkDNS', checkDNS);
|
|
349
382
|
registerCron('checkWebshopDNS', checkWebshopDNS);
|
|
350
383
|
registerCron('checkPayments', checkPayments);
|
|
384
|
+
registerCron('checkOldPayments', checkOldPayments);
|
|
351
385
|
registerCron('checkDrips', checkDrips);
|
|
352
386
|
|
|
353
387
|
// Register other crons
|