Exemple #1
0
 private Action <Error> GetErrorCallback(Action <Error> onError)
 {
     return(error =>
     {
         StoreDemoPopup.ShowError(error);
         onError?.Invoke(error);
     });
 }
 private void ShowTransactionErrorMessage()
 {
     StoreDemoPopup.ShowError(new Error
     {
         errorMessage =
             "Some transactions you've made recently were not finished. " +
             "Please, contact the support team."
     }).SetTitle("");
 }
 private void InitPurchases()
 {
     LoadTransactions();
     // Check status for all loaded transactions
     GetAllTransactions().ForEach(t =>
     {
         var timeoutCoroutine = CheckOldTransaction(t);
         HandleTransaction(t, timeoutCoroutine, catalogItem => StoreDemoPopup.ShowSuccess());
     });
 }
 public void ConsumeInventoryItem(InventoryItemModel item, uint count, Action <InventoryItemModel> onSuccess,
                                  Action <InventoryItemModel> onFailed = null)
 {
     StoreDemoPopup.ConsumeConfirmation(item.Name, count, () =>
     {
         StoreDemoPopup.ShowSuccess();
         RemoveItemFromInventory(item, count);
         onSuccess?.Invoke(item);
     }, () => onFailed?.Invoke(item));
 }
Exemple #5
0
 public void PurchaseForVirtualCurrency(CatalogItemModel item,
                                        [CanBeNull] Action <CatalogItemModel> onSuccess = null, [CanBeNull] Action <Error> onError = null)
 {
     StoreDemoPopup.ShowConfirm(() =>
                                PurchaseHelper.Instance.PurchasePlayfabItemForVirtualCurrency(item, purchasedItem =>
     {
         StartCoroutine(VirtualCurrencyPurchaseFinished(purchasedItem));
         StoreDemoPopup.ShowSuccess($"You have purchased `{purchasedItem.Name}`!");
         onSuccess?.Invoke(item);
     }, GetErrorCallback(onError)));
 }
Exemple #6
0
 public void PurchaseForRealMoney(CatalogItemModel item, [CanBeNull] Action <CatalogItemModel> onSuccess = null,
                                  [CanBeNull] Action <Error> onError = null)
 {
     PurchaseHelper.Instance.PurchasePlayfabItemForRealMoney(item, _ =>
     {
         UserInventory.Instance.Refresh();
         StoreDemoPopup.ShowSuccess();
         Destroy(BrowserHelper.Instance);
         onSuccess?.Invoke(item);
     }, GetErrorCallback(onError));
 }
Exemple #7
0
 public void ConsumeInventoryItem(InventoryItemModel item, uint count,
                                  [NotNull] Action <InventoryItemModel> onSuccess,
                                  [CanBeNull] Action <InventoryItemModel> onFailed = null)
 {
     StoreDemoPopup.ConsumeConfirmation(item.Name, count, () => {
         PlayfabApi.Inventory.ConsumeItem(item.InstanceId, count, () =>
         {
             StoreDemoPopup.ShowSuccess();
             onSuccess?.Invoke(item);
         }, GetErrorCallback(_ => onFailed?.Invoke(item)));
     },
                                        () => onFailed?.Invoke(item)
                                        );
 }
        public void PurchaseForRealMoney(CatalogItemModel item, [CanBeNull] Action <CatalogItemModel> onSuccess = null,
                                         [CanBeNull] Action <Error> onError = null)
        {
            var transaction = CreateTransaction(item);
            var accessData  = CreateAccessData(XsollaSettings.SimplifiedProjectId, transaction.transactionId, item);

            Payments.PaymentsHelper.OpenPurchaseByAccessData(accessData, XsollaSettings.IsSandbox);
            var timeoutCoroutine = FailedTransactionNotification(transaction);

            HandleTransaction(transaction, timeoutCoroutine, catalogItem =>
            {
                StoreDemoPopup.ShowSuccess();
                Destroy(BrowserHelper.Instance);
                onSuccess?.Invoke(catalogItem);
            }, onError);
        }