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
            PhotoFilterManager.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
            PhotoFilterManager.Purchase(productId);             // it's as though it was purchased again
            FinishTransaction(transaction, true);
        }
示例#3
0
 void UpdateButtons()
 {
     // set whether the user already has purchased these products
     if (PhotoFilterManager.HasPurchased(greyscaleProductId))
     {
         greyscaleButton.Enabled = true;
         greyscaleButton.SetTitle("Use Greyscale Filter", UIControlState.Normal);
         greyscalePurchased = true;
     }
     if (PhotoFilterManager.HasPurchased(sepiaProductId))
     {
         sepiaButton.Enabled = true;
         sepiaButton.SetTitle("Use Sepia Filter ", UIControlState.Normal);
         sepiaPurchased = true;
     }
 }
        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
            PhotoFilterManager.Purchase(productId);
            FinishTransaction(transaction, true);

/*
 *                      if (ReceiptValidation.VerificationController.SharedInstance.VerifyPurchase (transaction)) {
 *                              Console.WriteLine ("Verified!");
 *                              // Register the purchase, so it is remembered for next time
 *                              PhotoFilterManager.Purchase(productId);
 *                              FinishTransaction (transaction, true);
 *                      } else {
 *                              Console.WriteLine ("NOT Verified :(");
 *                              FinishTransaction (transaction, false);
 *                      }
 */
        }
示例#5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region UI layout stuff, not relevant to example
            Title = "Non-Consumable Products";
            View.BackgroundColor = UIColor.White;

            greyscaleButton = UIButton.FromType(UIButtonType.RoundedRect);
            greyscaleButton.SetTitle("loading...", UIControlState.Disabled);
            greyscaleButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled);
            greyscaleButton.SetTitle("Buy...", UIControlState.Normal);
            greyscaleButton.Enabled = false;

            sepiaButton = UIButton.FromType(UIButtonType.RoundedRect);
            sepiaButton.SetTitle("loading...", UIControlState.Disabled);
            sepiaButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled);
            sepiaButton.SetTitle("Buy...", UIControlState.Normal);
            sepiaButton.Enabled = false;

            greyscaleTitle        = new UILabel(new RectangleF(10, 5, 300, 30));
            greyscaleTitle.Font   = UIFont.BoldSystemFontOfSize(18f);
            greyscaleDescription  = new UILabel(new RectangleF(10, 30, 300, 30));
            greyscaleButton.Frame = new RectangleF(10, 65, 180, 40);

            sepiaTitle        = new UILabel(new RectangleF(10, 110, 300, 30));
            sepiaTitle.Font   = UIFont.BoldSystemFontOfSize(18f);
            sepiaDescription  = new UILabel(new RectangleF(10, 135, 300, 30));
            sepiaButton.Frame = new RectangleF(10, 170, 180, 40);

            clearButton = UIButton.FromType(UIButtonType.RoundedRect);
            clearButton.SetTitle("Clear Filter", UIControlState.Normal);
            clearButton.Frame          = new RectangleF(10, 215, 180, 40);
            clearButton.TouchUpInside += (sender, args) => {
                testFilterImage.Image = UIImage.FromFile(testImagePath);
            };

            restoreButton = UIButton.FromType(UIButtonType.RoundedRect);
            restoreButton.SetTitle("Restore", UIControlState.Normal);
            restoreButton.Frame = new RectangleF(200, 215, 110, 40);

            testFilterImage       = new UIImageView(new Rectangle(10, 265, 300, 100));
            testFilterImage.Image = UIImage.FromFile(testImagePath);

            infoLabel       = new UILabel(new RectangleF(10, 340, 300, 80));
            infoLabel.Lines = 3;
            infoLabel.Text  = "Notice how you can only purchase each product once. After that the transaction can't be charged again.";

            View.AddSubview(greyscaleButton);
            View.AddSubview(greyscaleTitle);
            View.AddSubview(greyscaleDescription);
            View.AddSubview(sepiaButton);
            View.AddSubview(sepiaTitle);
            View.AddSubview(sepiaDescription);
            View.AddSubview(testFilterImage);
            View.AddSubview(clearButton);
            View.AddSubview(restoreButton);
            View.AddSubview(infoLabel);
            #endregion

            greyscaleButton.TouchUpInside += (sender, e) => {
                if (greyscalePurchased)
                {
                    // paid for, therefore allow access
                    PhotoFilterManager.ApplyGreyscale(testImagePath, testFilterImage);
                }
                else
                {
                    // initiate payment
                    iap.PurchaseProduct(greyscaleProductId);
                }
            };
            sepiaButton.TouchUpInside += (sender, e) => {
                if (sepiaPurchased)
                {
                    // paid for, therefore allow access
                    PhotoFilterManager.ApplySepia(testImagePath, testFilterImage);
                }
                else
                {
                    // initiate payment
                    iap.PurchaseProduct(sepiaProductId);
                }
            };
            restoreButton.TouchUpInside += (sender, e) => {
                iap.Restore();
            };
        }
 protected override void RestoreTransaction(string productId)
 {
     // it's as though it was purchased again
     PhotoFilterManager.Purchase(productId);
 }
 protected override void CompleteTransaction(string productId)
 {
     // Register the purchase, so it is remembered for next time
     PhotoFilterManager.Purchase(productId);
 }