suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
49 stars 11 forks source link

Cash shop issue #2349

Closed Callepo closed 5 months ago

Callepo commented 6 months ago

The HandleRequestCashPackageBuyValidation has a bug i think.

image

The isupdatingItems in the other methods when its sending response to client all have it to false.. But this one is being set to true..

and i am checking this becuase when you buy cash ingame, you dont get the cash, and when u try to buy 2nd time, it tells u service not available.. Which is literally this image

insthync commented 6 months ago

Fixed

Callepo commented 6 months ago

Fixed

was my change the fix? tried looking at commits, but dont see it yet in there

Callepo commented 6 months ago

@insthync ?

insthync commented 6 months ago

https://github.com/suriyun-mmorpg/UnityMultiplayerARPG_MMO/commit/0e6339710a119432f0b0e686dd88342a2be1e5e6

Callepo commented 6 months ago

hmm, even with that change, we still got the error when purchasing First this one image

And then it says service not available.. But the thing we trying to purchase is a consumable, not subscription, so we should be able to buy it multiple times

insthync commented 6 months ago

Why service not available still occuring, is there any error in server log?

insthync commented 6 months ago

The already own thing might be a message from Google Play, so I can't know why, maybe you should try ask Google Play

Callepo commented 6 months ago

image I see this.

But this is in Server Logs as Warning

Callepo commented 6 months ago

image

image

Well i guess ill start here

insthync commented 6 months ago

Hmm, seems like I have to change its implementation, a new one will connects to external web-service, which uses https://github.com/voltrue2/in-app-purchase, also plan to store purchasing log to database by the web-service.

Callepo commented 6 months ago

Hmm, seems like I have to change its implementation, a new one will connects to external web-service, which uses https://github.com/voltrue2/in-app-purchase, also plan to store purchasing log to database by the web-service.

that would be great yea. If it can log product bought with Cash would be cool too, aka when someone uses their cash to buy something in the shop, it records what they bought, so you have prove of them spending the cash.

Im also looking into making a General Logger for the game, like Dealings, Login , log out, location from login etc But im doing this on my own

Callepo commented 6 months ago

@insthync After fixing the IAP Bug server side This is what we get now.. image

Client sends request to google to purchase cash.. W8's for response.. doesnt get it fast enough and times out.. SO when the response do come later on, its not processed, cuase its not listening anymore.. SO, server never processes the receipt, and u never get cash .. then the whole cash shop is bugged, u cant do anything anymore.. image

It Took 2 minutes for order to be processed.. Client Timed out long ago.. Cuase the Client didnt get the receipt, google refunds all purchases.

And then anything u try to do in the shop you get this.. image

Client shouldnt be responsible for processing this.. Server should be or an API.. Cuase it should keep listening for the response.. and not time out cuase it took longet than 10 seconds..

And what if my client crashes before i get my receipt?

The whole process is bad. I didnt find a single person who managed to get IAP working properly in the community.. Everyone using their own external API to purchase cash.. and just update the KIT DB cash on the account..

insthync commented 6 months ago

How did you fix it? just apply my commit? If yes, then why it will fix issues because the issues are from DefaultIAPReceiptValidator which uses Unity's IAP system to validate receipts but it is not working on the current version, so I have to change the receipt validation.

Callepo commented 6 months ago

How did you fix it? just apply my commit? If yes, then why it will fix issues because the issues are from DefaultIAPReceiptValidator which uses Unity's IAP system to validate receipts but it is not working on the current version, so I have to change the receipt validation.

I did not say it will fix the issue, im saying After applying the Server side Bug fix, its still not working because of others reasons, being the Receipt, i didnt even know the DefaultIAPReceiptValidator wasnt working on current version, i figured that out based on Testing and debugging.

But we know now its not working cuase im testing it

insthync commented 6 months ago

Ahh, I see, so it won't have anything fixed yet.

Callepo commented 6 months ago

When u change something to it, let me know pls, so i can test it out. thank you <3

Callepo commented 6 months ago

@insthync image

More Crash Logs from IAP

insthync commented 6 months ago

As I said issues are from DefaultIAPReceiptValidator, that error are from that component, if you want to fix it by yourself just try to validate the receipt, if you can't do it, then just wait for me to do it.

shubhank008 commented 6 months ago

@insthync image

More Crash Logs from IAP

The GooglePlayTangle.Data() error used to happen if you did not setup/use obfuscated keys for google play store https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html. Although a stupid question, are your google play keys correct setup and obfuscated ?

Also, as Suri mentioned, Unity's IAP is a bit insecure as its client-side validation and they themselves refer/link to https://github.com/voltrue2/in-app-purchase for server side validation (cause they donot provide it). But this package hasnt been updated in years and nodejs based.

It might be worth the effort to create our own server-side validation using direct GooglePlay/Apple APIs.

@Callepo can you try to run the unityIAPReceipt through this https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/get manually (browser/reqbin) ? If it works, I can help implement server-side validation using REST API (server->Google/Apple).
Relevant info I found for above approach. https://stackoverflow.com/a/54658639

insthync commented 6 months ago

@shubhank008 Seems like Unity's IAP validation won't work on standalone platforms anymore, so DefaultIAPReceiptValidator won't work anymore.

So I am just telling you guys to try to create your own validating component by implements IIAPReceiptValidator interface, it may connect to the external web-service which may being developed by NodeJS with https://github.com/voltrue2/in-app-purchase for server-side validation, the https://github.com/voltrue2/in-app-purchase still fine.

But if you guys want to implement it by yourself then go ahead it is fine too, Or if you are going to use Google's API for validation by yourself at map-server (like as I did to DefaultIAPReceiptValidator but this one is using Unity's IAP and currently not working) then it is okay too, might have to find JWT, base 64 decoding (and so on) libraries to implements it, I have an example to implements it: here.

