public void CompleteTransaction(SKPaymentTransaction transaction) { Console.WriteLine("CompleteTransaction " + transaction.TransactionIdentifier); var productId = transaction.Payment.ProductIdentifier; // Register the purchase, so it is remembered for next time HostedProductManager.Purchase(productId); FinishTransaction(transaction, true); }
public void RestoreTransaction(SKPaymentTransaction transaction) { // Restored Transactions always have an 'original transaction' attached Console.WriteLine("RestoreTransaction " + transaction.TransactionIdentifier + "; OriginalTransaction " + transaction.OriginalTransaction.TransactionIdentifier); var productId = transaction.OriginalTransaction.Payment.ProductIdentifier; // Register the purchase, so it is remembered for next time HostedProductManager.Purchase(productId); // it's as though it was purchased again FinishTransaction(transaction, true); }
void UpdateButtons() { // set whether the user already has purchased these products if (HostedProductManager.HasPurchased(hostedImagesProductId)) { hostedImagesButton.Enabled = true; hostedImagesButton.SetTitle("Read Images Chapter", UIControlState.Normal); hostedImagesPurchased = true; } if (HostedProductManager.HasPurchased(hostedFilesystemProductId)) { hostedFilesystemButton.Enabled = true; hostedFilesystemButton.SetTitle("Read FileSystem Chapter ", UIControlState.Normal); hostedFilesystemPurchased = true; } }
void UpdateButtons() { // set whether the user already has purchased these products if (HostedProductManager.HasPurchased(oldeStyleProductId)) { oldStyleButton.Enabled = true; oldStyleButton.SetTitle("Read Images Chapter", UIControlState.Normal); oldeStylePurchased = true; } if (HostedProductManager.HasPurchased(eightBitProductId)) { eightBitButton.Enabled = true; eightBitButton.SetTitle("Read FileSystem Chapter ", UIControlState.Normal); eightBitPurchased = true; } }
protected override void RestoreTransaction(string productId) { HostedProductManager.Purchase(productId); // it's as though it was purchased again }
protected override void CompleteTransaction(string productId) { // Register the purchase, so it is remembered for next time HostedProductManager.Purchase(productId); }
public override void ViewDidLoad() { base.ViewDidLoad(); #region UI layout stuff, not relevant to example Title = "Hosted Products"; View.BackgroundColor = UIColor.White; hostedImagesButton = UIButton.FromType(UIButtonType.RoundedRect); hostedImagesButton.SetTitle("loading...", UIControlState.Disabled); hostedImagesButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled); hostedImagesButton.SetTitle("Buy...", UIControlState.Normal); hostedImagesButton.Enabled = false; hostedFilesystemButton = UIButton.FromType(UIButtonType.RoundedRect); hostedFilesystemButton.SetTitle("loading...", UIControlState.Disabled); hostedFilesystemButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled); hostedFilesystemButton.SetTitle("Buy...", UIControlState.Normal); hostedFilesystemButton.Enabled = false; hostedImagesTitle = new UILabel(new RectangleF(10, 5, 300, 30)); hostedImagesTitle.Font = UIFont.BoldSystemFontOfSize(18f); hostedImagesDescription = new UILabel(new RectangleF(10, 30, 300, 30)); hostedImagesButton.Frame = new RectangleF(10, 65, 180, 40); hostedFilesystemTitle = new UILabel(new RectangleF(10, 110, 300, 30)); hostedFilesystemTitle.Font = UIFont.BoldSystemFontOfSize(18f); hostedFilesystemDescription = new UILabel(new RectangleF(10, 135, 300, 30)); hostedFilesystemButton.Frame = new RectangleF(10, 170, 180, 40); restoreButton = UIButton.FromType(UIButtonType.RoundedRect); restoreButton.SetTitle("Restore", UIControlState.Normal); restoreButton.Frame = new RectangleF(200, 170, 110, 40); bookTextDisplay = new UITextView(new RectangleF(10, 215, 300, 200)); bookTextDisplay.Text = ""; bookTextDisplay.ScrollEnabled = true; bookTextDisplay.Editable = false; bookIcon = new UIImageView(new RectangleF(240, 210, 60, 60)); View.AddSubview(hostedImagesButton); View.AddSubview(hostedImagesTitle); View.AddSubview(hostedImagesDescription); View.AddSubview(hostedFilesystemButton); View.AddSubview(hostedFilesystemTitle); View.AddSubview(hostedFilesystemDescription); View.AddSubview(restoreButton); View.AddSubview(bookTextDisplay); View.AddSubview(bookIcon); #endregion hostedImagesButton.TouchUpInside += (sender, e) => { if (hostedImagesPurchased) { // paid for, therefore allow access HostedProductManager.Read(hostedImagesProductId, bookTextDisplay, bookIcon); } else { // initiate payment iap.PurchaseProduct(hostedImagesProductId); } }; hostedFilesystemButton.TouchUpInside += (sender, e) => { if (hostedFilesystemPurchased) { // paid for, therefore allow access HostedProductManager.Read(hostedFilesystemProductId, bookTextDisplay, bookIcon); } else { // initiate payment iap.PurchaseProduct(hostedFilesystemProductId); } }; restoreButton.TouchUpInside += (sender, e) => { iap.Restore(); }; }