private void DoBuyProduct(StoreBuyProductParams buyParams, Action <BackendResult <StoreBuyProductResult, ResultCode> > successCallback, Action <BackendResult <StorePurchaseResult, ResultCode> > errorCallback) { Dictionary <string, string> parameters = new Dictionary <string, string>() { { "type", buyParams.ProductType.ToString() }, { "product_id", buyParams.ProductId.ToString() }, { "guid", buyParams.RandomId.ToString() }, { "privacy", ((int)buyParams.Privacy).ToString() } }; if (buyParams.UserIds != null) { parameters["user_ids"] = string.Join <long>(",", (IEnumerable <long>)buyParams.UserIds); } if (!string.IsNullOrEmpty(buyParams.Message)) { parameters["message"] = buyParams.Message; } if (AppGlobalStateManager.Current.GlobalState.PaymentType == AccountPaymentType.money) { parameters["no_inapp"] = "1"; } if (!string.IsNullOrEmpty(buyParams.StickerReferrer)) { parameters["sticker_referrer"] = buyParams.StickerReferrer; } VKRequestsDispatcher.DispatchRequestToVK <StoreBuyProductResult>("store.buyProduct", parameters, (Action <BackendResult <StoreBuyProductResult, ResultCode> >)(result => { if (result.ResultCode == ResultCode.Succeeded) { Action <BackendResult <StoreBuyProductResult, ResultCode> > action = successCallback; if (action == null) { return; } BackendResult <StoreBuyProductResult, ResultCode> backendResult = result; action(backendResult); } else { Action <BackendResult <StorePurchaseResult, ResultCode> > action = errorCallback; if (action == null) { return; } BackendResult <StorePurchaseResult, ResultCode> backendResult = new BackendResult <StorePurchaseResult, ResultCode>(result.ResultCode, StorePurchaseResult.GetForFailedPurchaseState()); action(backendResult); } }), null, false, true, new CancellationToken?(), (Action)(() => EventAggregator.Current.Publish(new StickersPurchaseFunnelEvent(StickersPurchaseFunnelAction.purchase_window)))); }
private void PurchaseVotesPackWithInApps(VotesPack votesPack, Action successCallback, Action <BackendResult <StorePurchaseResult, ResultCode> > errorCallback, Action cancelledCallback) { InAppPurchaseService.RequestProductPurchase(votesPack.MerchantProductId, (Action <InAppProductPurchaseResult>)(purchaseResult => { switch (purchaseResult.Status) { case InAppProductPurchaseStatus.Cancelled: Action action1 = cancelledCallback; if (action1 == null) { break; } action1(); break; case InAppProductPurchaseStatus.Purchased: this.FulfillPurchases(votesPack.MerchantProductId, successCallback, errorCallback); break; case InAppProductPurchaseStatus.Error: Action <BackendResult <StorePurchaseResult, ResultCode> > action2 = errorCallback; if (action2 == null) { break; } BackendResult <StorePurchaseResult, ResultCode> backendResult = new BackendResult <StorePurchaseResult, ResultCode>(ResultCode.Succeeded, StorePurchaseResult.GetForFailedPurchaseState()); action2(backendResult); break; } })); }