Answer the question
In order to leave comments, you need to log in
Google APP and Validation. Fake token?
I'm trying to validate purchases from Google.
Received Json with the Google API, threw the user into the Google console to be responsible for purchases.
Move on. I made a purchase script, the purchases themselves work, everything is fine. But I need to send the Token and Id of the Google product to a server, where it will check the whole thing and if everything is clear (correct), charge the currency.
The script is next.
public class ReceiptFull
{
public string store;
public string transactionId;
public string payload;
}
public class ReceiptGooglePlay
{
public string json;
public string signature;
}
public class PurchaseToken
{
public string orderId;
public string packageName;
public string productId;
public string purchaseTime;
public string purchaseState;
public string purchaseToken;
}
public class HardShopeController : MonoBehaviour
{
private HardCurrencyController hardCurrencyController;
[SerializeField]
PurchaseManager purchaseManager;
private void Awake()
{
hardCurrencyController = FindObjectOfType<HardCurrencyController>();
}
private void Start()
{
PurchaseManager.OnPurchaseConsumable += PurchaseManager_OnPurchaseConsumable;
}
private void PurchaseManager_OnPurchaseConsumable(PurchaseEventArgs args)
{
Debug.Log("SUCSED BUY");
StartCoroutine(BuyHardCurrencyCor(args));
}
//private void BuyHardCurrency(PurchaseEventArgs args)
//{
// StartCoroutine(BuyHardCurrencyCor(token, productId));
//}
private IEnumerator BuyHardCurrencyCor(PurchaseEventArgs args)
{
ReceiptFull receiptFull = JsonConvert.DeserializeObject<ReceiptFull>(args.purchasedProduct.receipt);
Debug.Log("TOKEN : " + args.purchasedProduct.receipt);
ReceiptGooglePlay receiptGooglePlay = JsonConvert.DeserializeObject<ReceiptGooglePlay>(receiptFull.payload);
PurchaseToken tokenFull = JsonConvert.DeserializeObject<PurchaseToken>(receiptGooglePlay.json);
string token = tokenFull.purchaseToken;
Debug.Log("token: " + token);
string argsId = args.purchasedProduct.definition.id;
var responce = ServerAPI.Billing.BuyProduct(token, argsId);
yield return StartCoroutine(responce.WaitUntilComplete());
if(responce.Data != null)
{
hardCurrencyController.ShoweVisualHardCurrencyOnServer();
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question