Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cash shop issue #2349

Closed
Callepo opened this issue Dec 21, 2023 · 50 comments
Closed

Cash shop issue #2349

Callepo opened this issue Dec 21, 2023 · 50 comments

Comments

@Callepo
Copy link
Collaborator

Callepo commented Dec 21, 2023

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
Copy link
Member

Fixed

insthync added a commit to suriyun-mmorpg/UnityMultiplayerARPG_MMO that referenced this issue Dec 22, 2023
@Callepo
Copy link
Collaborator Author

Callepo commented Dec 22, 2023

Fixed

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

@Callepo Callepo reopened this Dec 22, 2023
@Callepo Callepo closed this as completed Dec 22, 2023
@Callepo
Copy link
Collaborator Author

Callepo commented Dec 23, 2023

@insthync ?

@insthync
Copy link
Member

@Callepo
Copy link
Collaborator Author

Callepo commented Dec 23, 2023

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
Copy link
Member

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

@insthync
Copy link
Member

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
Copy link
Collaborator Author

Callepo commented Dec 23, 2023

image
I see this.

But this is in Server Logs as Warning

@Callepo
Copy link
Collaborator Author

Callepo commented Dec 23, 2023

image

image

Well i guess ill start here

@insthync
Copy link
Member

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.

@insthync insthync reopened this Dec 23, 2023
@Callepo
Copy link
Collaborator Author

Callepo commented Dec 23, 2023

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
Copy link
Collaborator Author

Callepo commented Dec 24, 2023

@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
Copy link
Member

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
Copy link
Collaborator Author

Callepo commented Dec 24, 2023

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
Copy link
Member

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

@Callepo
Copy link
Collaborator Author

Callepo commented Dec 24, 2023

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

@Callepo
Copy link
Collaborator Author

Callepo commented Dec 24, 2023

@insthync
image

More Crash Logs from IAP

@insthync
Copy link
Member

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
Copy link

@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
Copy link
Member

@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
Copy link
Collaborator Author

Callepo commented Dec 28, 2023

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
Copy link
Collaborator Author

Callepo commented Dec 28, 2023

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

@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
Copy link
Member

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

This history

@insthync
Copy link
Member

The service is done, tested, work as intended

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

@shubhank008
Copy link

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
Copy link
Member

Okay, changed it to be public

@Callepo
Copy link
Collaborator Author

Callepo commented Dec 30, 2023

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

This history

image

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

@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
Copy link
Member

insthync commented Jan 2, 2024

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

@insthync
Copy link
Member

insthync commented Jan 2, 2024

Status 0 is success.

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

yea im looking through code now
saw this
image

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

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

image
Started with this amount, before purchasing.

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

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

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

We are also doing the same, Internal Testing

@insthync
Copy link
Member

insthync commented Jan 2, 2024

Try latest commit of MMO repo

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

Try latest commit of MMO repo
RESTIAPReceiptValidator Error
image

Shouldnt it be
image

Like
image

Becuase this was removed
image

@insthync
Copy link
Member

insthync commented Jan 2, 2024

Pushed

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

@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
Copy link
Member

insthync commented Jan 2, 2024

Try to debug amount of ChangeCash

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

Try to debug amount of ChangeCash

XD
image

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

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

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
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

@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
Copy link
Member

insthync commented Jan 2, 2024

Nice

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

Nice

image

@Callepo
Copy link
Collaborator Author

Callepo commented Jan 2, 2024

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

@LordPhrozen
Copy link

LordPhrozen commented Jan 3, 2024

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

@tubhluas
Copy link

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
Copy link
Member

@tubhluas Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants