public static void RequestForBillingProducts(List <BillingProduct> _productsList) { CheckIfInitialised(); // Remove current products registeredProducts.Clear(); // Create list of registered products with price info int _totalProducts = _productsList.Count; for (int _iter = 0; _iter < _totalProducts; _iter++) { BillingProduct _storeProduct = _productsList[_iter]; BillingProduct _registeredProduct = _storeProduct.Copy(); if (_registeredProduct != null) { _registeredProduct.LocalizedPrice = string.Format("${0:0.00}", _registeredProduct.Price); // Add to store products registeredProducts.Add(_registeredProduct); } } // Callback is sent to binding event listener if (NPBinding.Billing != null) { NPBinding.Billing.InvokeMethod(kRequestForBillingProductsSuccessEvent, registeredProducts); } }
private void addProduct(BillingProduct product, Product queryProduct, TextBox el) { product.Barcode = queryProduct.Barcode; product.Name = queryProduct.Name; product.PrintName = queryProduct.PrintName; product.MRP = int.Parse(queryProduct.MRP); product.Quantity = 1; product.Total = int.Parse(queryProduct.MRP); product.Serial = products.IndexOf(product) + 1; int sum = products.Sum(product => product.Total); int discount = discountText.Text == "" ? 0 : int.Parse(discountText.Text); grandTotalText.Text = formatTotal(sum - discount); invoice.BillingProducts = JsonSerializer.Serialize <List <BillingProduct> >(products); int total = products.Sum(product => product.Quantity); totalItemsText.Text = "Total Items:" + total.ToString(); billTable.CellEditEnding -= billTableCellEditEvent; billTable.CommitEdit(); billTable.CommitEdit(); billTable.Items.Refresh(); billTable.CellEditEnding += billTableCellEditEvent; }
public static void BuyProduct(string _productID) { CheckIfInitialised(); BillingProduct _buyProduct = GetProduct(_productID); if (_buyProduct == null) { OnTransactionFailed(_productID, "The operation could not be completed because given product id information not found."); return; } if (NPBinding.UI != null) { string _message = string.Format("Do you want to buy {0} for {1}?", _buyProduct.Name, _buyProduct.LocalizedPrice); NPBinding.UI.ShowAlertDialogWithMultipleButtons("Confirm your purchase", _message, new string[] { "Cancel", "Buy" }, (string _buttonPressed) => { if (_buttonPressed.Equals("Buy")) { OnConfirmingPurchase(_buyProduct); } else { OnTransactionFailed(_productID, "The operation could not be completed because user cancelled purchase."); } }); } else { Console.LogWarning(Constants.kDebugTag, "[EditorStore] Native UI component is null"); return; } }
private void DoAction() { #if USES_BILLING try { BillingProduct _product = BillingUtils.productsList[atIndex.Value]; // Update properties productIdentifier.Value = _product.ProductIdentifier; name.Value = _product.Name; description.Value = _product.Description; isConsumable.Value = _product.IsConsumable; price.Value = _product.Price; localizedPrice.Value = _product.LocalizedPrice; currencyCode.Value = _product.CurrencyCode; currencySymbol.Value = _product.CurrencySymbol; } catch (System.Exception _exception) { Debug.Log(_exception.Message); Fsm.Event(failedEvent); return; } #endif }
public static void RestoreCompletedTransactions() { CheckIfInitialised(); if (registeredProducts == null) { Console.LogError(Constants.kDebugTag, "[EditorStore] Restore purchases can be done only after getting products information from store"); return; } int _totalProducts = registeredProducts.Count; List <BillingTransaction> _restoredTransactions = new List <BillingTransaction>(); for (int _iter = 0; _iter < _totalProducts; _iter++) { BillingProduct _product = registeredProducts[_iter]; if (IsProductPurchased(_product.ProductIdentifier)) { BillingTransaction _transaction = GetTransactionDetails(_product.ProductIdentifier, eBillingTransactionState.RESTORED, null); // Add it to list of restored transactions _restoredTransactions.Add(_transaction); } } // Send callback SendFinishedTransactionCallback(_restoredTransactions); }
private void _BuyProduct(BillingProduct _product) { #if DEBUG_MODE Debug.Log("RcBilling:_BuyProduct=" + _product); #endif NPBinding.Billing.BuyProduct(_product); }
private void DoAction() { #if USES_BILLING BillingProduct _product = NPBinding.Billing.GetStoreProduct(productIdentifier.Value); bool _isPurchased = NPBinding.Billing.IsProductPurchased(_product); Fsm.Event(_isPurchased ? purchasedEvent : notPurchasedEvent); #endif }
private BillingProduct CreateProduct(string name, bool isConsumable, string id) { PlatformValue[] platformVals = new PlatformValue[] { PlatformValue.IOS(id) }; return(BillingProduct.Create(name, isConsumable, platformVals)); }
private void DoAction() { #if USES_BILLING // Get the specified product BillingProduct _product = NPBinding.Billing.GetStoreProduct(productIdentifier.Value); // Start request to purchase product NPBinding.Billing.BuyProduct(_product); #endif }
// 이미 구입했던 아이템인가? (비소모성) private bool _IsProductPurchased(BillingProduct _product) { bool ret = NPBinding.Billing.IsProductPurchased(_product); #if DEBUG_MODE Debug.Log(string.Format("RcBilling:_IsProductPurchased={0} ret={1}", _product, ret)); #endif return(ret); }
public static IDictionary CreateJSONObject (BillingProduct _product) { IDictionary _productJsonDict = new Dictionary<string, string>(); _productJsonDict[kProductID] = _product.ProductIdentifier; _productJsonDict[kTitle] = _product.Name; _productJsonDict[kDescription] = _product.Description; _productJsonDict[kPriceAmount] = (_product.Price * 1000000).ToString(); _productJsonDict[kLocalizedPrice] = _product.LocalizedPrice; return _productJsonDict; }
private void handleProductCommit(BillingProduct product, Product queryProduct, TextBox el) { if (queryProduct != null) { List <BillingProduct> availableProducts = new List <BillingProduct>(); if (invoice.BillingProducts != null) { availableProducts = JsonSerializer.Deserialize <List <BillingProduct> >(invoice.BillingProducts); } if (availableProducts.Find(prod => prod.Barcode == queryProduct.Barcode) != null) { MessageBoxResult result = MessageBox.Show("Add Duplicate product?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { BillingProduct billingProduct = products.Find(prod => prod.Barcode == queryProduct.Barcode); billingProduct.Quantity = billingProduct.Quantity + 1; billingProduct.Total = int.Parse(queryProduct.MRP) * billingProduct.Quantity; int discount = discountText.Text == "" ? 0 : int.Parse(discountText.Text); int sum = products.Sum(product => product.Total); grandTotalText.Text = formatTotal(sum - discount); billTable.CellEditEnding -= billTableCellEditEvent; billTable.CancelEdit(); billTable.CancelEdit(); billTable.Items.Refresh(); billTable.CellEditEnding += billTableCellEditEvent; } else { billTable.CellEditEnding -= billTableCellEditEvent; billTable.CancelEdit(); billTable.CancelEdit(); billTable.Items.Refresh(); billTable.CellEditEnding += billTableCellEditEvent; } } else { addProduct(product, queryProduct, el); } } else { MessageBox.Show("Barcode not Found", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); billTable.CellEditEnding -= billTableCellEditEvent; billTable.CancelEdit(); billTable.CancelEdit(); billTable.Items.Refresh(); billTable.CellEditEnding += billTableCellEditEvent; } }
public static IDictionary CreateJSONObject(BillingProduct _product) { IDictionary _productJsonDict = new Dictionary <string, string>(); _productJsonDict[kProductID] = _product.ProductIdentifier; _productJsonDict[kTitle] = _product.Name; _productJsonDict[kDescription] = _product.Description; _productJsonDict[kPriceAmount] = (_product.Price * 1000000).ToString(); _productJsonDict[kLocalizedPrice] = _product.LocalizedPrice; return(_productJsonDict); }
private static void OnFinishedProductsRequest (BillingProduct[] _registeredProducts, string _error) { // Callback is sent to binding event listener if (NPBinding.Billing != null) NPBinding.Billing.InvokeMethod(kDidReceiveBillingProductsEventName, new object[] { _registeredProducts, _error }, new Type[] { typeof(BillingProduct[]), typeof(string) }); }
public static IDictionary CreateJSONObject (BillingProduct _product) { IDictionary _productJsonDict = new Dictionary<string, string>(); _productJsonDict[kTitle] = _product.Name; _productJsonDict[kProductID] = _product.ProductIdentifier; _productJsonDict[kDescription] = _product.Description; _productJsonDict[kPrice] = _product.Price.ToString(); _productJsonDict[kLocalizedPrice] = _product.LocalizedPrice; _productJsonDict[kCurrencyCode] = _product.CurrencyCode; _productJsonDict[kCurrencySymbol] = _product.CurrencySymbol; return _productJsonDict; }
private static void OnConfirmingPurchase(BillingProduct _product) { if (!_product.IsConsumable) { EditorPrefs.SetInt(_product.ProductIdentifier, 1); } BillingTransaction _newTransaction = CreateTransactionObject(_product.ProductIdentifier, eBillingTransactionState.PURCHASED, null); PostTransactionEvent(kProductPurchaseFinishedEventName, new BillingTransaction[1] { _newTransaction }); }
public static IDictionary CreateJSONObject(BillingProduct _product) { IDictionary _productJsonDict = new Dictionary <string, string>(); _productJsonDict[kTitle] = _product.Name; _productJsonDict[kProductID] = _product.ProductIdentifier; _productJsonDict[kDescription] = _product.Description; _productJsonDict[kPrice] = _product.Price.ToString(); _productJsonDict[kLocalizedPrice] = _product.LocalizedPrice; _productJsonDict[kCurrencyCode] = _product.CurrencyCode; _productJsonDict[kCurrencySymbol] = _product.CurrencySymbol; return(_productJsonDict); }
public void BuyItem(string id) { Debug.Log("Buy item's button callback."); BillingProduct product = this.GetProductByID(id); if (product != null) { this.BuyItem(product); } else { Debug.Log("Cannot find ID : " + id); } }
public void BuyItem(BillingProduct _product) { if (NPBinding.Billing.IsProductPurchased(_product.ProductIdentifier)) { // Show alert message that item is already purchased return; } // Call method to make purchase NPBinding.Billing.BuyProduct(_product); // At this point you can display an activity indicator to inform user that task is in progress }
private void dataGridKeyEvent(object sender, KeyEventArgs e) { if (billTable.SelectedItem != null) { int selectedIndex; switch (e.Key) { case Key.Delete: BillingProduct product = billTable.SelectedItem as BillingProduct; int sum = products.Sum(product => product.Total); int discount = discountText.Text == "" ? 0 : int.Parse(discountText.Text); grandTotalText.Text = formatTotal(sum - product.Total - discount); products.Remove(product); billTable.ItemsSource = products; int total = products.Sum(product => product.Quantity); totalItemsText.Text = "Total Items:" + total.ToString(); invoice.BillingProducts = JsonSerializer.Serialize <List <BillingProduct> >(products); billTable.Items.Refresh(); break; case Key.Enter: switchCells(e, Key.Enter); break; case Key.Back: switchCells(e, Key.Back); break; case Key.Down: selectedIndex = products_list.SelectedIndex; if (selectedIndex != -1 && selectedIndex < products_list.Items.Count) { products_list.SelectedIndex = selectedIndex + 1; products_list.ScrollIntoView(products_list.Items[selectedIndex]); } break; case Key.Up: selectedIndex = products_list.SelectedIndex; if (selectedIndex > 0) { products_list.SelectedIndex = selectedIndex - 1; products_list.ScrollIntoView(products_list.Items[selectedIndex]); } break; } } }
public void BuyItem(BillingProduct _product) { //For non-consumable items - if it has already been purchased - you can add it back to the user. Does not need to be used for rocket recover at the moment. if (NPBinding.Billing.IsProductPurchased(_product)) { // Show alert message that item is already purchased return; } // Call method to make purchase NPBinding.Billing.BuyProduct(_product); // At this point you can display an activity indicator to inform user that task is in progress }
private static void OnConfirmingPurchase(BillingProduct _product) { // Non consummable purchases are tracked if (!_product.IsConsumable) { EditorPrefs.SetInt(_product.ProductIdentifier, 1); } BillingTransaction _newTransaction = GetTransactionDetails(_product.ProductIdentifier, eBillingTransactionState.PURCHASED, null); // Send callback SendFinishedTransactionCallback(new BillingTransaction[1] { _newTransaction }); }
public BillingProduct GetProduct(string strIdentifier) { // 제품 정보 리턴. //#if DEBUG_MODE //Debug.Log("RcBilling:GetProduct="+strIdentifier); //#endif BillingProduct product = null; if (true == m_hashProducts.TryGetValue(strIdentifier, out product)) { return(product); } return(null); }
/// <summary> /// Fetch the latest product metadata, including purchase receipts, /// asynchronously with results returned via IStoreCallback. /// </summary> public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products) { this.products = new Dictionary <string, ProductDescription>(); List <BillingProduct> billingProducts = new List <BillingProduct>(); for (int i = 0; i < products.Count; i++) { BillingProduct product = ConvertProduct(products[i]); if (product != null) { billingProducts.Add(product); } } NPBinding.Billing.RequestForBillingProducts(billingProducts.ToArray()); }
public override bool AddPurchase(string productID) { if (NPBinding.Billing.IsAvailable()) { BillingProduct bp = NPBinding.Billing.GetStoreProduct(productID); if (!NPBinding.Billing.IsProductPurchased(bp)) { NPBinding.Billing.BuyProduct(bp); // will fire OnDidFinishTransaction Event on complete } else if (productID == "removeads") { GameManager.Instance.RemoveAds(); } return(true); } return(false); }
public void BuyItem(BillingProduct _product) { Debug.Log("Buy product : " + _product.ProductIdentifier); if (NPBinding.Billing.IsProductPurchased(_product.ProductIdentifier)) { // Show alert message that item is already purchased Debug.Log("Alert : " + _product.ProductIdentifier + "has been purchased!"); return; } // At this point you can display an activity indicator to inform user that task is in progress // if (m_LoadingLayer != null) m_LoadingLayer.SetVisible(true); // Call method to make purchase NPBinding.Billing.BuyProduct(_product); Debug.Log("Send purchase request."); }
void OnDidFinishProductsRequest(BillingProduct[] _regProductsList, string _error) { // Hide activity indicator // Handle response if (_error != null) { // Something went wrong } else { // Inject code to display received products premiumUserProduct = _regProductsList[0]; print(premiumUserProduct.Name); print(premiumUserProduct.Price); SetupPremiumUser(premiumUserProduct); } }
public bool Buy(string strIdentifier, funcBuy OnCallback) { // 구입. #if DEBUG_MODE Debug.Log("RcBilling:Buy=" + strIdentifier); #endif m_OnCallbackBuy = OnCallback; if (true == this.available) { BillingProduct product = GetProduct(strIdentifier); if (null != product) { // 비소모 아이템 이면서 if (false == product.IsConsumable) { // 이미 구입했다면 if (true == _IsProductPurchased(product)) { // 이미 구입 콜백 if (null != m_OnCallbackBuy) { m_OnCallbackBuy(E_BILLING_RESULT.Already, null); } return(false); } } _BuyProduct(product); return(true); } } if (null != m_OnCallbackBuy) { m_OnCallbackBuy(E_BILLING_RESULT.Failed, null); } return(false); }
public static void RequestForBillingProducts (BillingProduct[] _productsList) { CheckIfInitialised(); if (_productsList == null) { registeredProducts = new EditorBillingProduct[0]; // Trigger handler OnFinishedProductsRequest(null, "The operation could not be completed beacuse product list is null."); return; } else { // Create new registered product list List<EditorBillingProduct> _newlyRegisteredProductList = new List<EditorBillingProduct>(); // Create list of registered products with price info foreach (BillingProduct _curProduct in _productsList) { if (_curProduct != null) { EditorBillingProduct _newRegProduct = new EditorBillingProduct(_curProduct); _newRegProduct.SetLocalizePrice(string.Format("${0:0.00}", _curProduct.Price)); _newRegProduct.SetCurrencyCode("USD"); _newRegProduct.SetCurrencySymbol("$"); // Add to store products _newlyRegisteredProductList.Add(_newRegProduct); } } // Cache new list registeredProducts = _newlyRegisteredProductList.ToArray(); // Trigger handler OnFinishedProductsRequest(registeredProducts, null); return; } }
//converting Unity IAP product definitions into the VoxelBuster format private BillingProduct ConvertProduct(ProductDefinition product) { IAPObject obj = IAPManager.GetIAPObject(product.id); if (obj == null) { return(null); } List <VoxelBusters.NativePlugins.PlatformID> platformIds = new List <VoxelBusters.NativePlugins.PlatformID>(); platformIds.Add(VoxelBusters.NativePlugins.PlatformID.Editor(product.id)); #if UNITY_ANDROID platformIds.Add(VoxelBusters.NativePlugins.PlatformID.Android(product.storeSpecificId)); #elif UNITY_IOS || UNITY_TVOS platformIds.Add(VoxelBusters.NativePlugins.PlatformID.IOS(product.storeSpecificId)); #endif return(BillingProduct.Create(obj.title, product.type == ProductType.Consumable ? true : false, platformIds.ToArray())); }
public JsonResult Create(List <BillingProductVM> billingProductViewModel, String customername, String address, String contact, String gt, String total, String discount) { if (billingProductViewModel != null) { Billing billing = new Billing(); billing.DateCreated = DateTime.Now; billing.CreatedBy = 1; billing.Amount = gt; billing.TotalDiscount = discount; billing.TotalPrice = total; billing.Name = customername; billing.Addres = address; billing.ContactNo = contact; billingService.Add(billing); billingService.Save(); int BillingId = billing.BillingId; foreach (var item in billingProductViewModel) { BillingProduct billingProduct = new BillingProduct(); billingProduct.Discount = item.Discount; billingProduct.BillingId = BillingId; billingProduct.Quantity = item.Quantity; billingProduct.ProductId = item.ProductId; Product product = productService.LoadByID(billingProduct.ProductId); product.Quantities.FirstOrDefault().Quantity1 -= billingProduct.Quantity; billingProductService.Add(billingProduct); } productService.Save(); billingProductService.Save(); } JsonResult jsonResult = new JsonResult(); jsonResult.Data = new { d = "ddd" }; return(jsonResult); }
private void DoAction() { #if USES_BILLING BillingProduct _product = NPBinding.Billing.GetStoreProduct(productIdentifier.Value); if (_product == null) { Fsm.Event(failedEvent); return; } else { // Update properties name.Value = _product.Name; description.Value = _product.Description; isConsumable.Value = _product.IsConsumable; price.Value = _product.Price; localizedPrice.Value = _product.LocalizedPrice; currencyCode.Value = _product.CurrencyCode; currencySymbol.Value = _product.CurrencySymbol; } #endif }
public EditorBillingProduct (BillingProduct _product) : base (_product) {}
public void SetNoPremiumUser(BillingProduct _product) { premiumUser.priceTxt.text = "Price:" + _product.Price.ToString(); premiumUserOverlay.SetActive(true); }
protected MutableBillingProduct (BillingProduct _product) : base (_product) {}
private void BuyItemFromStore(BillingProduct _product) { AndroidDebug.debug("BuyItemFromStore -" + _product.ProductIdentifier); NPBinding.Billing.BuyProduct(_product); }
private static void OnConfirmingPurchase (BillingProduct _product) { // Non consummable purchases are tracked if (!_product.IsConsumable) { EditorPrefs.SetInt(_product.ProductIdentifier, 1); } BillingTransaction _newTransaction = GetTransactionDetails(_product.ProductIdentifier, eBillingTransactionState.PURCHASED, null); List<BillingTransaction> _transactionList = new List<BillingTransaction>(new BillingTransaction[1] { _newTransaction }); // Send callback SendFinishedTransactionCallback(_transactionList); }