Server Side Purchase Validation

Hello!

Sorry for the message, I hope I’m not making a duplicate topic.
I’m currently implementing in app purchase verification inside a golang module.
I used a plugin for the IOS part, without any problems. https://github.com/awa/go-iap -> link to it.

Then when I tried to use the Android part, things started to become tricky. I used the sample with dummy values. No problem for compiling with Docker, but docker-compose up is throwing me errors when nakama try to load the golang module. Because it’s said the cause is different version of package, I checked the setup, I am using Golang 1.13 (tried updating to 1.14), Nakama 2.7.0, nakama-common 1.0.0
I also tried without the package, by using directly with google functions, but the same error is thrown right now.

So just by using this line : conf, err := google.JWTConfigFromJSON(byte(jsonKey), “https://www.googleapis.com/auth/androidpublisher”) and importing : “golang.org/x/oauth2/google”, I got the same error from docker. Do you have any idea of the possible mismatch here?

Thank in advance for the answer.

Remi

PS : here is the docker error

"msg":"Could not open Go module","path":"/nakama/data/modules/baccarat.so","error":"plugin.Open(\"/nakama/data/modules/baccarat\"): plugin was built with a different version of package golang.org/x/net/context/ctxhttp","stacktrace":"github.com/heroiclabs/nakama/v2/server.openGoModule\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime_go.go:1899\ngithub.com/heroiclabs/nakama/v2/server.NewRuntimeProviderGo\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime_go.go:1823\ngithub.com/heroiclabs/nakama/v2/server.NewRuntime\n\tgithub.com/heroiclabs/nakama/v2@/server/runtime.go:442\nmain.main\n\tmain.go:130\nruntime.main\n\truntime/proc.go:203"}

This indicates your plugin is importing a version of x/net that’s different to the one Nakama is compiled with. Go plugins require that all dependencies exactly match between the plugin and the application it’s loaded into.

Ensure your go.mod file and vendored dependencies match the versions your Nakama release is built with.

Thanks a lot for your answer.

To test more easily, I have disabled the external plugin, trying to use only Google functions for this time.
By modifying my go.mod as you said, I’ve been able to pass through the net/context/ctxhttp error, and also github.com/golang/protobuf who came after. I found the good version to import by looking to go.mod file of the my current version of nakama (2.7.0) -> https://github.com/heroiclabs/nakama/blob/d5e0b5bb9df6c58c2cdbc91a00fbfdf8e12cc6f1/go.mod

I don’t know if it’s the correct workaround to ensure that dependencies are matching.

The problem is I still got the same error, but this time for golang.org/x/oauth2/internal, and this time this one is not listed in nakama go.mod.
Am I missing something to check the dependencies?

There are a number of transitive dependencies that are not explicitly listed in the go.mod file. Check Nakama’s vendor/modules.txt at the tag for your release for a full list of everything the server is built with.

You don’t need to match absolutely everything if it doesn’t appear at all in your plugin (or if your plugin uses dependencies Nakama does not) but where your plugin’s dependencies overlap with Nakama’s the versions must match exactly.

Thanks a lot for the answer, it took sometime, but I was able to make all the dependencies version to match.