handle invalid bundle request
This commit is contained in:
parent
de9283e3a7
commit
2dfb36018f
@ -335,8 +335,19 @@ const handleCreditBundlePurchase = async (
|
|||||||
inventory: TInventoryDatabaseDocument
|
inventory: TInventoryDatabaseDocument
|
||||||
): Promise<IPurchaseResponse> => {
|
): Promise<IPurchaseResponse> => {
|
||||||
const bundleName = typeName.split(typeName).pop();
|
const bundleName = typeName.split(typeName).pop();
|
||||||
|
let creditsAmount = 0;
|
||||||
|
|
||||||
// CreditBundleA = 50.000 credits or CreditBundleC = 175.000 credits
|
// 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;
|
inventory.RegularCredits += creditsAmount;
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user