Hello everyone,
Short question:
Does anyone know what :
ProductPurchaseDecision
does?
I appreciate any help, thx :D.
Hello everyone,
Short question:
Does anyone know what :
ProductPurchaseDecision
does?
I appreciate any help, thx :D.
ProductPurchaseDecision
is used in developer product processing to indicate whether a player has received product benefits successfully. Returning Enum.ProductPurchaseDecision.PurchaseGranted
indicates to the MarketplaceService that the product has been successfully processed and the player received their benefits. Returning Enum.ProductPurchaseDecision.NotProcessedYet
indicates to the MarketplaceService that something went wrong and then will retry when the player next joins the game.
local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local productFuncs = {}
productFuncs[productId] = function(player: Player): nil
--give benefits
end
--the use for these EnumItems is within the main callback
local function processReceipt(receipt: {[string]: any}): Enum.ProductPurchaseDecision
--we would get the player and product from the receipt
local player = players:GetPlayerByUserId(receipt.PlayerId)
local productId = receipt.ProductId
--then, we'd get the appropriate handler to handle the purchase
local handler = productFuncs[productId]
--we run it in protected mode. This way, we can catch errors and return the appropriate Enum
local success, result = pcall(handler, player)
--get the appropriate return Enum to indicate the outcome to the MarketplaceService
local returnItem = if success then Enum.ProductPurchaseDecision.PurchaseGranted
else Enum.ProductPurchaseDecision.NotProcessedYet
--return the Enum
return returnItem
end
mps.ProcessReceipt = processReceipt
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.