Пример #1
0
        //the actual method constructing the web request for validation
        private void WaitForRequest(Product p)
        {
            #pragma warning disable 0219
            Hashtable hash    = SIS.MiniJson.JsonDecode(p.receipt) as Hashtable;
            string    receipt = string.Empty;
            #pragma warning restore 0219

            #if UNITY_ANDROID
            string signature = string.Empty;
            switch (StandardPurchasingModule.Instance().androidStore)
            {
            case AndroidStore.GooglePlay:
                hash      = SIS.MiniJson.JsonDecode(hash["Payload"] as string) as Hashtable;
                receipt   = hash["json"] as string;
                signature = hash["signature"] as string;

                ValidateGooglePlayPurchaseRequest gRequest = new ValidateGooglePlayPurchaseRequest()
                {
                    ReceiptJson   = receipt,
                    Signature     = signature,
                    CurrencyCode  = p.metadata.isoCurrencyCode,
                    PurchasePrice = (uint)(p.metadata.localizedPrice * 100)
                };

                PlayFabClientAPI.ValidateGooglePlayPurchase(gRequest, OnValidationResult, OnValidationError, p.definition.storeSpecificId);
                break;

            case AndroidStore.AmazonAppStore:
                ValidateAmazonReceiptRequest aRequest = new ValidateAmazonReceiptRequest()
                {
                    ReceiptId     = p.receipt,
                    UserId        = IAPManager.extensions.GetExtension <IAmazonExtensions>().amazonUserId,
                    CurrencyCode  = p.metadata.isoCurrencyCode,
                    PurchasePrice = (int)(p.metadata.localizedPrice * 100)
                };
                PlayFabClientAPI.ValidateAmazonIAPReceipt(aRequest, OnValidationResult, OnValidationError, p.definition.storeSpecificId);
                break;
            }
            #elif UNITY_IOS || UNITY_TVOS
            receipt = hash["Payload"] as string;

            ValidateIOSReceiptRequest request = new ValidateIOSReceiptRequest()
            {
                ReceiptData   = receipt,
                CurrencyCode  = p.metadata.isoCurrencyCode,
                PurchasePrice = (int)(p.metadata.localizedPrice * 100)
            };
            PlayFabClientAPI.ValidateIOSReceipt(request, OnValidationResult, OnValidationError, p.definition.storeSpecificId);
            #endif
        }
Пример #2
0
 public static IEnumerator <ValidateAmazonReceiptResult> Do(ValidateAmazonReceiptRequest request)
 {
     return(Do <ValidateAmazonReceiptRequest, ValidateAmazonReceiptResult>(request, PlayFabClientAPI.ValidateAmazonIAPReceipt));
 }
 public UnityTask <ValidateAmazonReceiptResult> Do(ValidateAmazonReceiptRequest request)
 {
     return(this.Do <ValidateAmazonReceiptRequest, ValidateAmazonReceiptResult>(request, PlayFabClientAPI.ValidateAmazonIAPReceiptAsync));
 }