S
S
Suren2018-11-01 12:54:47
C++ / C#
Suren, 2018-11-01 12:54:47

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();
        }
    }
}

So, when debugging the Token Debug.Log("TOKEN : " + args.purchasedProduct.receipt); - this is the TOKEN thing: {"Store":"fake","TransactionID":"6b3c54ef-1893-4b65-848d-b5a05c785da5","Payload":"{ \"this\" : \"is a fake receipt \" }"}
When debugging in Visual Studio, I get Null 5bdacd5ac8ba1537822829.png
What to do, help plz)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question