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

Unity IAP 4.12.2 Multiple purchase #8

Open
AlexTr17 opened this issue Sep 29, 2024 · 0 comments
Open

Unity IAP 4.12.2 Multiple purchase #8

AlexTr17 opened this issue Sep 29, 2024 · 0 comments

Comments

@AlexTr17
Copy link

Hello, I want to know how to make multiple purchases from play store in 4.12.2 iap version. I found a tutorial with option of multiple purchases, but there was a 4.7.0 version. Here is a sample of code which I use.

 public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
        {
            var product = purchaseEvent.purchasedProduct;
            var receipt = product.receipt;
            var data = JsonUtility.FromJson<Data>(receipt);
            var payload = JsonUtility.FromJson<Payload>(data.Payload);
            var productConfig = Products[purchaseEvent.purchasedProduct.definition.id];
            OnProcessPurchase?.Invoke(productConfig.definition.id, payload.payloadData.quantity);
            return PurchaseProcessingResult.Complete; 
        }

Classes which I get from json

 [Serializable]
    public class SkuDetails
    {
        public string productId;
        public string type;
        public string title;
        public string name;
        public string iconUrl;
        public string description;
        public string price;
        public string price_amount_micros;
        public string price_currency_code;
        public string skuDetailsToken;
    }
    [Serializable]
    public class PayloadData
    {
        public string orderId;
        public string packageName;
        public string productId;
        public long purchaseTime;
        public int purchaseState;
        public string purchaseToken;
        public int quantity;
        public bool acknowledged;
    }

    [Serializable]
    public class Payload
    {
        public string json;
        public string signature;
        public List<SkuDetails> skuDetails;
        public PayloadData payloadData;
    }


    [Serializable]
    public class Data
    {
        public string Store;
        public string Payload;
        public string TransactionID;
    }
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

1 participant