diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index bc2ef924f..69723d24e 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -330,6 +330,20 @@ const handleBoosterPackPurchase = async ( return purchaseResponse; }; +const handleCreditBundlePurchase = async ( + typeName: string, + inventory: TInventoryDatabaseDocument +): Promise => { + const bundleName = typeName.split(typeName).pop(); + // CreditBundleA = 50.000 credits or CreditBundleC = 175.000 credits + const creditsAmount = bundleName == "CreditBundleA" ? 50_000 : 175_000; + + inventory.RegularCredits += creditsAmount; + await inventory.save(); + + return { InventoryChanges: { RegularCredits: creditsAmount } }; +}; + //TODO: change to getInventory, apply changes then save at the end const handleTypesPurchase = async ( typesName: string, @@ -345,6 +359,8 @@ const handleTypesPurchase = async ( return handleBoosterPackPurchase(typesName, inventory, quantity); case "SlotItems": return handleSlotPurchase(typesName, inventory, quantity); + case "CreditBundles": + return handleCreditBundlePurchase(typesName, inventory); } };