Esempio n. 1
0
 protected override void purchase(PackPanel pack)
 {
     if (pack.IsFree)
     {
         download(pack);
     }
     else
     {
         GameBase.GloballyDisableInput = true;
         iap.PurchaseItem(pack.PackId, purchaseCompleteResponse);
     }
 }
Esempio n. 2
0
 void productsResponse(SKProduct[] products)
 {
     GameBase.Scheduler.Add(delegate {
         foreach (SKProduct p in products)
         {
             PackPanel associatedPack = packs.Find(pack => pack.PackId == p.ProductIdentifier);
             if (associatedPack != null)
             {
                 associatedPack.SetPrice(p.LocalizedPrice());
             }
         }
     });
 }
Esempio n. 3
0
        void purchaseCompleteResponse(SKPaymentTransaction transaction, bool wasSuccessful)
        {
            GameBase.GloballyDisableInput = false;

            if (transaction == null)
            {
                return;
            }

            PackPanel pack = packs.Find(p => p.PackId == transaction.Payment.ProductIdentifier);

            if (pack == null)
            {
                return;
            }

            if (wasSuccessful)
            {
#if !DIST
                Console.WriteLine("Receipt is: ");

                foreach (byte b in transaction.TransactionReceipt)
                {
                    Console.Write(b.ToString());
                }
                Console.WriteLine();
#endif

                NSData receiptRaw = transaction.TransactionReceipt;

                if (receiptRaw == null || receiptRaw.Bytes == null)
                {
                    wasSuccessful = false;
                }
                else
                {
                    byte[] dataBytes = new byte[receiptRaw.Length];
                    Marshal.Copy(receiptRaw.Bytes, dataBytes, 0, Convert.ToInt32(receiptRaw.Length));

                    pack.Receipt = dataBytes;

                    download(pack);
                }
            }

            if (!wasSuccessful && transaction.Error != null && transaction.Error.Code != 2)
            {
                GameBase.Notify(transaction.Error.ToString(), null);
            }
        }