What I've planned to do is: I will create a new component which implements IIAPReceiptValidator interface, which when it is going to validate, it (map-server) will connect to web-service with receipt/user data to validate, if it is valid then it will store billing history to database and send success message to map-server to increase player's currencies, so I have to develop web-service for the validating too.

But I actually recommend you guys to create your own IAP system including product listing UIs (at client) because the built-in one was planned to make it work for both Offline and MMO games projects and it is hard to update product data, which you have to do it in Unity then build then upload.

Callepo commented 6 months ago

Atm i just need the simplest and easiest one that works for now, and than i can take the time to check for any alternatives. Just need whats currently in kit to work for now cuase its a bit urgent, all the extra stuff i can do later or w8 how ever long idm.

" Seems like Unity's IAP validation won't work on standalone platforms anymore, so DefaultIAPReceiptValidator won't work anymore." Also not using standalone platforms, its all Mobile builds

Callepo commented 6 months ago

As I said issues are from DefaultIAPReceiptValidator, that error are from that component, if you want to fix it by yourself just try to validate the receipt, if you can't do it, then just wait for me to do it.

i wasn't rushing you, u asked me for logs before, and i found logs so i shared it with you. Simply did what u asked. :)

112

insthync commented 6 months ago

Atm i just need the simplest and easiest one that works for now, and than i can take the time to check for any alternatives. Just need whats currently in kit to work for now cuase its a bit urgent, all the extra stuff i can do later or w8 how ever long idm.

" Seems like Unity's IAP validation won't work on standalone platforms anymore, so DefaultIAPReceiptValidator won't work anymore." Also not using standalone platforms, its all Mobile builds

I mean receipt validating by server, server builds are standalone platforms.

insthync commented 6 months ago

As I said issues are from DefaultIAPReceiptValidator, that error are from that component, if you want to fix it by yourself just try to validate the receipt, if you can't do it, then just wait for me to do it.

i wasn't rushing you, u asked me for logs before, and i found logs so i shared it with you. Simply did what u asked. :)

112

It should not warn service is not available by logs you've shown me, because playerCharacterEntity.IsUpdatingItems should set to false so next request should not warn that message

insthync commented 6 months ago

@Callepo Where can I find this history

I can't find it in Google Play Console, and as I try I can't find "you already own this item" problems.

insthync commented 6 months ago

292661729-f4134d38-a4d6-42de-9dcf-23cc9c0a66ca

This history

insthync commented 6 months ago

The service is done, tested, work as intended

https://github.com/suriyun-mmorpg/mmorpg-kit-iap-validation-service

shubhank008 commented 6 months ago

The service is done, tested, work as intended

https://github.com/suriyun-mmorpg/mmorpg-kit-iap-validation-service

Repo seems private, cannot access it

insthync commented 6 months ago

Okay, changed it to be public

Callepo commented 6 months ago

292661729-f4134d38-a4d6-42de-9dcf-23cc9c0a66ca

This history

image

Callepo commented 6 months ago

@insthync is it supposed to add cash to account even when doing sandbox mode for testing? Or only in live mode? Service is receiving receipt, ingame showing no errors everything fine, Log added to Db but the Status is 0 and Acknowledged is false.

Its not failing anymore and Refunding all the purchases.

Everything seems fine, just Status 0 and cash not added.

image

image

image

image

insthync commented 6 months ago

Should be added while it is in test mode, I did internal test.

insthync commented 6 months ago

Status 0 is success.

Callepo commented 6 months ago

yea im looking through code now saw this image

so figured 0 is good.. but no cash added to the player

Callepo commented 6 months ago

image Started with this amount, before purchasing.

it should have added all those amounts, but its stays the same image

Callepo commented 6 months ago

Should be added while it is in test mode, I did internal test.

We are also doing the same, Internal Testing

insthync commented 6 months ago

Try latest commit of MMO repo

Callepo commented 6 months ago

Try latest commit of MMO repo RESTIAPReceiptValidator Error image

Shouldnt it be image

Like image

Becuase this was removed image

insthync commented 6 months ago

Pushed

Callepo commented 6 months ago

@insthync image

image

Still same 1300 cash image

:(

There is literally 0 errors anywhere.. everything is passing and validating, the last piece just doesnt wanna work lol .. wtf This look good? I have the Cash amount set as 2000 or it needs to be somewhere else? cuase seems like its not getting the amount properly image

insthync commented 6 months ago

Try to debug amount of ChangeCash

Callepo commented 6 months ago

Try to debug amount of ChangeCash

XD image

Literally what i was doing, uploading build etc to try and buy again

Callepo commented 6 months ago

nothing showed up in log files or console feel like it should have. i changed debug logs to logger to be sure image

making new build now and testing again.

Callepo commented 6 months ago

@insthync im retarded.. i have 2 Server build folders 1 for SEA Region and 1 for EU Region.. i did the changes in the project, made a build in the SEA folder And kept uploading EU build to the EU server, so none of the changes were added.. I uploaded the correct build now and it works .. FML..

Sorry

insthync commented 6 months ago

Nice

Callepo commented 6 months ago

Nice

image

Callepo commented 6 months ago

But yea ur latest commit 100% fixed it. its showing instantly now

LordPhrozen commented 6 months ago

Glad to see this fixed :) Thanks from my side as well to both of you!

tubhluas commented 4 months ago

The service is done, tested, work as intended

https://github.com/suriyun-mmorpg/mmorpg-kit-iap-validation-service

do i have to use this above package for this fixed to take effect?

insthync commented 4 months ago

@tubhluas Yes