Hello, I’m experiencing this issue regarding ProcessReceipts where the function is being called an additional time for each purchase made.
Its essentially the same issue as this:
This is causing my function to make a Datastore:GetAsync() for each of the calls and im worried I will theoretically hit the queue/limit were a player to purchase enough products
...
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
--this line is calling the datastore multiple times
purchased = self.purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
print(tag('Purchase Recorded')) --this line is getting printed multiple times
return Enum.ProductPurchaseDecision.PurchaseGranted --ends here
elseif not success then
error(tag("Data store error:") .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = self.productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
...
return Enum.ProductPurchaseDecision.PurchaseGranted
Output:
I appreciate every suggestion and solution offered.