MarketplaceService callback when an asset sale is made

As a Roblox developer, it is currently too hard to give player awards when they buy UGC in my experience.

The best solution we have right now is to listen to MarketplaceService:PromptPurchaseFinished however, if the player leaves the game before clicking the final “ok” button, we will never know they finished the purchase, and thus, can not give any promised awards.

One solution is detection if they own the asset when they rejoin the game, however, this does not work if the UGC is limited and they can purchase multiple of the item, because we cannot detect if they own multiple of the same asset with existing API

My suggestion is creating a MarketplaceService callback similar to MarketplaceService.ProcessReciept

MarketplaceService.ProcessSale = function (player, assetId, wasPurchased)
  if wasPurchased then
    if assetId == 000 then
      print("Thanks for buying!  Here is 100 coins!")
    end
  end
end
4 Likes

The code sample for ProcessReciept MarketplaceService | Documentation - Roblox Creator Hub seems to cover exactly your case. It says there in a comment “-- The player probably left the game” (scroll down completely to see the sample).

ProcessReciept only runs for dev products, not assets or Gamepasses

Oh sorry! Didn’t pay enough attention, then it’s wrong of course

1 Like