/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection to purchase manager _Storyboard = Storyboard; PurchaseManager = purchaseManager; // Scan sub view controllers foreach (UIViewController controller in ChildViewControllers) { //Console.WriteLine (controller.ToString ()); // Wireup sub views to the master purchase controller if (controller is PurchaseTableViewController) { // Found the previous purchase table, save and initialize _purchaseTable = (PurchaseTableViewController)controller; _purchaseTable.AttachToPurchaseManager (_Storyboard, purchaseManager); } else if (controller is StoreTableViewController) { // Found the available products for sale table, save and initialize _storeTable = (StoreTableViewController)controller; _storeTable.AttachToPurchaseManager (_Storyboard, purchaseManager); } else if (controller is FeaturesController) { // Found special features, save and initialize _featuresController = (FeaturesController)controller; _featuresController.AttachToPurchaseManager (_Storyboard, purchaseManager); } else if (controller is SettingsController) { // Found settings, save and initialize _settingsController = (SettingsController)controller; _settingsController.AttachToPurchaseManager (_Storyboard, purchaseManager); } } }
public void ResponseButton_OK() { if (ShopType == STOREMODE_TYPE.Gold) { webRequest.ShopBuyItem(InfosShop.ShopIdx, callback_complete_purchase); } else { #if UNITY_EDITOR if (packageType == Package_Type.Special) { //상점팝업닫기 if (UI_Top.Getsingleton.popupStore.gameObject.activeSelf == true) { UI_Top.Getsingleton.popupStore.gameObject.SetActive(false); } //현재팝업 끄기 UI_Manager.Getsingleton.ClearUI(this); //test //webRequest.ShopBuyUnit(10009, 100, callback_complete_BuySpecial); webRequest.ShopBuyItem(InfosShop.ShopIdx, callback_complete_BuySpecial); } else { webRequest.ShopBuyItem(InfosShop.ShopIdx, callback_complete_purchase); } #else InAppPurchaseManager _IAP = InAppPurchaseManager.instance; if (packageType == Package_Type.Special) { //상점팝업닫기 if (UI_Top.Getsingleton.popupStore.gameObject.activeSelf == true) { UI_Top.Getsingleton.popupStore.gameObject.SetActive(false); } //현재팝업 끄기 UI_Manager.Getsingleton.ClearUI(this); _IAP.nextPrcs = callback_complete_BuySpecial; } else { _IAP.nextPrcs = callback_complete_purchase; } _IAP.RequestPayment(_IAP.Get_ProductID(InfosShop.ShopIdx), InfosShop.ShopIdx); #endif } }
public void DisplayProduct(InAppPurchaseManager purchaseManager, InAppProduct product) { // Save copy of the current product and purchase manager _purchaseManager = purchaseManager; Product = product; // Set image based on the product type switch (product.ProductType) { case InAppProductType.NonConsumable: if (product.Downloadable) { // ItemImage.Image = UIImage.FromFile("Images/Downloadable.png"); } else { // ItemImage.Image = UIImage.FromFile("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: //ItemImage.Image = UIImage.FromFile("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: // ItemImage.Image = UIImage.FromFile("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: //ItemImage.Image = UIImage.FromFile("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: //ItemImage.Image = UIImage.FromFile("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: //ItemImage.Image = UIImage.FromFile("Images/Unknown.png"); break; } // Fill in the rest of the information _isRestore = false; //ItemTitle.Text = product.Title; //DownloadProgress.Hidden = true; //ItemDescription.Text = product.Description; //ItemPrice.Text = product.FormattedPrice; //BuyButton.SetTitle("Buy", UIControlState.Normal); //BuyButton.Hidden = !_purchaseManager.CanMakePayments; //BuyButton.Enabled = true; // Wireup Button WireupBuyButton(); }
void Awake() { if (instance == null) { instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } else { GameObject.Destroy(this); } }
private async void InitializeInAppPurchases() { PurchaseManager = new InAppPurchaseManager(); // assembly public key string value = Xamarin.InAppPurchase.Utilities.Security.Unify( new string[] { "1322f985c2", "a34166b24", "ab2b367", "851cc6" }, new int[] { 0, 1, 2, 3 }); PurchaseManager.PublicKey = value; PurchaseManager.ApplicationUserName = "******"; // be sure the user can make payment if (!PurchaseManager.CanMakePayments) { // the user is not able to make payment await AlertControllerHelper.ShowAlert(Application.LocalizedString("PaymentFailure") , Application.LocalizedString("CantPurchase") , Application.LocalizedString("Close")); } // be sure the user has access to internet PurchaseManager.NoInternetConnectionAvailable += async() => { // the user is has not internet await AlertControllerHelper.ShowAlert(Application.LocalizedString("PaymentFailure") , Application.LocalizedString("NoInternet") , Application.LocalizedString("Close")); }; // display any invalid product IDs PurchaseManager.ReceivedInvalidProducts += (productIDs) => { Console.WriteLine("The following IDs were rejected by the iTunes App Store:"); foreach (string ID in productIDs) { Console.WriteLine(ID); } }; // setup automatic purchase persistance and load any previous purchases PurchaseManager.AutomaticPersistenceType = InAppPurchasePersistenceType.LocalFile; PurchaseManager.PersistenceFilename = "AtomicData"; PurchaseManager.ShuffleProductsOnPersistence = false; PurchaseManager.RestoreProducts(); PurchaseManager.QueryInventory(new string[] { "com.thingsoftomorrow.seekios.observation", "com.thingsoftomorrow.seekios.discovery", "com.thingsoftomorrow.seekios.exploration", "com.thingsoftomorrow.seekios.aventure", "com.thingsoftomorrow.seekios.epopee" }); }
private void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } SetToDontDestroyOnLoad(); }
protected override void Purchase(PurchaseOfferCallback callback) { InAppPurchaseManager.BuyProduct(inAppProductTag, success => { if (success) { CollectProduct(callback); } else { callback?.Invoke(false); } }); }
public void DisplayProduct(InAppPurchaseManager purchaseManager, InAppProduct product) { // Save copy of the current product and purchase manager _purchaseManager = purchaseManager; Product = product; // Set image based on the product type switch (product.ProductType) { case InAppProductType.NonConsumable: if (product.Downloadable) { ItemImage.Image = UIImage.FromFile ("Images/Downloadable.png"); } else { ItemImage.Image = UIImage.FromFile ("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: ItemImage.Image = UIImage.FromFile ("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: ItemImage.Image = UIImage.FromFile ("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: ItemImage.Image = UIImage.FromFile ("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: ItemImage.Image = UIImage.FromFile ("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: ItemImage.Image = UIImage.FromFile ("Images/Unknown.png"); break; } // Fill in the rest of the information _isRestore = false; ItemTitle.Text = product.Title; DownloadProgress.Hidden = true; ItemDescription.Text = product.Description; ItemPrice.Text = product.FormattedPrice; BuyButton.SetTitle ("Buy", UIControlState.Normal); BuyButton.Hidden = !_purchaseManager.CanMakePayments; BuyButton.Enabled = true; // Wireup Button WireupBuyButton (); }
//public event PaypalUriRetreivedEventHandler PaypalUriRetreived; public LoginRegisterViewModel() { _internetConnectionManagerLocator = new InternetConnectionManagerLocator(); _informerManagerLocator = new InformerManagerLocator(); //_locationHelper = new LocationManager(); _inAppPurchaseManager = new InAppPurchaseManager(); _user = new User(); _planApi = new PlanAPI(new Uri(AppResources.BaseAddress)); _userApi = new UserAPI(new Uri(AppResources.BaseAddress)); _internetConnectionManagerLocator.InternetConnectionManager.ConnectionStateChanged += InternetConnectionManager_ConnectionStateChanged; _userApi.ErrorReceived += _userApi_ErrorReceived; Plans = new ObservableCollection <Plan>(); GetPlans(); //_locationHelper.GetPhoneLocation(); }
public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { _purchaseManager = purchaseManager; purchaseManager.ReceivedValidProducts += (products) => { // received valid products from the iTunes App Store, // update the displ LoadData(); }; purchaseManager.InAppProductPurchased += (transaction, product) => { ProductPurchased(transaction, product); }; purchaseManager.InAppPurchasesRestored += (count) => { // update list to remove any non-consumable products that were // purchased and restored }; purchaseManager.InAppProductPurchaseFailed += (transaction, product) => { //var tt = product.ProductIdentifier; //ProductPurchased(transaction, product); // Inform caller that the purchase of the requested product failed. // NOTE: The transaction will normally encode the reason for the failure but since // we are running in the simulated iTune App Store mode, no transaction will be returned. //Display Alert Dialog Box using (var alert = new UIAlertView(Application.LocalizedString("BuyPack") , string.Format(Application.LocalizedString("BuyFailed") , product.Title , transaction.Error.ToString()) , null , Application.LocalizedString("OK") , null)) { alert.Show(); } // InsertInAppPurchase(App.Locator.ReloadCredit.CreatePurchaseDTO(product.ProductIdentifier, empty, str, PlateformeVersionEnum.IOS) // Force a reload to clear any locked items }; }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; // Respond to events _purchaseManager.ReceivedValidProducts += (products) => { // Received valid products from the iTunes App Store, // Update the display ReloadData(); }; _purchaseManager.InAppProductPurchased += (MonoTouch.StoreKit.SKPaymentTransaction transaction, InAppProduct product) => { // Update list to remove any non-consumable products that were // purchased ReloadData(); }; _purchaseManager.InAppPurchaseProductQuantityConsumed += (identifier) => { // Update list to remove any consumable products that were // used up ReloadData(); }; _purchaseManager.InAppPurchasesRestored += (count) => { // Update list to remove any non-consumable products that were // purchased and restored if (count > 0) { ReloadData(); } }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // If a download fails we have still purchased a product show we need to show it // on the list and show that it is still awaiting download. ReloadData(); }; // Display initial data ReloadData(); }
public override void UpdateButton() { UnityEngine.Purchasing.Product inAppProduct = null; if (InAppPurchaseManager.Initialized) { inAppProduct = InAppPurchaseManager.GetProduct(product.InAppProductTag); } if (inAppProduct is null) { priceText.text = LocalizationManager.GetTranslation(NotAvailableKey) as string; Button.Interactable = false; } else { priceText.text = inAppProduct.metadata.localizedPriceString; Button.Interactable = true; } }
/// <summary> /// Displays the restore previous purchases item /// </summary> /// <param name="purchaseManager">Purchase manager.</param> /// <param name="product">Product.</param> public void DisplayRestore(InAppPurchaseManager purchaseManager) { // Save copy of the current product and purchase manager _purchaseManager = purchaseManager; Product = null; // Fill in theg rest of the information _isRestore = true; //ItemImage.Image = UIImage.FromFile ("Images/RestorePurchases.png"); //ItemTitle.Text = "Restore Purchases"; //ItemDescription.Text = "Restore any previous purchases that you have made in this app."; //DownloadProgress.Hidden = true; //ItemPrice.Text = ""; //BuyButton.SetTitle("Restore", UIControlState.Normal); //BuyButton.Hidden = !_purchaseManager.CanMakePayments; //BuyButton.Enabled = true; // Wireup Button WireupBuyButton(); }
public void Init() { _purchaseManager = new InAppPurchaseManager (); _purchaseManager.SimulateiTunesAppStore = true; _purchaseManager.PublicKey = "ASDFASDFASDF"; _purchaseManager.AutomaticPersistenceType = InAppPurchasePersistenceType.LocalFile; _purchaseManager.ShuffleProductsOnPersistence = false; _purchaseManager.RestoreProducts (); _purchaseManager.QueryInventory (new string[] { _productId, }); _purchaseManager.ReceivedValidProducts += (products) => { Console.WriteLine("ReceivedValidProducts"); foreach(InAppProduct product in products) Console.WriteLine(product.Description); }; }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; // Respond to events _purchaseManager.InAppProductPurchased += (StoreKit.SKPaymentTransaction transaction, InAppProduct product) => { // Update the display UpdateCoinCount(); }; _purchaseManager.InAppPurchaseProductQuantityConsumed += (identifier) => { // Update the display UpdateCoinCount(); }; // Display initial data UpdateCoinCount(); }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection to purchase manager _Storyboard = Storyboard; PurchaseManager = purchaseManager; // Scan sub view controllers foreach (UIViewController controller in ChildViewControllers) { //Console.WriteLine (controller.ToString ()); // Wireup sub views to the master purchase controller if (controller is PurchaseTableViewController) { // Found the previous purchase table, save and initialize _purchaseTable = (PurchaseTableViewController)controller; _purchaseTable.AttachToPurchaseManager(_Storyboard, purchaseManager); } else if (controller is StoreTableViewController) { // Found the available products for sale table, save and initialize _storeTable = (StoreTableViewController)controller; _storeTable.AttachToPurchaseManager(_Storyboard, purchaseManager); } else if (controller is FeaturesController) { // Found special features, save and initialize _featuresController = (FeaturesController)controller; _featuresController.AttachToPurchaseManager(_Storyboard, purchaseManager); } else if (controller is SettingsController) { // Found settings, save and initialize _settingsController = (SettingsController)controller; _settingsController.AttachToPurchaseManager(_Storyboard, purchaseManager); } } }
void Awake() { instance = this; }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; }
void Start() { // bind button events BuyDurableButton.Select(); BuyDurableButton.onClick.AddListener(buyDurableClicked); BuyConsumableButton.onClick.AddListener(buyConsumableClicked); RestoreButton.onClick.AddListener(restoreClicked); GetPriceInfoButton.onClick.AddListener(getPriceInfoClicked); BackButton.onClick.AddListener(backClicked); // make sure we don't init the same IAP items twice if (created) { return; } created = true; // InApp-Purchases - NOTE: you can set different "In App IDs" for each platform. var inAppIDs = new InAppPurchaseID[3]; inAppIDs[0] = new InAppPurchaseID(item1, 1.99m, "$", InAppPurchaseTypes.NonConsumable); inAppIDs[1] = new InAppPurchaseID(item2, 0.99m, "$", InAppPurchaseTypes.NonConsumable); inAppIDs[2] = new InAppPurchaseID(item3, 2.49m, "$", InAppPurchaseTypes.Consumable); // create desc object var desc = new InAppPurchaseDesc(); // Global desc.Testing = true; desc.ClearNativeCache = false; // Editor desc.Editor_InAppIDs = inAppIDs; // WinRT desc.WinRT_InAppPurchaseAPI = InAppPurchaseAPIs.MicrosoftStore; desc.WinRT_MicrosoftStore_InAppIDs = inAppIDs; // WP8 desc.WP8_InAppPurchaseAPI = InAppPurchaseAPIs.MicrosoftStore; desc.WP8_MicrosoftStore_InAppIDs = inAppIDs; // BB10 desc.BB10_InAppPurchaseAPI = InAppPurchaseAPIs.BlackBerryWorld; desc.BB10_BlackBerryWorld_InAppIDs = inAppIDs; // iOS desc.iOS_InAppPurchaseAPI = InAppPurchaseAPIs.AppleStore; desc.iOS_AppleStore_InAppIDs = inAppIDs; desc.iOS_AppleStore_SharedSecretKey = ""; // NOTE: Must set SharedSecretKey, even for Testing! // Android // Choose for either GooglePlay or Amazon. // NOTE: Use "player settings" to define compiler directives. #if AMAZON desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.Amazon; #elif SAMSUNG desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.Samsung; #else desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.GooglePlay; #endif desc.Android_GooglePlay_InAppIDs = inAppIDs; desc.Android_GooglePlay_Base64Key = ""; // NOTE: Must set Base64Key for GooglePlay in Apps to work, even for Testing! desc.Android_Amazon_InAppIDs = inAppIDs; desc.Android_Samsung_InAppIDs = inAppIDs; desc.Android_Samsung_ItemGroupID = ""; // init InAppPurchaseManager.Init(desc, createdCallback); }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; // Respond to events _purchaseManager.ReceivedValidProducts += (products) => { // Received valid products from the iTunes App Store, // Update the display ReloadData(); }; _purchaseManager.InAppProductPurchased += (transaction, product) => { // Update list to remove any non-consumable products that were // purchased ReloadData(); }; _purchaseManager.InAppPurchasesRestored += (count) => { // Update list to remove any non-consumable products that were // purchased and restored ReloadData(); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadInProgress += (download) => { // Update the table to display the status of any downloads of hosted content // that we currently have in progress so we are forcing a table reload on the // download progress update. Since the final message will be the raising of the // InAppProductPurchased event, we'll just trap it to clear any completed // downloads instead of listening to the InAppPurchaseContentDownloadCompleted on the // purchase managers transaction observer. ReloadData(); // Display download percent in the badge StoreTab.BadgeValue = string.Format ("{0:###}%", _purchaseManager.ActiveDownloadPercent * 100.0f);; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadCompleted += (download) => { // Clear badge StoreTab.BadgeValue = null; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadCanceled += (download) => { // Clear badge StoreTab.BadgeValue = null; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // Clear badge StoreTab.BadgeValue = null; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // Inform the user that the download has failed. Normally download would contain // information about the failure that you would want to display to the user, since // we are running in simulation mode download will be null, so just display a // generic failure message. using(var alert = new UIAlertView("Download Failed", "Unable to complete the downloading of content for the product being purchased. Please try again later.", null, "OK", null)) { alert.Show(); } // Force the table to reload to remove current download message ReloadData(); }; _purchaseManager.InAppProductPurchaseFailed += (transaction, product) => { // Inform caller that the purchase of the requested product failed. // NOTE: The transaction will normally encode the reason for the failure but since // we are running in the simulated iTune App Store mode, no transaction will be returned. //Display Alert Dialog Box using(var alert = new UIAlertView("Xamarin.InAppPurchase", String.Format("Attempt to purchase {0} has failed: {1}", product.Title, transaction.Error.ToString()), null, "OK", null)) { alert.Show(); } // Force a reload to clear any locked items ReloadData(); }; // Initially populate the table with information ReloadData (); }
public void DisplayDownload(InAppPurchaseManager purchaseManager) { // Save copy of the current product and purchase manager _purchaseManager = purchaseManager; Product = purchaseManager.ProductDownloadingContent; // Has the product already been purged from memory? if (Product == null) { // Inform user of completion ItemImage.Image = UIImage.FromFile ("Images/Downloadable.png"); ItemTitle.Text = "Finalizing Download"; ItemDescription.Text = "Completing product download and moving product into position."; ItemPrice.Text = "100%"; BuyButton.Hidden = true; DownloadProgress.Hidden = false; DownloadProgress.Progress = 1.0f; } else { // Set image based on the product type switch (Product.ProductType) { case InAppProductType.NonConsumable: if (Product.Downloadable) { ItemImage.Image = UIImage.FromFile ("Images/Downloadable.png"); } else { ItemImage.Image = UIImage.FromFile ("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: ItemImage.Image = UIImage.FromFile ("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: ItemImage.Image = UIImage.FromFile ("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: ItemImage.Image = UIImage.FromFile ("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: ItemImage.Image = UIImage.FromFile ("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: ItemImage.Image = UIImage.FromFile ("Images/Unknown.png"); break; } // Fill in the rest of the information _isRestore = false; ItemTitle.Text = string.Format("{0} v{1}",Product.Title,Product.DownloadableContentVersion); ItemDescription.Text = Product.Description; ItemPrice.Text = string.Format ("{0:###}%", purchaseManager.ActiveDownloadPercent * 100.0f); BuyButton.Hidden = true; DownloadProgress.Hidden = false; DownloadProgress.Progress = purchaseManager.ActiveDownloadPercent; } }
public void AttachToPurchaseManager(InAppPurchaseManager purchaseManager) { Console.WriteLine("Attached to ThingViewController"); _purchaseManager = purchaseManager; // Respond to events _purchaseManager.ReceivedValidProducts += (products) => { // Received valid products from the iTunes App Store, // Update the display Console.WriteLine("_purchaseManager.ReceivedValidProducts " + products); foreach (var p in products) { Console.WriteLine("--- " + p.productIdentifier + " " + p.price); } ReloadData(); }; _purchaseManager.InAppProductPurchased += (MonoTouch.StoreKit.SKPaymentTransaction transaction, InAppProduct product) => { // Update list to remove any non-consumable products that were // purchased Console.WriteLine("_purchaseManager.InAppProductPurchased " + product.productIdentifier); ReloadData(); }; _purchaseManager.InAppPurchasesRestored += (count) => { // Update list to remove any non-consumable products that were // purchased and restored Console.WriteLine("_purchaseManager.InAppPurchasesRestored " + count); ReloadData(); }; _purchaseManager.transactionObserver.InAppPurchaseContentDownloadInProgress += (download) => { // Update the table to display the status of any downloads of hosted content // that we currently have in progress so we are forcing a table reload on the // download progress update. Since the final message will be the raising of the // InAppProductPurchased event, we'll just trap it to clear any completed // downloads instead of listening to the InAppPurchaseContentDownloadCompleted on the // purchase managers transaction observer. Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadInProgress " + string.Format("{0:###}%", _purchaseManager.activeDownloadPercent * 100.0f)); ReloadData(); // Display download percent in the badge // StoreTab.BadgeValue = string.Format ("{0:###}%", _purchaseManager.activeDownloadPercent * 100.0f); }; _purchaseManager.transactionObserver.InAppPurchaseContentDownloadCompleted += (download) => { // Clear badge Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadCompleted"); }; _purchaseManager.transactionObserver.InAppPurchaseContentDownloadCanceled += (download) => { // Clear badge Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadCanceled"); }; _purchaseManager.transactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // Inform the user that the download has failed. Normally download would contain // information about the failure that you would want to display to the user, since // we are running in simulation mode download will be null, so just display a // generic failure message. using (var alert = new UIAlertView("Download Failed", "Unable to complete the downloading of content for the product being purchased. Please try again later.", null, "OK", null)) { alert.Show(); } Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadFailed"); // Force the table to reload to remove current download message ReloadData(); }; _purchaseManager.InAppProductPurchaseFailed += (transaction, product) => { // Inform caller that the purchase of the requested product failed. // NOTE: The transaction will normally encode the reason for the failure but since // we are running in the simulated iTune App Store mode, no transaction will be returned. //Display Alert Dialog Box using (var alert = new UIAlertView("Xamarin.InAppPurchase", String.Format("Attempt to purchase {0} has failed.", product.title), null, "OK", null)) { alert.Show(); } Console.WriteLine("InAppProductPurchaseFailed " + transaction.Error.Code + " " + transaction.Error.LocalizedDescription); // Force a reload to clear any locked items ReloadData(); }; }
/// <summary> /// Displays the restore previous purchases item /// </summary> /// <param name="purchaseManager">Purchase manager.</param> /// <param name="product">Product.</param> public void DisplayRestore(InAppPurchaseManager purchaseManager) { // Save copy of the current product and purchase manager _purchaseManager = purchaseManager; Product = null; // Fill in theg rest of the information _isRestore = true; ItemImage.Image = UIImage.FromFile ("Images/RestorePurchases.png"); ItemTitle.Text = "Restore Purchases"; ItemDescription.Text = "Restore any previous purchases that you have made in this app."; DownloadProgress.Hidden = true; ItemPrice.Text = ""; BuyButton.SetTitle ("Restore", UIControlState.Normal); BuyButton.Hidden = !_purchaseManager.CanMakePayments; BuyButton.Enabled = true; // Wireup Button WireupBuyButton (); }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; // Respond to events _purchaseManager.ReceivedValidProducts += (products) => { // Received valid products from the iTunes App Store, // Update the display ReloadData(); }; _purchaseManager.InAppProductPurchased += (transaction, product) => { // Update list to remove any non-consumable products that were // purchased ReloadData(); }; _purchaseManager.InAppPurchasesRestored += (count) => { // Update list to remove any non-consumable products that were // purchased and restored ReloadData(); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadInProgress += (download) => { // Update the table to display the status of any downloads of hosted content // that we currently have in progress so we are forcing a table reload on the // download progress update. Since the final message will be the raising of the // InAppProductPurchased event, we'll just trap it to clear any completed // downloads instead of listening to the InAppPurchaseContentDownloadCompleted on the // purchase managers transaction observer. ReloadData(); // Display download percent in the badge // StoreTab.BadgeValue = string.Format("{0:###}%", _purchaseManager.ActiveDownloadPercent * 100.0f); ; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadCompleted += (download) => { // Clear badge // StoreTab.BadgeValue = null; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadCanceled += (download) => { // Clear badge // StoreTab.BadgeValue = null; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // Clear badge //StoreTab.BadgeValue = null; }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // Inform the user that the download has failed. Normally download would contain // information about the failure that you would want to display to the user, since // we are running in simulation mode download will be null, so just display a // generic failure message. using (var alert = new UIAlertView("Download Failed", "Unable to complete the downloading of content for the product being purchased. Please try again later.", null, "OK", null)) { alert.Show(); } // Force the table to reload to remove current download message ReloadData(); }; _purchaseManager.InAppProductPurchaseFailed += (transaction, product) => { // Inform caller that the purchase of the requested product failed. // NOTE: The transaction will normally encode the reason for the failure but since // we are running in the simulated iTune App Store mode, no transaction will be returned. //Display Alert Dialog Box using (var alert = new UIAlertView("Xamarin.InAppPurchase", String.Format("Attempt to purchase {0} has failed: {1}", product.Title, transaction.Error.ToString()), null, "OK", null)) { alert.Show(); } // Force a reload to clear any locked items ReloadData(); }; // Initially populate the table with information ReloadData(); }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; // Respond to events _purchaseManager.ReceivedValidProducts += (products) => { // Received valid products from the iTunes App Store, // Update the display ReloadData(); }; _purchaseManager.InAppProductPurchased += (transaction, product) => { // Update list to remove any non-consumable products that were // purchased ReloadData(); }; _purchaseManager.InAppPurchaseProductQuantityConsumed += (identifier) => { // Update list to remove any consumable products that were // used up ReloadData(); }; _purchaseManager.InAppPurchasesRestored += (count) => { // Update list to remove any non-consumable products that were // purchased and restored if (count>0) ReloadData(); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // If a download fails we have still purchased a product show we need to show it // on the list and show that it is still awaiting download. ReloadData(); }; // Display initial data ReloadData (); }
public void DisplayProduct(PurchaseTableViewController controller, InAppPurchaseManager purchaseManager, InAppProduct product) { // Save copy of the current product and purchase manager _controller = controller; _purchaseManager = purchaseManager; Product = product; // Set image based on the product type switch (product.ProductType) { case InAppProductType.NonConsumable: if (product.Downloadable) { ItemImage.Image = UIImage.FromFile("Images/Downloadable.png"); } else { ItemImage.Image = UIImage.FromFile("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: ItemImage.Image = UIImage.FromFile("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: ItemImage.Image = UIImage.FromFile("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: ItemImage.Image = UIImage.FromFile("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: ItemImage.Image = UIImage.FromFile("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: ItemImage.Image = UIImage.FromFile("Images/Unknown.png"); break; } // Fill in the rest of the information ItemTitle.Text = product.Title; ItemDescription.Text = product.Description; UpdateButton.Hidden = true; // Take action based on the product type switch (Product.ProductType) { case InAppProductType.Consumable: // Show remaining quantity AvailableQuantity.Hidden = false; AvailableQuantity.Text = String.Format("{0} qty", product.AvailableQuantity); break; case InAppProductType.AutoRenewableSubscription: case InAppProductType.NonRenewingSubscription: // Force this product to use a calculated date product.UseCalculatedExpirationDate = true; // Show expiration date AvailableQuantity.Hidden = false; AvailableQuantity.Text = String.Format("Exp {0:d}", product.SubscriptionExpirationDate); break; case InAppProductType.FreeSubscription: // Show it never expires AvailableQuantity.Hidden = false; AvailableQuantity.Text = "Unlimited"; break; case InAppProductType.NonConsumable: if (Product.Downloadable) { // Use quantity to show download state if (Product.NewContentAvailable) { AvailableQuantity.Text = string.Format("v{0} Available", Product.DownloadableContentVersion); // Display update button and wire it up _displayContent = false; UpdateButton.Hidden = _purchaseManager.DownloadInProgress; UpdateButton.SetTitle("Update", UIControlState.Normal); WireupUpdateButton(); } else if (Product.ContentDownloaded) { AvailableQuantity.Text = string.Format("Ready v{0}", Product.DownloadableContentVersion); // Display button _displayContent = true; UpdateButton.Hidden = false; UpdateButton.SetTitle("Show", UIControlState.Normal); WireupUpdateButton(); } else { AvailableQuantity.Text = "Awaiting Content"; // Display update button and wire it up _displayContent = false; UpdateButton.Hidden = _purchaseManager.DownloadInProgress; UpdateButton.SetTitle("Get", UIControlState.Normal); WireupUpdateButton(); } AvailableQuantity.Hidden = false; } else { // Not downloadable, hide quantity AvailableQuantity.Hidden = true; } break; default: AvailableQuantity.Hidden = true; break; } }
public void DisplayDownload(InAppPurchaseManager purchaseManager) { // Save copy of the current product and purchase manager _purchaseManager = purchaseManager; Product = purchaseManager.ProductDownloadingContent; // Has the product already been purged from memory? if (Product == null) { //// Inform user of completion //ItemImage.Image = UIImage.FromFile("Images/Downloadable.png"); //ItemTitle.Text = "Finalizing Download"; //ItemDescription.Text = "Completing product download and moving product into position."; //ItemPrice.Text = "100%"; //BuyButton.Hidden = true; //DownloadProgress.Hidden = false; //DownloadProgress.Progress = 1.0f; } else { // Set image based on the product type switch (Product.ProductType) { case InAppProductType.NonConsumable: if (Product.Downloadable) { // ItemImage.Image = UIImage.FromFile("Images/Downloadable.png"); } else { // ItemImage.Image = UIImage.FromFile("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: //ItemImage.Image = UIImage.FromFile("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: // ItemImage.Image = UIImage.FromFile("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: // ItemImage.Image = UIImage.FromFile("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: // ItemImage.Image = UIImage.FromFile("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: // ItemImage.Image = UIImage.FromFile("Images/Unknown.png"); break; } // Fill in the rest of the information _isRestore = false; //ItemTitle.Text = string.Format("{0} v{1}", Product.Title, Product.DownloadableContentVersion); //ItemDescription.Text = Product.Description; //ItemPrice.Text = string.Format("{0:###}%", purchaseManager.ActiveDownloadPercent * 100.0f); //BuyButton.Hidden = true; //DownloadProgress.Hidden = false; //DownloadProgress.Progress = purchaseManager.ActiveDownloadPercent; } }
/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection _Storyboard = Storyboard; _purchaseManager = purchaseManager; // Respond to events _purchaseManager.InAppProductPurchased += (StoreKit.SKPaymentTransaction transaction, InAppProduct product) => { // Update the display UpdateCoinCount(); }; _purchaseManager.InAppPurchaseProductQuantityConsumed += (identifier) => { // Update the display UpdateCoinCount(); }; // Display initial data UpdateCoinCount (); }
public CustomPaymentObserver(InAppPurchaseManager manager) { theManager = manager; }
public void DisplayProduct(PurchaseTableViewController controller, InAppPurchaseManager purchaseManager, InAppProduct product) { // Save copy of the current product and purchase manager _controller = controller; _purchaseManager = purchaseManager; Product = product; // Set image based on the product type switch (product.ProductType) { case InAppProductType.NonConsumable: if (product.Downloadable) { ItemImage.Image = UIImage.FromFile ("Images/Downloadable.png"); } else { ItemImage.Image = UIImage.FromFile ("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: ItemImage.Image = UIImage.FromFile ("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: ItemImage.Image = UIImage.FromFile ("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: ItemImage.Image = UIImage.FromFile ("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: ItemImage.Image = UIImage.FromFile ("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: ItemImage.Image = UIImage.FromFile ("Images/Unknown.png"); break; } // Fill in the rest of the information ItemTitle.Text = product.Title; ItemDescription.Text = product.Description; UpdateButton.Hidden = true; // Take action based on the product type switch (Product.ProductType) { case InAppProductType.Consumable: // Show remaining quantity AvailableQuantity.Hidden = false; AvailableQuantity.Text = String.Format ("{0} qty", product.AvailableQuantity); break; case InAppProductType.AutoRenewableSubscription: case InAppProductType.NonRenewingSubscription: // Force this product to use a calculated date product.UseCalculatedExpirationDate = true; // Show expiration date AvailableQuantity.Hidden = false; AvailableQuantity.Text = String.Format ("Exp {0:d}", product.SubscriptionExpirationDate); break; case InAppProductType.FreeSubscription: // Show it never expires AvailableQuantity.Hidden = false; AvailableQuantity.Text = "Unlimited"; break; case InAppProductType.NonConsumable: if (Product.Downloadable) { // Use quantity to show download state if (Product.NewContentAvailable) { AvailableQuantity.Text = string.Format("v{0} Available",Product.DownloadableContentVersion); // Display update button and wire it up _displayContent = false; UpdateButton.Hidden = _purchaseManager.DownloadInProgress; UpdateButton.SetTitle ("Update", UIControlState.Normal); WireupUpdateButton (); } else if (Product.ContentDownloaded) { AvailableQuantity.Text = string.Format("Ready v{0}",Product.DownloadableContentVersion); // Display button _displayContent = true; UpdateButton.Hidden = false; UpdateButton.SetTitle ("Show", UIControlState.Normal); WireupUpdateButton (); } else { AvailableQuantity.Text = "Awaiting Content"; // Display update button and wire it up _displayContent = false; UpdateButton.Hidden = _purchaseManager.DownloadInProgress; UpdateButton.SetTitle ("Get", UIControlState.Normal); WireupUpdateButton (); } AvailableQuantity.Hidden = false; } else { // Not downloadable, hide quantity AvailableQuantity.Hidden = true; } break; default: AvailableQuantity.Hidden = true; break; } }
public void AttachToPurchaseManager(InAppPurchaseManager purchaseManager) { Console.WriteLine("Attached to ThingViewController"); _purchaseManager = purchaseManager; // Respond to events _purchaseManager.ReceivedValidProducts += (products) => { // Received valid products from the iTunes App Store, // Update the display Console.WriteLine("_purchaseManager.ReceivedValidProducts " + products); foreach (var p in products) { Console.WriteLine("--- " + p.ProductIdentifier + " " + p.Price); } ReloadData(); }; _purchaseManager.InAppProductPurchased += (StoreKit.SKPaymentTransaction transaction, InAppProduct product) => { // Update list to remove any non-consumable products that were // purchased Console.WriteLine("_purchaseManager.InAppProductPurchased " + product.ProductIdentifier); ReloadData(); }; _purchaseManager.InAppPurchasesRestored += (count) => { // Update list to remove any non-consumable products that were // purchased and restored Console.WriteLine("_purchaseManager.InAppPurchasesRestored " + count); ReloadData(); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadInProgress += (download) => { // Update the table to display the status of any downloads of hosted content // that we currently have in progress so we are forcing a table reload on the // download progress update. Since the final message will be the raising of the // InAppProductPurchased event, we'll just trap it to clear any completed // downloads instead of listening to the InAppPurchaseContentDownloadCompleted on the // purchase managers transaction observer. Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadInProgress " + string.Format("{0:###}%", _purchaseManager.ActiveDownloadPercent * 100.0f)); ReloadData(); // Display download percent in the badge // StoreTab.BadgeValue = string.Format ("{0:###}%", _purchaseManager.activeDownloadPercent * 100.0f); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadCompleted += (download) => { // Clear badge Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadCompleted"); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadCanceled += (download) => { // Clear badge Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadCanceled"); }; _purchaseManager.TransactionObserver.InAppPurchaseContentDownloadFailed += (download) => { // Inform the user that the download has failed. Normally download would contain // information about the failure that you would want to display to the user, since // we are running in simulation mode download will be null, so just display a // generic failure message. using (var alert = new UIAlertView("Download Failed", "Unable to complete the downloading of content for the product being purchased. Please try again later.", null, "OK", null)) { alert.Show(); } Console.WriteLine("transactionObserver.InAppPurchaseContentDownloadFailed"); // Force the table to reload to remove current download message ReloadData(); }; _purchaseManager.InAppProductPurchaseFailed += (transaction, product) => { // Inform caller that the purchase of the requested product failed. // NOTE: The transaction will normally encode the reason for the failure but since // we are running in the simulated iTune App Store mode, no transaction will be returned. //Display Alert Dialog Box using (var alert = new UIAlertView("Xamarin.InAppPurchase", String.Format("Attempt to purchase {0} has failed.", product.Title), null, "OK", null)) { alert.Show(); } Console.WriteLine("InAppProductPurchaseFailed " + transaction.Error.Code + " " + transaction.Error.LocalizedDescription); // Force a reload to clear any locked items ReloadData(); }; }
public PackView(IntPtr handle) : base(handle) { _purchaseManager = AppDelegate.PurchaseManager; }