ProccessReceipt issue, getting additional calls on each purchase

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:
image

I appreciate every suggestion and solution offered.

2 Likes

I solved my issue, some unrelated part of my code was messing with my return, causing the ProcessReceipt not to reach ProductPurchaseDecision.PurchaseGranted. It’s working as intended now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.