public void OnPurchaseSucceeded(Purchase purchase)
    {
        if (AudioManager.instance.sfxEnabled) this.GetComponent<AudioSource>().Play();

        Debug.Log("OnPurchaseSucceeded");
        OpenIAB.consumeProduct(purchase);

        ValidateGooglePlayPurchaseRequest request = new ValidateGooglePlayPurchaseRequest();
        request.ReceiptJson = purchase.OriginalJson;
        request.Signature = purchase.Signature;
        PlayFabClientAPI.ValidateGooglePlayPurchase(request, OnValidateCompleted, OnValidateError);

		// calling this before validation?
        UpdateUserDataRequest dataRequest = new UpdateUserDataRequest();
        dataRequest.Data = new Dictionary<string, string>();
        dataRequest.Data.Add(GameConstants.boughtSheKey, "true");
        dataRequest.Permission = UserDataPermission.Public;
        PlayFabClientAPI.UpdateUserData(dataRequest, OnDataUpdateCompleted, OnDataUpdateError);

        AccountManager.instance.BuyShe();
    }
Пример #2
0
		/// <summary>
		/// Validates a Google Play purchase and gives the corresponding item to the player.
		/// </summary>
		public static void ValidateGooglePlayPurchase(ValidateGooglePlayPurchaseRequest request, ValidateGooglePlayPurchaseCallback resultCallback, ErrorCallback errorCallback)
		{
			if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

			string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
			Action<string,string> callback = delegate(string responseStr, string errorStr)
			{
				ValidateGooglePlayPurchaseResult result = null;
				PlayFabError error = null;
				ResultContainer<ValidateGooglePlayPurchaseResult>.HandleResults(responseStr, errorStr, out result, out error);
				if(error != null && errorCallback != null)
				{
					errorCallback(error);
				}
				if(result != null)
				{
					
					if(resultCallback != null)
					{
						resultCallback(result);
					}
				}
			};
			PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/ValidateGooglePlayPurchase", serializedJSON, "X-Authorization", AuthKey, callback);
		}
        /// <summary>
        /// Validates a Google Play purchase and gives the corresponding item to the player.
        /// </summary>
        public static void ValidateGooglePlayPurchase(ValidateGooglePlayPurchaseRequest request, ProcessApiCallback<ValidateGooglePlayPurchaseResult> resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (_authKey == null) throw new Exception("Must be logged in to call this method");

            string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy);
            Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                ResultContainer<ValidateGooglePlayPurchaseResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/ValidateGooglePlayPurchase", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }
Пример #4
0
		/// <summary>
		/// Validates a Google Play purchase and gives the corresponding item to the player.
		/// </summary>
        public static async Task<PlayFabResult<ValidateGooglePlayPurchaseResult>> ValidateGooglePlayPurchaseAsync(ValidateGooglePlayPurchaseRequest request)
        {
            if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

            object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/ValidateGooglePlayPurchase", request, "X-Authorization", AuthKey);
            if(httpResult is PlayFabError)
            {
                PlayFabError error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                    PlayFabSettings.GlobalErrorHandler(error);
                return new PlayFabResult<ValidateGooglePlayPurchaseResult>
                {
                    Error = error,
                };
            }
            string resultRawJson = (string)httpResult;

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<ValidateGooglePlayPurchaseResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			ValidateGooglePlayPurchaseResult result = resultData.data;
			
			
            return new PlayFabResult<ValidateGooglePlayPurchaseResult>
                {
                    Result = result
                };
        }