Critical bug found in game atm. When players buy something from the Google Store, and they cancel the payment or the payment pruchase takes a long time. They can still validate the purchase as successful and they get rewarded.
Solution? The seenBefore function is just not enough. It needs to validate the purchase as well.
validateResponse, err := nk.PurchaseValidateGoogle(ctx, *userId, data, true)
for _, response := range validateResponse.GetValidatedPurchases() {
transaction, err := nk.PurchaseGetByTransactionId(ctx, response.TransactionId)
if transaction.SeenBefore {
//error
}
//Reward player
}
The problem is that, there is no functions exposing if the transaction was successfull or not. When I debug this with my own phone, (payment slow) and call the validation before the payment has been approved, it still validates it as successful somehow?
I have done plenty of workarounds and safeguards now, but there is still some loopholes that could be used if found.