Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I use ProcessReceipt?

Asked by
Minifig77 190
10 years ago

I'm trying to make a developer product to sell things in game, and I found out that you have to use ProcessReciept to find out if the purchase went through. I look at the ROBLOX Wiki page, and the example is too complicated for a guy just trying to learn how to use it to figure out. Is there a simpler example?

1 answer

Log in to vote
0
Answered by
TofuBytes 500 Moderation Voter
10 years ago

This is the script I use for processing receipts for the player. It uses a DataSore to store the amount they've bought. It will continue to give them that item unless you script a lock so they don't continue to repurchase something they have forever.

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") --Data Stored into "PurchaseHistory"

MarketplaceService.ProcessReceipt = function(receiptInfo)
    print("Test Receipt Loaded")
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId --example "player_3774904_product_19918045"
    local numberBought = ds:IncrementAsync(playerProductKey, 1) --Increases their current amount.
    for i,v in pairs (game.Players:GetChildren()) do
        if v.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == 19918045 then --Dev Product ID would go here and verifies if they bought it.
                print("User Bought a Dev Product.") --Your code would replace this.
                    end
                end
            end
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end
Ad

Answer this question