Пример #1
0
        /// <summary>
        /// Sync (Verify and fulfil) item entitlement from Apple Store platform purchase.
        /// </summary>
        /// <param name="syncRequest"> That contain of ProductId, TransactionId, ReceiptData, and ExcludeOldTransactions to verify and sync item user bought from Apple Store. </param>
        /// <param name="callback"> Returns a Result via callback when completed</param>
        public void SyncMobilePlatformPurchaseApple(PlatformSyncMobileApple syncRequest, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            if (!this.session.IsValid())
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);

                return;
            }

            this.coroutineRunner.Run(
                this.api.SyncMobilePlatformPurchaseApple(
                    this.@namespace,
                    this.session.UserId,
                    this.session.AuthorizationToken,
                    syncRequest,
                    callback
                    ));
        }
Пример #2
0
        public IEnumerator SyncMobilePlatformPurchaseApple(string @namespace, string userId, string userAccessToken, PlatformSyncMobileApple 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/apple/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);
        }