Convert "ProcessReceipt" into "Prompt GamePass Purchase Finished"?

Hello! I need help converting a ProcessReceipt Function into a PromptGamePassPurchaseFinished Event. How would I do this?

Code reference
MarketplaceService.ProcessReceipt = function(receiptInfo)

	for _, player in pairs(game:GetService("Players"):GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
-- and so on..

-- to this:
1. Check if the gamepass is successful
2. Check if the id is correct (I already have a code for this)
3. Make sure code doesn't have issues since it's for dev products.

I need to change this 'cause I have a script that only relies on ProcessReceipt, and that’s why I need to modify all other scripts to something else.

(For Context:) About ProcessReceipt & ...PurchaseFinished
  • ProcessReceipt (different to PromptGamePassPurchaseFinished) is a Function and can only be called from one script. This can be compared to OnServerInvoke.

  • PromptGamePassPurchaseFinished can be called from any script and the fire event does not need to rely on a single event.

Thank you in advance! :slight_smile:
Sincerely, Dev_Mathe

1 Like

Doesn’t matter if it’s spoonfeed at this point. No one is responding. :neutral_face:

Sincerely, I sorta need an answer soon. :slight_smile:

You don’t, they’re two different things and are used for two different purposes. ProcessReceipt is used for processing developer product purchases (awarding one-time purchase perks like currency) and handles refunds if the purchase wasn’t marked as successful after 7 (I think) days, whereas PromptGamePassPurchaseFinished is just that, it fires when the user closes a game pass purchase prompt. It isn’t processing a purchase or anything.

Well then what do I do in this scenario? I have a leaderboard that I cannot change and developer products like coins, multipliers etc. in a custom script. Both are developer products.

I believe what you’re looking for is this:

local MarketplaceService = game:GetService('MarketplaceService')

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, ProductId, WasPurchased)
    if Player and ProductId == 0000000 and WasPurchased then
        print(Player.Name..' has purchased a gamepass!')
    elseif Player and ProductId == 1111111 and WasPurchased then
        print(Player.Name..' has purchased a different gamepass!')

Something like that is what you’re looking for! Just keep following the same basic formula (elseif Player and ProductId == Your_ProductId_Here and WasPurchased then), and you’ll be all good! :smile:

Perfect! You sure this won’t cause any trouble? What would be the disadvantages?

As game passes are kept forever once bought, you won’t have any trouble. The event PromptGamePassPurchaseFinished will only fire after the transaction had been made, thus, even if the player leaves or is disconnected @CommanderRanking code should work with ease.

Note: Make sure to have a handler when the player joins the server to check for game passes