Why doesn't ProcessReceipt Fire?
I've tried everything I could think of, but the function won't fire when I buy the dev product. sometimes after I rejoin the place, it recognises that I bought the item, but I'd like it to recognise instantly.
the place with the script in question is here
and here is the script in question, all variable references are to existing items
001 | if game.ServerScriptService:FindFirstChild( "VaporPurchaseHandler" ) ~ = nil then |
002 | script.Parent = game.ServerScriptService |
008 | enable_debug_print = true |
010 | if enable_debug_print then |
015 | print_d( "DEBUG MODE ACTIVE" ) |
017 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
018 | local PurchaseHistory = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
019 | local data = game:GetService( "DataStoreService" ):GetDataStore( "VaporData" ) |
023 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
025 | local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId |
026 | if PurchaseHistory:GetAsync(playerProductKey) then |
027 | return Enum.ProductPurchaseDecision.PurchaseGranted |
029 | print_d( "RUNNING: for i, player in ipairs(game.Players:GetPlayers()) do" ) |
030 | for i, player in ipairs (game.Players:GetPlayers()) do |
031 | print_d( "RUNNING: if player.userId == receiptInfo.PlayerId then" ) |
032 | if player.userId = = receiptInfo.PlayerId then |
033 | print_d( "condition successful" ) |
035 | local vapor = player.PlayerGui:FindFirstChild( "Vapor" ) |
036 | local props = vapor.Properties |
037 | local GameId = props.ProductId.Value |
038 | local suffix = props.DataSuffix.Value |
039 | local main = vapor.Window |
041 | if receiptInfo.ProductId = = GameId then |
044 | main.Buy.Visible = false |
045 | main.Load.Visible = true |
046 | print_d( "gameIdAffirmative" ) |
047 | if main.Buy:FindFirstChild( "Gift" ) ~ = nil and main.Buy:FindFirstChild( "Gift" ).isGift.Value = = true then |
049 | local text = string.lower(main.Buy:FindFirstChild( "Gift" ).GiftBox.Text) |
050 | local giftlist = data:GetAsync( "giftlist" ..suffix) |
051 | if giftlist ~ = nil then |
053 | for i = 1 ,#giftlist do |
054 | if giftlist [ i ] = = text then |
055 | print_d( "already gifted to " ..text) |
060 | if gifted = = false then |
062 | table.insert(giftlist,text) |
063 | data:SetAsync_d( "giftlist" ..suffix,giftlist) |
064 | main.Load.Text.Text = "Gift Sent.." |
070 | main.Load.Text.Text = "Processing.." |
071 | main.Load.Visible = false |
072 | main:FindFirstChild( "Buy" ).Visible = true |
074 | elseif main.Buy:FindFirstChild( "Gift" ).isGift.Value = = false then |
077 | data:SetAsync(player.userId..suffix, true ) |
078 | main.Load.Text.Text = "Purchase Complete.." |
080 | main.Load.Text.Text = "Processing.." |
082 | main.Load.Visible = false |
083 | main.Buy.Visible = true |
085 | vapor.Back.Visible = false |
088 | else print_d( "notgift, and not notgift" ) |
093 | print_d( "condition failed" ) |
095 | print_d( "if statement completed" ) |
097 | PurchaseHistory:SetAsync(playerProductKey, true ) |
098 | print_d( "purchasefinish" ) |
099 | return Enum.ProductPurchaseDecision.PurchaseGranted |
102 | print_d( "purchase handler is ready" ) |