Add dryRun parameter to the purchase api

This commit is contained in:
Jonas Lochmann
2026-01-26 01:00:00 +01:00
parent 6935c0811c
commit c6c0051f82
2 changed files with 16 additions and 11 deletions
+14 -10
View File
@@ -140,13 +140,15 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
if (
typeof req.body !== 'object' ||
typeof req.body.purchaseToken !== 'string' ||
typeof req.body.purchaseId !== 'string'
typeof req.body.purchaseId !== 'string' ||
typeof req.body.dryRun !== 'boolean'
) {
throw new BadRequest()
}
const purchaseToken: string = req.body.purchaseToken
const purchaseId: string = req.body.purchaseId
const dryRun: boolean = req.body.dryRun
const tokenContent = await verifyIdentitifyToken(purchaseToken)
@@ -250,15 +252,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
}
}
await addPurchase({
database,
familyId: tokenContent.familyId,
type: 'year',
service: 'directpurchase',
transactionId: purchaseId,
websocket,
transaction
})
if (!dryRun) {
await addPurchase({
database,
familyId: tokenContent.familyId,
type: 'year',
service: 'directpurchase',
transactionId: purchaseId,
websocket,
transaction
})
}
}
return {