MarketplaceService.ProcessReceipt not firing in studio testing

I have setup the ProcessReceipt callback like this. (using Knit framework, thats why you see a : in there)

function GamePassService:ProcessReceipt(receiptInfo)
    print("cheetoes are the best!")
    print(receiptInfo)
end 

MarketplaceService.ProcessReceipt = GamePassService:ProcessReceipt()

When I test in Studio, at server startup the callback fires immediately. It does both prints fine, but the receiptInfo prints nil.

However when I test purchases (in Studio) I get all the popups and confirmations from Roblox, but the callback never fires.

How do you test dev products in studio if the callback will not fire?

That instantly calls the function, you probably meant to do MarketplaceService.ProcessReceipt = GamePassService.ProcessReceipt, although you would be missing the self argument.

So you will need something like

MarketplaceService.ProcessReceipt = function(receiptInfo: { [string]: any })
    return GamePassService:ProcessReceipt(receiptInfo)
end
2 Likes

can you explain the part with (receiptInfo: { [string]: any })

MarketplaceService.ProcessReceipt = function(receiptInfo: { [string]: any })
    return GamePassService:ProcessReceipt(receiptInfo)
end

I’m just using type annotations – since the receipt info is just a dictionary with string keys with arbitrary values of different types. I am just being explicit about it

1 Like

so the code i just put in my script looks like this then

MarketplaceService.ProcessReceipt = function()
    return GamePassService:ProcessReceipt(receiptInfo)
end

would that be right?

if my method, GamePassService:ProcessReceipt returns the proper enums at the end of the function, will this work properly?

You need it as a parameter in the closure

MarketplaceService.ProcessReceipt = function(receiptInfo)
    return GamePassService:ProcessReceipt(receiptInfo)
end

otherwise where did it come from

1 Like

good point, when i read through the roblox code on the wiki they didn’t even have aguements:

MarketplaceService.ProcessReceipt = processReceipt

Guess it just confused me on how to make this work in Knit framewokr because except for this case, none of my code is structured in that way

That is setting ProcessReceipt to the function itself, when you do a = b() you aren’t setting a to the function b itself you are setting it to what it returns.

local function b() return 1 end
local a = b()
print(a) -- 1
local c = b
print(c) -- function: XXX
1 Like

learn something every day! thanks so much!!!