public void SKPayment_PaymentWithProduct() { SKProduct product = new SKProduct(); SKPayment payment = SKPayment.PaymentWithProduct(product); Assert.IsNotNull(payment); }
public void Buy(SKProduct product) { Console.WriteLine("STORE Buy({0})", product.ProductIdentifier); var payment = SKMutablePayment.PaymentWithProduct(product); SKPaymentQueue.DefaultQueue.AddPayment(payment); }
public async Task PurchaseProduct(SKProduct productId) { _actionSource = new TaskCompletionSource<bool>(); SKPayment payment = SKPayment.PaymentWithProduct(productId); SKPaymentQueue.DefaultQueue.AddPayment (payment); await _actionSource.Task; }
// /// <summary> // /// A Dictionary of product IDs to SKProduct objects that have been successfully initialized. // /// </summary> // /// <value>The initialized products.</value> // [Obsolete("Use the products property.")] // public static Dictionary<string, SKProduct> Products { // get { return _products; } // } /// <summary> /// Returns an initialized SKProduct object matching the specified product ID. /// </summary> /// <returns>The product.</returns> /// <param name="productID">Product ID</param> public static SKProduct GetProduct(string productID) { SKProduct product = null; _products.TryGetValue(productID, out product); return(product); }
void SetVisualState(UIButton button, UILabel title, UILabel description, SKProduct product) { button.Enabled = true; button.SetTitle(string.Format("Buy {0}", product.LocalizedPrice()), UIControlState.Normal); title.Text = product.LocalizedTitle; description.Text = product.LocalizedDescription; }
void Print(SKProduct product) { Console.WriteLine("Product id: {0}", product.ProductIdentifier); Console.WriteLine("Product title: {0}", product.LocalizedTitle); Console.WriteLine("Product description: {0}", product.LocalizedDescription); Console.WriteLine("Product price: {0}", product.Price); Console.WriteLine("Product l10n price: {0}", product.LocalizedPrice()); }
public async Task PurchaseProduct(SKProduct productId) { _actionSource = new TaskCompletionSource <bool>(); SKPayment payment = SKPayment.PaymentWithProduct(productId); SKPaymentQueue.DefaultQueue.AddPayment(payment); await _actionSource.Task; }
public void SetDetails(SKProduct productDetails) { this.lastDetailsRequest = DateTime.Now; this.details = productDetails; if (this.State == ProductState.Unknown) { this.State = ProductState.Loaded; } }
public static void Print(SKProduct product) { Console.WriteLine("Product id: {0}", product.ProductIdentifier); Console.WriteLine("Product title: {0}", product.LocalizedTitle); Console.WriteLine("Product description: {0}", product.LocalizedDescription); Console.WriteLine("Product price: {0}", product.Price); m_id2Description[product.ProductIdentifier] = product.LocalizedTitle; }
public static string LocalizedPrice(this SKProduct product) { using (NSNumberFormatter numberFormatter = new NSNumberFormatter()) { numberFormatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4; numberFormatter.NumberStyle = NSNumberFormatterStyle.Currency; numberFormatter.Locale = product.PriceLocale; return(numberFormatter.StringFromNumber(product.Price).ToString()); } }
public async Task <PurchaseResult> PurchaseProduct(SKProduct product) { try { var purchaser = new ProductPurchaser(); var result = await purchaser.PurchaseProduct(product); return(result); } catch (Exception error) { throw new Exception(string.Format("An error occured purchasing product '{0}' from iTunes", product == null ? "NULL" : (product.ProductIdentifier ?? "NULL PRODUCT IDENTIFIER")), error); } }
public static string LocalizedPrice(this SKProduct product) { var formatter = new NSNumberFormatter(); formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4; formatter.NumberStyle = NSNumberFormatterStyle.Currency; formatter.Locale = product.PriceLocale; var formattedString = formatter.StringFromNumber(product.Price); return(formattedString); }
/// <remarks> /// Use Apple's sample code for formatting a SKProduct price /// https://developer.apple.com/library/ios/#DOCUMENTATION/StoreKit/Reference/SKProduct_Reference/Reference/Reference.html#//apple_ref/occ/instp/SKProduct/priceLocale /// Objective-C version: /// NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; /// [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; /// [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; /// [numberFormatter setLocale:product.priceLocale]; /// NSString *formattedString = [numberFormatter stringFromNumber:product.price]; /// </remarks> public static string LocalizedPrice(this SKProduct product) { var formatter = new NSNumberFormatter(); formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4; formatter.NumberStyle = NSNumberFormatterStyle.Currency; formatter.Locale = product.PriceLocale; var formattedString = formatter.StringFromNumber(product.Price); Console.WriteLine(" ** formatter.StringFromNumber(" + product.Price + ") = " + formattedString + " for locale " + product.PriceLocale.LocaleIdentifier); return(formattedString); }
private static string LocalizedPrice(SKProduct product) { var formatter = new NSNumberFormatter { FormatterBehavior = NSNumberFormatterBehavior.Version_10_4, NumberStyle = NSNumberFormatterStyle.Currency, Locale = product.PriceLocale, }; string formattedString = formatter.StringFromNumber(product.Price); return(formattedString); }
public async Task <PurchaseResult> PurchaseProduct(SKProduct product) { try { SKPaymentQueue.DefaultQueue.AddTransactionObserver(this); _payment = SKPayment.PaymentWithProduct(product); SKPaymentQueue.DefaultQueue.AddPayment(_payment); await Task.Run(() => _waiter.Wait()); return(_result); } finally { SKPaymentQueue.DefaultQueue.RemoveTransactionObserver(this); } }
void Print(SKProduct product) { Console.WriteLine("Product id: {0}", product.ProductIdentifier); Console.WriteLine("Product title: {0}", product.LocalizedTitle); Console.WriteLine("Product description: {0}", product.LocalizedDescription); Console.WriteLine("Product price: {0}", product.Price); Console.WriteLine("Product l10n price: {0}", product.LocalizedPrice()); Console.WriteLine("Product downloadable: {0}", product.Downloadable); // iOS6 Console.WriteLine("Product version: {0}", product.DownloadContentVersion); // iOS6 if (product.DownloadContentLengths != null) { Console.WriteLine("Product length: {0}", product.DownloadContentLengths[0]); // iOS6 } }
public void PurchaseProduct(SKProduct appStoreProductId) { NetworkStatus internetStatus = Reachability.InternetConnectionStatus (); //make sure the internet is still good. If it is, go ahead. if (internetStatus == NetworkStatus.NotReachable) { NSNotificationCenter.DefaultCenter.PostNotificationName (NoInternetNotification, null); Console.WriteLine ("No Internet"); } else { Console.WriteLine ("PurchaseProduct " + appStoreProductId); SKPayment payment = SKPayment.PaymentWithProduct (appStoreProductId); SKPaymentQueue.DefaultQueue.AddPayment (payment); } }
/// <remarks> /// Use Apple's sample code for formatting a SKProduct price /// https://developer.apple.com/library/ios/#DOCUMENTATION/StoreKit/Reference/SKProduct_Reference/Reference/Reference.html#//apple_ref/occ/instp/SKProduct/priceLocale /// Objective-C version: /// NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; /// [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; /// [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; /// [numberFormatter setLocale:product.priceLocale]; /// NSString *formattedString = [numberFormatter stringFromNumber:product.price]; /// </remarks> public static string LocalizedPrice(this SKProduct product) { if (product?.PriceLocale == null) { return(string.Empty); } var formatter = new NSNumberFormatter() { FormatterBehavior = NSNumberFormatterBehavior.Version_10_4, NumberStyle = NSNumberFormatterStyle.Currency, Locale = product.PriceLocale }; var formattedString = formatter.StringFromNumber(product.Price); Console.WriteLine(" ** formatter.StringFromNumber(" + product.Price + ") = " + formattedString + " for locale " + product.PriceLocale.LocaleIdentifier); return(formattedString); }
public static SubscriptionPeriod ToSubscriptionPeriod(this SKProduct p) { if (!InAppBillingImplementation.HasIntroductoryOffer) { return(SubscriptionPeriod.Unknown); } if (p?.SubscriptionPeriod?.Unit == null) { return(SubscriptionPeriod.Unknown); } return(p.SubscriptionPeriod.Unit switch { SKProductPeriodUnit.Day => SubscriptionPeriod.Day, SKProductPeriodUnit.Month => SubscriptionPeriod.Month, SKProductPeriodUnit.Year => SubscriptionPeriod.Year, SKProductPeriodUnit.Week => SubscriptionPeriod.Week, _ => SubscriptionPeriod.Unknown, });
void OnInitializationCompleted(object sender, InitializationEventArgs e) { Log("InitializationCompleted"); SKProduct product = IAPXT.GetProduct(premiumProductID); if (product == null) { Log("Error: Product not defined: " + premiumProductID); return; } Log("title: " + product.localizedTitle); Log("description: " + product.localizedDescription); var price = product.price; Log("price type: " + price.GetType()); Log("price: " + price); Log("localized price: " + product.localizedPrice); }
public void PurchaseProduct(SKProduct product) { try { if (Reachability.InternetConnectionStatus() == NetworkStatus.NotReachable) { Logger.Log("ERROR: PurchaseProduct: No open internet connection is available."); using (var alert = new UIAlertView("ERROR", "No open internet connection is available.", null, "OK", null)) alert.Show(); return; } if (!CanMakePayments()) { Logger.Log("ERROR: PurchaseProduct: Cannot make payments"); using (var alert = new UIAlertView("ERROR", "Sorry but you cannot make purchases from the In App Billing store. Please try again later.", null, "OK", null)) alert.Show(); return; } if (product == null) { Logger.Log("ERROR: PurchaseProduct: Product is null"); return; } Logger.Log("PurchaseProduct: Product ID: " + product.ProductIdentifier); SKPayment payment = SKPayment.CreateFrom(product); SKPaymentQueue.DefaultQueue.AddPayment(payment); } catch (Exception ex) { Logger.Log("ERROR: PurchaseProduct: " + ex); } }
private void PurchaseProduct(SKProduct product, int quantity) { if (product == null) throw new ArgumentNullException("InAppPurchaseManager: Product is not valid."); try { if (observer == null) { observer = new PaymentTransactionObserver(this); SKPaymentQueue.DefaultQueue.AddTransactionObserver(observer); } if (quantity > 1) { SKMutablePayment payment = SKMutablePayment.PaymentWithProduct(product); payment.Quantity = quantity; SKPaymentQueue.DefaultQueue.AddPayment(payment); } else { SKPayment payment = SKPayment.PaymentWithProduct(product); SKPaymentQueue.DefaultQueue.AddPayment(payment); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); OnPurchaseFailed(new InAppPurchaseException("Error executing in-app purchase.", 0, ex)); } }
public override bool ShouldAddStorePayment(SKPaymentQueue queue, SKPayment payment, SKProduct product) { return(true); }
public SKProductInformation(SKProduct product) : base(product.ProductIdentifier) { Product = product; }
private void PurchaseProduct(SKProduct product) { Console.WriteLine ("disable"); UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; UIApplication.SharedApplication.BeginIgnoringInteractionEvents(); iap.PurchaseProduct (product); }
public override void ViewWillAppear (bool animated) { base.ViewWillAppear (animated); priceObserver = NSNotificationCenter.DefaultCenter.AddObserver (InAppPurchaseManager.InAppPurchaseManagerProductsFetchedNotification, (notification) => { //the code that will run when product info is retrieved from apple var info = notification.UserInfo; //assign product ID's frontingProduct = (SKProduct) info.ObjectForKey(NSProdID); fcdProduct=(SKProduct) info.ObjectForKey(keyFCD); stoppingProduct = (SKProduct) info.ObjectForKey(keyStopping); glidingProduct = (SKProduct) info.ObjectForKey(keyGliding); multiProduct = (SKProduct) info.ObjectForKey(keyMulti); stridencyProduct = (SKProduct) info.ObjectForKey(keySD); preProduct = (SKProduct) info.ObjectForKey(keyPre); postProduct = (SKProduct) info.ObjectForKey(keyPost); crProduct = (SKProduct) (SKProduct) info.ObjectForKey(keyCR); //set button titles if(!iapHelpers.hasPurchased("fronting")) { this.btnFronting.SetTitle("Fronting - "+frontingProduct.Price.ToString(), UIControlState.Normal); this.btnFronting.Enabled = true; } if(!iapHelpers.hasPurchased("cluster_reduction")) { this.btnCluster.SetTitle("Cluster Reduction - " + crProduct.Price.ToString(), UIControlState.Normal); this.btnCluster.Enabled = true; } if(!iapHelpers.hasPurchased("stopping")) { this.btnStopping.SetTitle("Stopping - " + stoppingProduct.Price.ToString(), UIControlState.Normal); this.btnStopping.Enabled = true; } if(!iapHelpers.hasPurchased("postvocalic")) { this.btnPostVoicing.SetTitle("Post-Vocalic Voicing - " + postProduct.Price.ToString(), UIControlState.Normal); this.btnPostVoicing.Enabled = true; } if(!iapHelpers.hasPurchased("gliding")) { this.btnGliding.SetTitle("Gliding - " + glidingProduct.Price.ToString(), UIControlState.Normal); this.btnGliding.Enabled = true; } if(!iapHelpers.hasPurchased("prevocalic")) { this.btnPreVoicing.SetTitle("Pre-Vocalic Voicing - " + preProduct.Price.ToString(),UIControlState.Normal); this.btnPreVoicing.Enabled = true; } if(!iapHelpers.hasPurchased("stridency_deletion")) { this.btnStridency.SetTitle("Stridency Deletion - " + stridencyProduct.Price.ToString(), UIControlState.Normal); this.btnStridency.Enabled = true; } if(!iapHelpers.hasPurchased("multi")) { this.btnMulti.SetTitle("Multi-Syllabalic Words - " + multiProduct.Price.ToString(), UIControlState.Normal); this.btnMulti.Enabled = true; } if(!iapHelpers.hasPurchased("final_consonant")) { this.btnFinalConsonant.SetTitle("Final Consonant Deletion - " + fcdProduct.Price.ToString(), UIControlState.Normal); this.btnFinalConsonant.Enabled = true; } Console.WriteLine("here"); }); succeededObserver = NSNotificationCenter.DefaultCenter.AddObserver (InAppPurchaseManager.InAppPurchaseManagerTransactionSucceededNotification, (notification) => { // update the buttons after a successful purchase buttonCheck(); }); requestObserver = NSNotificationCenter.DefaultCenter.AddObserver (InAppPurchaseManager.InAppPurchaseManagerRequestFailedNotification, (notification) => { UIAlertView alert = new UIAlertView("App Store Error", "There was a problem connecting to the App Store. Feel free to utilize items which have already been purchased",null,"OK",null); alert.Show(); }); failedObserver = NSNotificationCenter.DefaultCenter.AddObserver(InAppPurchaseManager.InAppPurchaseManagerTransactionFailedNotification, (notification)=>{ UIAlertView alert2 = new UIAlertView("Transaction Failed","The purchase was unsuccessful. You will not be charged. Please make sure you are properly connected to the App Store and try again",null,"OK",null); alert2.Show(); }); List<String> allProdStrings = iapHelpers.getAllKeys (); iap.RequestProductData (allProdStrings); }
void Print(SKProduct product) { Console.WriteLine("Product id: {0}", product.ProductIdentifier); Console.WriteLine("Product title: {0}", product.LocalizedTitle); Console.WriteLine("Product description: {0}", product.LocalizedDescription); Console.WriteLine("Product price: {0}", product.Price); Console.WriteLine("Product l10n price: {0}", product.LocalizedPrice()); Console.WriteLine("Product downloadable: {0}", product.Downloadable); // iOS6 Console.WriteLine("Product version: {0}", product.DownloadContentVersion); // iOS6 if (product.DownloadContentLengths != null) Console.WriteLine("Product length: {0}", product.DownloadContentLengths[0]); // iOS6 }
public void Buy (SKProduct product) { Console.WriteLine ("STORE Buy({0})", product.ProductIdentifier); var payment = SKMutablePayment.PaymentWithProduct (product); SKPaymentQueue.DefaultQueue.AddPayment (payment); }
public override bool ShouldAddStorePayment(SKPaymentQueue queue, SKPayment payment, SKProduct product) { return(onShouldAddStorePayment?.Invoke(queue, payment, product) ?? false); }
public void SetDetails(SKProduct productDetails) { this.lastDetailsRequest = DateTime.Now; this.details = productDetails; if (this.State == ProductState.Unknown) this.State = ProductState.Loaded; }
void SetVisualState(UIButton buyBtn, UILabel title, UILabel description, SKProduct product) { buyBtn.Enabled = true; buyBtn.SetTitle(String.Format (Buy, product.LocalizedPrice()), UIControlState.Normal); title.Text = product.LocalizedTitle; description.Text = product.LocalizedDescription; }
bool OnShouldAddStorePayment(SKPaymentQueue queue, SKPayment payment, SKProduct product) { // true in app purchase is initiated, false cancels it. // you can check if it was already purchased. return(true); }
bool OnShouldAddStorePayment(SKPaymentQueue queue, SKPayment payment, SKProduct product) { SettingsService.IsPro = true; SettingsService.NeedsProSync = true; return(true); }
void SetVisualState(UIButton button, UILabel title, UILabel description, SKProduct product) { var btnTitle = string.Format ("Buy {0}", product.LocalizedPrice ()); button.Enabled = true; button.SetTitle (btnTitle, UIControlState.Normal); title.Text = product.LocalizedTitle; description.Text = product.LocalizedDescription; }
public static SKPayment PaymentWithProduct(SKProduct product) { return CreateFrom (product); }
public static SKPayment PaymentWithProduct(SKProduct product) { return(CreateFrom(product)); }
private string LocalizedPrice(SKProduct product) { var formatter = new NSNumberFormatter(); formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4; formatter.NumberStyle = NSNumberFormatterStyle.Currency; formatter.Locale = product.PriceLocale; var formattedString = formatter.StringFromNumber(product.Price); return formattedString; }