Beispiel #1
0
        /// <summary>
        /// Sync (Verify and fulfil) item entitlement from Google Play platform purchase.
        /// </summary>
        /// <param name="syncRequest"> That contain of OrderId, PackageName, ProductId, PurchaseTime, and PurchaseToken to verify and sync item user bought from Google Play.</param>
        /// <param name="callback"> Returns a Result via callback when completed</param>
        public void SyncMobilePlatformPurchaseGoogle(PlatformSyncMobileGoogle syncRequest, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            if (!this.session.IsValid())
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);

                return;
            }

            this.coroutineRunner.Run(
                this.api.SyncMobilePlatformPurchaseGoogle(
                    this.@namespace,
                    this.session.UserId,
                    this.session.AuthorizationToken,
                    syncRequest,
                    callback
                    ));
        }
Beispiel #2
0
        public IEnumerator SyncMobilePlatformPurchaseGoogle(string @namespace, string userId, string userAccessToken, PlatformSyncMobileGoogle syncRequest, ResultCallback callback)
        {
            Assert.IsNotNull(@namespace, "Can't update distribution receiver! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't update distribution receiver! UserId parameter is null!");

            var request = HttpRequestBuilder
                          .CreatePut(this.baseUrl + "/public/namespaces/{namespace}/users/{userId}/iap/google/receipt")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(syncRequest.ToUtf8Json())
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParse();

            callback.Try(result);
        }