/// <summary> /// Retrieves a completed purchase along with its current PlayFab status. /// </summary> public static async Task<PlayFabResult<GetPurchaseResult>> GetPurchaseAsync(GetPurchaseRequest request) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetPurchase", request, "X-Authorization", AuthKey); if(httpResult is PlayFabError) { PlayFabError error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) PlayFabSettings.GlobalErrorHandler(error); return new PlayFabResult<GetPurchaseResult> { Error = error, }; } string resultRawJson = (string)httpResult; var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetPurchaseResult>>(new JsonTextReader(new StringReader(resultRawJson))); GetPurchaseResult result = resultData.data; return new PlayFabResult<GetPurchaseResult> { Result = result }; }
/// <summary> /// Retrieves a completed purchase along with its current PlayFab status. /// </summary> public static void GetPurchase(GetPurchaseRequest request, ProcessApiCallback<GetPurchaseResult> 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<GetPurchaseResult>.HandleResults(requestContainer, resultCallback, errorCallback, null); }; PlayFabHTTP.Post("/Client/GetPurchase", serializedJson, "X-Authorization", _authKey, callback, request, customData); }
/// <summary> /// Retrieves a completed purchase along with its current PlayFab status. /// </summary> public static void GetPurchase(GetPurchaseRequest request, GetPurchaseCallback resultCallback, ErrorCallback errorCallback, object customData = null) { 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,PlayFabError> callback = delegate(string responseStr, PlayFabError pfError) { GetPurchaseResult result = null; ResultContainer<GetPurchaseResult>.HandleResults(responseStr, ref pfError, out result); if(pfError != null && errorCallback != null) { errorCallback(pfError); } if(result != null) { result.CustomData = customData; result.Request = request; if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/GetPurchase", serializedJSON, "X-Authorization", AuthKey, callback); }