Exemplo n.º 1
0
 /**
  * Notifies observers of the purchase state change of the specified item.
  *
  * @param itemId
  *            id of the item whose purchase state has changed.
  * @param state
  *            new purchase state of the item.
  */
 private static void notifyPurchaseStateChange(string itemId, PurchaseState state)
 {
     foreach (IBillingObserver o in observers)
     {
         o.onPurchaseStateChanged(itemId, state);
     }
 }
Exemplo n.º 2
0
    public override void Execute()
    {
        PurchaseState purchaseState = StoreKitHelper.GetPurchaseState();

        Debug.Log("the state is : " + purchaseState.ToString());
        if (purchaseState == PurchaseState.PurchaseSuccess)
        {
            iOSConfirmContext confirmContext = new iOSConfirmContext();
            this.ShopModule.ChangeContext(confirmContext);
            confirmContext.StartProductConfirm(this.m_ProductID);
        }
        else if (purchaseState == PurchaseState.PurchaseFail || purchaseState == PurchaseState.PurchaseCancel)
        {
            iOSIdleContext idleContext = new iOSIdleContext();
            this.ShopModule.ChangeContext(idleContext);
            if (purchaseState == PurchaseState.PurchaseFail)
            {
                this.ShopModule.State = ShopActionState.Fail;
                PurchaseFailInformation failInformation = new PurchaseFailInformation();
                failInformation.Reason           = PurchaseFailedReason.Abort;
                failInformation.ErrorDescription = ClientStringConstants.PURCHASE_FAIL_TIPS;
                this.ShopModule.OnPurchaseFailed(failInformation);
            }
            else
            {
                this.ShopModule.State = ShopActionState.Cancel;
                PurchaseFailInformation failInformation = new PurchaseFailInformation();
                failInformation.Reason           = PurchaseFailedReason.Cancel;
                failInformation.ErrorDescription = ClientStringConstants.PURCHASE_FAIL_TIPS;
                this.ShopModule.OnPurchaseFailed(failInformation);
            }
        }
    }
Exemplo n.º 3
0
 public PurchaseResult(string productIdentifier, PurchaseState state, string applicationUsername = "", string receipt = "", string transactionIdentifier = "") : base()
 {
     _ProductIdentifier     = productIdentifier;
     _State                 = state;
     _Receipt               = receipt;
     _TransactionIdentifier = transactionIdentifier;
     _ApplicationUsername   = applicationUsername;
 }
Exemplo n.º 4
0
 private void Awake()
 {
     if (null == Instance)
     {
         Instance = this;
     }
     else if (this != Instance)
     {
         Destroy(this);
     }
 }
