forked from OpenWF/SpaceNinjaServer
handle invalid bundle request
This commit is contained in:
parent
de9283e3a7
commit
2dfb36018f
@ -335,8 +335,19 @@ const handleCreditBundlePurchase = async (
|
||||
inventory: TInventoryDatabaseDocument
|
||||
): Promise<IPurchaseResponse> => {
|
||||
const bundleName = typeName.split(typeName).pop();
|
||||
let creditsAmount = 0;
|
||||
|
||||
// CreditBundleA = 50.000 credits or CreditBundleC = 175.000 credits
|
||||
const creditsAmount = bundleName == "CreditBundleA" ? 50_000 : 175_000;
|
||||
switch (bundleName) {
|
||||
case "CreditBundleA":
|
||||
creditsAmount = 50_000;
|
||||
break;
|
||||
case "CreditBundleC":
|
||||
creditsAmount = 175_000;
|
||||
break;
|
||||
default:
|
||||
throw new Error("invalid credit bundle: " + bundleName);
|
||||
}
|
||||
|
||||
inventory.RegularCredits += creditsAmount;
|
||||
await inventory.save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user