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(string productId) { _actionSource = new TaskCompletionSource <bool>(); var payment = SKMutablePayment.PaymentWithProduct(productId); SKPaymentQueue.DefaultQueue.AddPayment(payment); await _actionSource.Task; }
public async Task PurchaseProduct(string productId) { this.Log().Debug("Preparing to purchase: " + productId); _actionSource = new TaskCompletionSource <bool>(); var payment = SKMutablePayment.PaymentWithProduct(productId); SKPaymentQueue.DefaultQueue.AddPayment(payment); await _actionSource.Task; }
/// <summary> /// Buy a product with specified productID and quantity. /// </summary> /// <remarks> /// This method starts a transaction with the server. /// If the DisplayActivityIndicator property is true, a semi-transparent native activity indicator view with label /// would cover the entire screen, blocking any user input from Unity. /// If you set the DisplayActivityIndicator property to false, you should provide a similar view blocking input /// during the purchase process so the user cannot start another purchase at the same time, for example. /// <p></p> /// On transaction complete, it raises either the TransactionCompleted or TransactionFailed event. /// On TransactionCompleted event, you should provide content to the user for what they have just bought. /// On TransactionFailed event, you can display an error message to the user. /// If the product has hosted download on Apple servers (available iOS 6.0 and later), /// the content would have been extracted and moved to app-storage:/downloads/[productID]/ by the time this event is raised. /// You can then move it somewhere else or use it as it is. /// </remarks> /// <returns><c>true</c> if a transaction has started; <c>false</c> otherwise.</returns> /// <param name="productID">The product to buy.</param> /// <param name="quantity">The quantity of the product to buy; it should be 1 for non-consumables.</param> public static bool Buy(string productID, int quantity = 1) { if (quantity <= 0) { return(false); } var product = GetProduct(productID); if (product == null) { return(false); } _ShowActivityIndicator(" Purchasing..."); var payment = SKMutablePayment.Payment(product); payment.quantity = quantity; SKPaymentQueue.DefaultQueue().AddPayment(payment); return(true); }