Exemplo n.º 5
0
        public bool AssignPurchase(int purchaseId, string purchaserUserGuid, PurchaseState purchaseState)
        {
            const string query = "Update Purchases " +
                                 "Set AssignedUser = @PurchaserUserGuid, State= @purchaseState" +
                                 " Where Id = @purchaseId";

            _sqliteDataProvider.AddParameter("@purchaseId", purchaseId);
            _sqliteDataProvider.AddParameter("@purchaserUserGuid", purchaserUserGuid);
            _sqliteDataProvider.AddParameter("@purchaseState", purchaseState);
            return(_sqliteDataProvider.ExecuteNonQuery(query) > 0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Inserts a purchased product into the database. There may be multiple
        /// rows in the table for the same product if it was purchased multiple times
        /// or if it was refunded. </summary>
        /// <param name="orderId"> the order ID (matches the value in the product list) </param>
        /// <param name="productId"> the product ID (sku) </param>
        /// <param name="state"> the state of the purchase </param>
        /// <param name="purchaseTime"> the purchase time (in milliseconds since the epoch) </param>
        /// <param name="developerPayload"> the developer provided "payload" associated with
        ///     the order. </param>
        private void insertOrder(string orderId, string productId, PurchaseState state, long purchaseTime, string developerPayload)
        {
            ContentValues values = new ContentValues();

            values.Put(HISTORY_ORDER_ID_COL, orderId);
            values.Put(HISTORY_PRODUCT_ID_COL, productId);
            values.Put(HISTORY_STATE_COL, state.ToString());
            values.Put(HISTORY_PURCHASE_TIME_COL, purchaseTime);
            values.Put(HISTORY_DEVELOPER_PAYLOAD_COL, developerPayload);
            mDb.Replace(PURCHASE_HISTORY_TABLE_NAME, null, values); // nullColumnHack
        }
Exemplo n.º 7
0
 public Transaction(String orderId, String productId, String packageName, PurchaseState purchaseState,
                    String notificationId, long purchaseTime, String developerPayload)
 {
     this.orderId          = orderId;
     this.productId        = productId;
     this.packageName      = packageName;
     this.purchaseState    = purchaseState;
     this.notificationId   = notificationId;
     this.purchaseTime     = purchaseTime;
     this.developerPayload = developerPayload;
 }
Exemplo n.º 8
0
        void DoPurchase()
        {
            // Set the state
            m_State = PurchaseState.PurchasingProduct;

            // Open the purchase confirmation
            PurchaseSystem.Instance.Display(Happiness.Game.AccountId, m_Products[m_iSelectedProduct].ProductID);

            // Querry the server for the credits/vip
            m_VerifyPurchase = Happiness.Game.ServerWriter.WaitForPurchaseComplete();
        }
 /// <summary>
 /// Updates the UI after the database has been updated.  This method runs
 /// in a background thread so it has to post a Runnable to run on the UI
 /// thread. </summary>
 /// <param name="purchaseState"> the purchase state of the item </param>
 /// <param name="itemId"> a string identifying the item </param>
 /// <param name="quantity"> the quantity of items in this purchase </param>
 //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
 //ORIGINAL LINE: void postPurchaseStateChange(final InAppBilling.Consts.PurchaseState purchaseState, final String itemId, final int quantity, final long purchaseTime, final String developerPayload)
 internal virtual void postPurchaseStateChange(PurchaseState purchaseState, string itemId, int quantity, long purchaseTime, string developerPayload)
 {
     //JAVA TO C# CONVERTER TODO TASK: Anonymous inner classes are not converted to C# if the base type is not defined in the code being converted:
     //			mHandler.post(new Runnable()
     //		{
     //			public void run()
     //			{
     //				onPurchaseStateChange(purchaseState, itemId, quantity, purchaseTime, developerPayload);
     //			}
     //		});
 }
Exemplo n.º 10
0
        void SetupProducts(NetworkCore.GlobalProduct[] products)
        {
            m_State = PurchaseState.SelectingProduct;

            foreach (NetworkCore.GlobalProduct p in products)
            {
                ProductDisplay disp = new ProductDisplay(p, m_ScrollRect.Left, m_ScrollRect.Width);
                m_Products.Add(disp);
            }

            int productsHeight = (int)(m_Products.Count * m_Products[0].Height);

            m_ScrollMax = (m_ScrollRect.Height < productsHeight) ? productsHeight - m_ScrollRect.Height : 0;
        }
Exemplo n.º 11
0
        void DoPurchase()
        {
            // Set the state
            m_State = PurchaseState.PurchasingProduct;

            // Open the browser
#if DEBUG
            string host = "localhost:8080";
#else
            string host = "www.ronzgames.com/braintree";
#endif
            string url = string.Format("http://{0}/purchase?uid={1}&pid={2}", host, Happiness.Game.AccountId, m_Products[m_iSelectedProduct].ProductID);
            System.Diagnostics.Process.Start(url);

            // Querry the server for the credits/vip
            m_VerifyPurchase = Happiness.Game.ServerWriter.WaitForPurchaseComplete();
        }
Exemplo n.º 12
0
        public static bool AreAdsRemoved(PurchaseState state)
        {
            switch (state)
            {
            case PurchaseState.Restored:
            case PurchaseState.Purchasing:
            case PurchaseState.Deferred:
            case PurchaseState.Purchased:
                return(true);

            case PurchaseState.Canceled:
            case PurchaseState.Refunded:
            case PurchaseState.Failed:
            case PurchaseState.Unknown:
            default:
                return(false);
            }
        }
Exemplo n.º 13
0
        // Return false if this menu should close
        public bool HandleClick(int iX, int iY)
        {
            if (m_State == PurchaseState.SelectingProduct)
            {
                if (m_ScrollRect.Contains(iX, iY))
                {
                    foreach (ProductDisplay pd in m_Products)
                    {
                        pd.Selected = false;
                    }
                    int product = (int)((iY - (m_ScrollRect.Top - m_ScrollPosition)) / m_Products[0].Height);
                    m_Products[product].Selected = true;

                    if (m_Products[product].Button.Click(iX, iY))
                    {
                        PurchaseProduct(product);
                        return(true);
                    }
                }
            }

            if (m_State == PurchaseState.ConfirmingPurchase &&
                (m_PurchaseButton.Click(iX, iY) || m_Products[m_iSelectedProduct].Button.Click(iX, iY)))
            {
                DoPurchase();
            }

            if (m_CancelButton.Click(iX, iY))
            {
                if (m_State == PurchaseState.ConfirmingPurchase)
                {
                    m_State = PurchaseState.SelectingProduct;
                    return(true);
                }
                if (m_VerifyPurchase != null)
                {
                    m_VerifyPurchase.Destroy(); // Allow this to be destroyed when its done
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 14
0
    private PurchaseState getPurchaseState(string pt)
    {
        PurchaseState result = PurchaseState.Purchased;

        switch (pt)
        {
        case "Purchased":
            result = PurchaseState.Purchased;
            break;

        case "Canceled":
            result = PurchaseState.Canceled;
            break;

        case "Refunded":
            result = PurchaseState.Refunded;
            break;
        }
        return(result);
    }
Exemplo n.º 15
0
        public async Task <bool> CheckOut(Guid purchaseGuid, PurchaseState purchaseState = PurchaseState.Paid)
        {
            using (var db = new StationContext())
            {
                var myPurchase = await db.Purchases.FindAsync(purchaseGuid);

                if (myPurchase == null)
                {
                    throw new InvalidOperationException("ITEM_NOT_FOUND");
                }
                if (myPurchase.PurchaseState == purchaseState)
                {
                    throw new InvalidOperationException("ITEM_ALREADY_PAID");
                }

                myPurchase.PurchaseState = purchaseState;
                db.Purchases.Attach(myPurchase);
                db.Entry(myPurchase).State = EntityState.Modified;
                return(await db.SaveChangesAsync() > 0);
            }
        }
Exemplo n.º 16
0
    // Start is called before the first frame update
    void Start()
    {
        roundImage.enabled        = false;
        roundNotification.enabled = false;
        lastLives      = lives;
        lastRound      = round;
        selectionDelay = float.MinValue;
        purchaseState  = PurchaseState.None;
        groundTiles    = GameObject.Find("Grid").GetComponentInChildren <Tilemap>();
        reservedTiles  = new ArrayList();

        // Add lines to tile

        /*string[] lines = System.IO.File.ReadAllLines("Assets/Scripts/ReservedTiles.txt");
         * foreach (string line in lines)
         * {
         *  string[] coords = line.Split(',');
         *  reservedTiles.Add(
         *      new Vector3Int(int.Parse(coords[0], System.Globalization.NumberStyles.AllowLeadingSign),
         *      int.Parse(coords[1], System.Globalization.NumberStyles.AllowLeadingSign), 0));
         * }
         * trueReservedTiles = lines.Length;*/

        defenses    = new GameObject[4];
        defenses[0] = (GameObject)Resources.Load("Prefabs/DefenseObjects/Defense1");
        defenses[1] = (GameObject)Resources.Load("Prefabs/DefenseObjects/Defense2");
        defenses[2] = (GameObject)Resources.Load("Prefabs/DefenseObjects/Defense3");
        defenses[3] = (GameObject)Resources.Load("Prefabs/DefenseObjects/Defense4");
        background  = (Tile)Resources.Load("Tilesets/Tiles/Ground Tiles/TileSet_V2_47");
        canPlace    = (Tile)Resources.Load("Tilesets/Tiles/Ground Tiles/canPlace");
        // cannotPlace = (Tile)Resources.Load("Tilesets/Tiles/Ground Tiles/cannotPlace");
        curTile = new Vector3Int(int.MaxValue, int.MaxValue, int.MaxValue);

        Debug.Assert(groundTiles != null);
        Debug.Assert(canPlace != null);
        // Debug.Assert(cannotPlace != null);
        Debug.Assert(background != null);

        Vector3 dir = transform.transform.localPosition - transform.position;
    }
Exemplo n.º 17
0
 public void Update(GameTime gameTime)
 {
     if (m_State == PurchaseState.FetchingProducts)
     {
         if (m_ProductsRequest != null && m_ProductsRequest.Finished)
         {
             SetupProducts(m_ProductsRequest.Products);
             m_ProductsRequest.Destroy();
             m_ProductsRequest = null;
         }
     }
     if (m_State == PurchaseState.PurchasingProduct)
     {
         if (m_VerifyPurchase != null && m_VerifyPurchase.Finished)
         {
             m_State             = PurchaseState.PurchaseComplete;
             m_CancelButton.Text = "Close";
             m_VerifyPurchase.Destroy();
             m_VerifyPurchase = null;
         }
     }
 }
Exemplo n.º 18
0
        public virtual int updatePurchase(string orderId, string productId, PurchaseState purchaseState, long purchaseTime, string developerPayload)
        {
            insertOrder(orderId, productId, purchaseState, purchaseTime, developerPayload);
            ICursor ICursor = mDb.Query(PURCHASE_HISTORY_TABLE_NAME, HISTORY_COLUMNS, HISTORY_PRODUCT_ID_COL + "=?", new string[] { productId }, null, null, null, null);

            if (ICursor == null)
            {
                return(0);
            }
            int quantity = 0;

            try
            {
                // Count the number of times the product was purchased
                while (ICursor.MoveToNext())
                {
                    int           stateIndex = ICursor.GetInt(2);
                    PurchaseState state      = (PurchaseState)stateIndex;
                    // Note that a refunded purchase is treated as a purchase. Such
                    // a friendly refund policy is nice for the user.
                    if (state == PurchaseState.PURCHASED || state == PurchaseState.REFUNDED)
                    {
                        quantity += 1;
                    }
                }

                // Update the "purchased items" table
                updatePurchasedItem(productId, quantity);
            }
            catch
            {
                if (ICursor != null)
                {
                    ICursor.Close();
                }
            }
            return(quantity);
        }
Exemplo n.º 19
0
    public override void Execute()
    {
        PurchaseState purchaseState = StoreKitHelper.GetPurchaseState();

        Debug.Log("the state is : " + purchaseState.ToString());

        /*
         * if(purchaseState == PurchaseState.PurchasePurchasing)
         * {
         *      NetWorkDialog.Instance.HideConnectingWithoutManager();
         * }
         */
        if (purchaseState == PurchaseState.PurchaseSuccess)
        {
            ConfirmingContext confirmingContext = new ConfirmingContext()
            {
                ProductID = this.ProductID
            };
            this.ShopModule.ChangeContext(confirmingContext);
        }
        else if (purchaseState == PurchaseState.PurchaseFail || purchaseState == PurchaseState.PurchaseCancel)
        {
            IdleContext idleContext = new IdleContext();
            this.ShopModule.ChangeContext(idleContext);
            if (purchaseState == PurchaseState.PurchaseFail)
            {
                this.ShopModule.State = ShopActionState.Fail;
                //this.ShopModule.OnPurchaseFailed(PurchaseFailedReason.Abort);
            }
            else
            {
                this.ShopModule.State = ShopActionState.Cancel;
                //this.ShopModule.OnPurchaseFailed(PurchaseFailedReason.Cancel);
            }
        }
    }
Exemplo n.º 20
0
 public static new void RegisterInAppPurchase(PurchaseState purchaseState, string purchaseToken, string productId, string orderId, DateTime purchaseTime, string developerPayload, double price, string currency)
 {
     Debug.Log("FuseAPI:RegisterInAppPurchase(" + purchaseState.ToString() + "," + purchaseToken + "," + productId + "," + orderId + "," + DateTimeToTimestamp(purchaseTime) + "," + developerPayload + "," + price + "," + currency + ")");
     _fuseUnityPlugin.CallStatic("registerInAppPurchase", purchaseState.ToString(), purchaseToken, productId, orderId, DateTimeToTimestamp(purchaseTime), developerPayload, price, currency);
 }
Exemplo n.º 21
0
 public IEnumerable <Purchase> GetByPurchaseState(PurchaseState purchaseState)
 {
     return(PurchasesTable.Where(p => p.InvState == purchaseState));
 }
Exemplo n.º 22
0
 public abstract void onPurchaseStateChanged(String itemId, PurchaseState state);
Exemplo n.º 23
0
 public override void onPurchaseStateChanged(String itemId, PurchaseState state)
 {
     this.onPurchaseStateChanged(itemId, state);
 }
Exemplo n.º 24
0
 public void onPurchaseStateChanged(string itemId, PurchaseState state)
 {
     onPurchaseStateChanged(itemId, state);
 }
Exemplo n.º 25
0
 public void onPurchaseStateChanged(string itemId, PurchaseState state)
 {
     Log.Info(TAG, "onPurchaseStateChanged() itemId: " + itemId);
     updateOwnedItems();
 }
Exemplo n.º 26
0
        internal static async Task <double> StaticGetPurchasedSum(ProductType?product, PurchaseState purchaseState, DateTime?startDate, DateTime?endDate)
        {
            return(await Task.Run(() => {
                using (var db = new StationContext()) {
                    switch (product)
                    {
                    case null:
                        if (!db.Purchases.Any(t => t.PurchaseState == purchaseState && !t.IsDeleted))
                        {
                            return 0;
                        }

                        if (startDate == null || endDate == null)
                        {
                            return db.Purchases.Where(t => t.PurchaseState == purchaseState && !t.IsDeleted).Sum(t => t.Sum);
                        }

                        return db.Purchases.Any(t =>
                                                t.PurchaseState == purchaseState && !t.IsDeleted &&
                                                t.PurchaseDate >= startDate &&
                                                t.PurchaseDate <= endDate)
                                ? db.Purchases.Where(t =>
                                                     t.PurchaseState == purchaseState && !t.IsDeleted &&
                                                     t.PurchaseDate >= startDate &&
                                                     t.PurchaseDate <= endDate
                                                     ).Sum(t => t.Sum)
                                : 0;
                    }

                    if (!db.Purchases.Any(t => t.ProductType == product && t.PurchaseState == purchaseState && !t.IsDeleted))
                    {
                        return 0;
                    }

                    if (startDate == null || endDate == null)
                    {
                        return db.Purchases.Where(t => t.ProductType == product && t.PurchaseState == purchaseState && !t.IsDeleted).Sum(t => t.Sum);
                    }

                    return db.Purchases.Any(t =>
                                            t.ProductType == product && t.PurchaseState == purchaseState && !t.IsDeleted &&
                                            t.PurchaseDate >= startDate &&
                                            t.PurchaseDate <= endDate)
                        ? db.Purchases.Where(t =>
                                             t.ProductType == product && t.PurchaseState == purchaseState && !t.IsDeleted &&
                                             t.PurchaseDate >= startDate &&
                                             t.PurchaseDate <= endDate
                                             ).Sum(t => t.Sum)
                        : 0;
                }
            }));
        }
Exemplo n.º 27
0
 public static void RegisterInAppPurchase(PurchaseState purchaseState, string notifyId, string productId, string orderId, DateTime purchaseTime, string developerPayload, double price, string currency)
 {
     FusePlatformAPI.RegisterInAppPurchase(purchaseState, notifyId, productId, orderId, purchaseTime, developerPayload, price, currency);
 }
Exemplo n.º 28
0
        //--------------------------------------
        // Initialize
        //--------------------------------------

        public PurchaseResult(string productIdentifier, SA.Common.Models.Error e) : base(e)
        {
            _ProductIdentifier = productIdentifier;
            _State             = PurchaseState.Failed;
        }
Exemplo n.º 29
0
        public async Task <List <KeyValuePair <DateTime, double> > > MonthlyPurchasedSum(ProductType?product, PurchaseState purchaseState, DateTime fromDate, DateTime toDate)
        {
            var points = new List <KeyValuePair <DateTime, double> >();

            foreach (var date in DateTimeHelper.EachMonth(new DateTime(fromDate.Year, fromDate.Month, 1), new DateTime(toDate.Year, toDate.Month, 1)))
            {
                points.Add(new KeyValuePair <DateTime, double>(date,
                                                               await StaticGetPurchasedSum(product, purchaseState, date.Date, date.Date.AddMonths(1).AddDays(-1))));
            }
            return(points);
        }
 /// <summary>
 /// This is the callback that is invoked when an item is purchased,
 /// refunded, or canceled.  It is the callback invoked in response to
 /// calling <seealso cref="BillingService#requestPurchase(String)"/>.  It may also
 /// be invoked asynchronously when a purchase is made on another device
 /// (if the purchase was for a Market-managed item), or if the purchase
 /// was refunded, or the charge was canceled.  This handles the UI
 /// update.  The database update is handled in
 /// {@link ResponseHandler#purchaseResponse(Context, PurchaseState,
 /// String, String, long)}. </summary>
 /// <param name="purchaseState"> the purchase state of the item </param>
 /// <param name="itemId"> a string identifying the item (the "SKU") </param>
 /// <param name="quantity"> the current quantity of this item after the purchase </param>
 /// <param name="purchaseTime"> the time the product was purchased, in
 /// milliseconds since the epoch (Jan 1, 1970) </param>
 public abstract void onPurchaseStateChange(PurchaseState purchaseState, string itemId, int quantity, long purchaseTime, string developerPayload);
Exemplo n.º 31
0
 void FetchProducts()
 {
     m_State           = PurchaseState.FetchingProducts;
     m_ProductsRequest = Happiness.Game.ServerWriter.RequestProducts();
 }
Exemplo n.º 32
0
 void PurchaseProduct(int product)
 {
     m_State            = PurchaseState.ConfirmingPurchase;
     m_iSelectedProduct = product;
 }
 // Android purchase notification
 public static new void RegisterInAppPurchase(PurchaseState purchaseState, string notifyId, string productId, string orderId, DateTime purchaseTime, string developerPayload, double price, string currency)
 {
     Debug.Log("FuseAPI:RegisterInAppPurchase");
 }