mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add dryRun parameter to the purchase api
This commit is contained in:
+2
-1
@@ -96,10 +96,11 @@ Use this to unlock all features for one user for a specified duration.
|
|||||||
|
|
||||||
### request
|
### request
|
||||||
|
|
||||||
request properties: ``purchaseToken`` and ``purchaseId``
|
request properties: ``purchaseToken``, ``purchaseId`` and ``dryRun``
|
||||||
|
|
||||||
- ``purchasetoken`` is a string which the client shows at the purchase screen
|
- ``purchasetoken`` is a string which the client shows at the purchase screen
|
||||||
- ``purchaseId`` is the ID that is used at the bill
|
- ``purchaseId`` is the ID that is used at the bill
|
||||||
|
- ``dryRun`` is a boolean; setting true will skip the actual unlocking
|
||||||
|
|
||||||
### response
|
### response
|
||||||
|
|
||||||
|
|||||||
+14
-10
@@ -140,13 +140,15 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
if (
|
if (
|
||||||
typeof req.body !== 'object' ||
|
typeof req.body !== 'object' ||
|
||||||
typeof req.body.purchaseToken !== 'string' ||
|
typeof req.body.purchaseToken !== 'string' ||
|
||||||
typeof req.body.purchaseId !== 'string'
|
typeof req.body.purchaseId !== 'string' ||
|
||||||
|
typeof req.body.dryRun !== 'boolean'
|
||||||
) {
|
) {
|
||||||
throw new BadRequest()
|
throw new BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
const purchaseToken: string = req.body.purchaseToken
|
const purchaseToken: string = req.body.purchaseToken
|
||||||
const purchaseId: string = req.body.purchaseId
|
const purchaseId: string = req.body.purchaseId
|
||||||
|
const dryRun: boolean = req.body.dryRun
|
||||||
|
|
||||||
const tokenContent = await verifyIdentitifyToken(purchaseToken)
|
const tokenContent = await verifyIdentitifyToken(purchaseToken)
|
||||||
|
|
||||||
@@ -250,15 +252,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await addPurchase({
|
if (!dryRun) {
|
||||||
database,
|
await addPurchase({
|
||||||
familyId: tokenContent.familyId,
|
database,
|
||||||
type: 'year',
|
familyId: tokenContent.familyId,
|
||||||
service: 'directpurchase',
|
type: 'year',
|
||||||
transactionId: purchaseId,
|
service: 'directpurchase',
|
||||||
websocket,
|
transactionId: purchaseId,
|
||||||
transaction
|
websocket,
|
||||||
})
|
transaction
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user