I’m trying to process a receipt for a developer product but the code I’ve writ to handle the receipt randomly stops executing midway through.
function PetSystem:ConfirmPendingPurchase(player, purchase_id) print("Confirming purchase...") print(1) local pendingPurchase, purchaseIndex = PetSystem:GetPendingPurchaseByPurchaseId(player, purchase_id) print(2) local inventory = PetInventory.get(player) print(3) -- ...
The function prints “1” but never prints “2”. the GetPendingPurchaseByPurchaseId function doesn’t yield, it’s just a loop to find the corresponding purchase object:
function PetSystem:GetPendingPurchaseByPurchaseId(player, purchase_id) for i, purchase in ipairs(PendingPurchases[player]) do if purchase.PurchaseId == purchase_id then return purchase, i end end return nil end
This is the code I have in the ProcessReceipt callback function:
print("DevProducts >> found pet purchase") -- V doesn't execute past this line V local success = PetSystem:ConfirmPendingPurchase(petPurchase.PurchaseId) if success then print("DevProducts >> purchase confirmed") return Enum.ProductPurchaseDecision.PurchaseGranted else return Enum.ProductPurchaseDecision.NotProcessedYet end
I vaguely remember something about datastore UpdateAsync cutting your code short if you tried to yield in the callback function… is it possible something like this is happening with my code? If so, I can’t imagine why since none of it yields the execution at all