Exactly when MarketplaceService.ProcessReceipt is called?

So, I am creating a Developer Products for the first time and I have some doubts. This is what it says in the roblox documentation:

After a player makes a purchase through a PromptProductPurchase() dialog, this callback is called multiple times until it returns Enum.ProductPurchaseDecision.PurchaseGranted.

That’s clear. But then it says this:

For example, the function is called again for a product when the player joins the game — or even after they have bought something else

why does it say that the callback will be called when a player joins the game? and why does it say that it will be called after it has bought something else? So, the big question is, exactly when is this callback called?

Thanks for answering.

The function will be fired when a player joins the game to check if the Player purchased the dev product while not playing the game. This video explains the basics and how to code a basic purchase with devproducts and here an example of a script (purchases currency).

2 Likes

Thank you very much for your reply. I checked the links and they were very helpful. But I still have a doubt, can a player buy a developer product outside the game? This is really new to me, so could you explain a bit more about that?

They should be able to purchase it from outside the game, that’s why the function fires when a player joins the game using the following code in the function:

if not player then -- If the player is not in the game rn
    return Enum.ProductPurchaseDecision.NotProcessedYet -- Halt the funtion until the Player joins the game
end

As the documentation says, ProcessReceipt is called at multiple times throughout your game until PurchaseGranted is returned. If PurchaseGranted isn’t returned within three days, the player will be refunded for their purchase.

This is done to ensure that the player’s purchase can properly be handled in case there’s ever an error or a reason the developer’s code returns NotProcessedYet instead of PurchaseGranted, either in the form of delaying when they get their benefits or refunding their purchase.

Not sure of all the cases when it gets fired again but they’re typically not - unless you’re very technically invested - anything you need to know about. You just need to worry about using ProcessReceipt to correctly grant purchases.

Products cannot be purchased outside of a game. The reason why it fires again when a player joins is to ensure that an unprocessed purchase from a previous session can be retried in a new one.

1 Like