MarketPlace ProcessReceipt function stopping for no reason

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...")
	local pendingPurchase, purchaseIndex = PetSystem:GetPendingPurchaseByPurchaseId(player, purchase_id)	
	local inventory = PetInventory.get(player)
-- ...

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
	return nil

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	
    return Enum.ProductPurchaseDecision.NotProcessedYet

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

1 Like

Ignore… I was just being dumb and found an error in my code

1 Like

Glad you found it! Mark your comment as the solution so the topic closes.