Ejemplo n.º 1
0
    // Finds a free slot and returns that slot
    protected DigitalItem FindFreeSlot()
    {
        DigitalItem freeSlot   = null;
        int         takenSlots = 0;

        for (int i = 0; i < m_SlotList.Count; i++)  // Loop through all slots
        {
            if (m_SlotList[i].SlotIsTaken == false) // If the slot is not taken
            {
                if (freeSlot == null)               // And theres not a new slot already found
                {
                    freeSlot = m_SlotList[i];       // Set this slot as the new inventory slot
                }
            }
            else // If the slot is taken increment the takenSlots int
            {
                takenSlots++;
            }
        }

        if (takenSlots == m_SlotList.Count - 1) // If all the slots are taken set the inventory to full
        {
            m_SlotsHolderIsFull = true;
        }

        return(freeSlot); // Return the slot, also if its null
    }
Ejemplo n.º 2
0
 protected virtual void EmptySlot(DigitalItem slot)
 {
     if (m_SlotsHolderIsFull) // Backpack is not full anymore if a slot is emptied
     {
         m_SlotsHolderIsFull = false;
     }
     slot.ResetSlot();
 }
Ejemplo n.º 3
0
        public static void RecurringChargeRightAway()
        {
            CheckoutShoppingCartRequest cartRequest
                = new CheckoutShoppingCartRequest("123456", "merchantkey", EnvironmentType.Sandbox, "USD", 120);
            //if you are using a web page and it has the Google Checkout button, you would use this syntax.
            //= GCheckoutButton1.CreateRequest()

            Subscription        gSubscription = new Subscription();
            SubscriptionPayment maxCharge     = new SubscriptionPayment();

            DigitalItem urlDigitalItem = new DigitalItem(new Uri("http://www.url.com/login.aspx"),
                                                         "Congratulations, your account has been created!");

            DigitalItem urlDigitalItemSubscription = new DigitalItem(new Uri("http://www.url.com/login.aspx"),
                                                                     "You may now continue to login to your account.");

            ShoppingCartItem gRecurrentItem = new ShoppingCartItem();

            maxCharge.MaximumCharge = 29.99M;

            gRecurrentItem.Name                       = "Entry Level Plan";
            gRecurrentItem.Description                = "Allows for basic stuff. Monthly Subscription:";
            gRecurrentItem.Quantity                   = 1;
            gRecurrentItem.Price                      = 29.99M;
            gRecurrentItem.DigitalContent             = urlDigitalItemSubscription;
            gRecurrentItem.DigitalContent.Disposition = DisplayDisposition.Pessimistic;

            urlDigitalItem.Disposition = DisplayDisposition.Pessimistic;

            gSubscription.Type   = SubscriptionType.google;
            gSubscription.Period = GCheckout.AutoGen.DatePeriod.MONTHLY;
            gSubscription.AddSubscriptionPayment(maxCharge);
            gSubscription.RecurrentItem = gRecurrentItem;

            cartRequest.AddItem("Entry Level Plan", "Allows for basic stuff.", 1, gSubscription);
            cartRequest.AddItem("Entry Level Plan", "First Month:", 29.99M, 1, urlDigitalItem);

            cartRequest.MerchantPrivateData = "UserName:Joe87";

            Debug.WriteLine(EncodeHelper.Utf8BytesToString(cartRequest.GetXml()));

            //Send the request to Google
            //GCheckout.Util.GCheckoutResponse resp = cartRequest.Send();

            //Uncommment this line or perform additional actions
            //if (resp.IsGood) {
            //Response.Redirect(resp.RedirectUrl, True)
            //}
            //else{
            //Response.Write("Resp.ResponseXml = " & Resp.ResponseXml & "<br>");
            //Response.Write("Resp.RedirectUrl = " & Resp.RedirectUrl & "<br>");
            //Response.Write("Resp.IsGood = " & Resp.IsGood & "<br>");
            //Response.Write("Resp.ErrorMessage = " & Resp.ErrorMessage & "<br>");
            //}
        }
Ejemplo n.º 4
0
 public void RemoveSingleItem(DigitalItem item)
 {
     if (item.SlotAmount > 1) // If it has more than one, decrease the amount
     {
         item.DecreaseAmount(1);
     }
     else // If it has one, remove the inventoryslot with the item in it
     {
         EmptySlot(item);
     }
 }
Ejemplo n.º 5
0
 public void RemoveMultipleItems(DigitalItem item, int amount)
 {
     if (item.SlotAmount > amount)
     {
         item.DecreaseAmount(amount);
     }
     else
     {
         EmptySlot(item);
     }
 }
Ejemplo n.º 6
0
    private void AddStoreSlot(ObjectData objectData)
    {
        GameObject itemPrefab = Instantiate(m_StoreItemPrefab);

        itemPrefab.transform.SetParent(m_StoreItemsParent, false); // false so it scales locally

        DigitalItem item = itemPrefab.GetComponent <DigitalItem>();

        item.ObjectData = objectData;
        item.SetAmount(1);
        item.SetImage(objectData.Icon);

        m_StoreItemList.Add(item);
    }
Ejemplo n.º 7
0
 private void SetPlayerIcon(DigitalItem slot)
 {
     if (slot.ObjectData == null)
     {
         m_PlayerSelectedImage.enabled = false;
     }
     else
     {
         if (m_PlayerSelectedImage.enabled == false)
         {
             m_PlayerSelectedImage.enabled = true;
         }
         m_PlayerSelectedImage.sprite = slot.ObjectData.Icon;
     }
 }
Ejemplo n.º 8
0
        public void LoadDigitalItemToDb(DigitalItem digitalItem)
        {
            string query  = @"INSERT INTO DigitalItem (TitleId, Title, KindId, ArtistName, Demo, Pa, Edited, ArtKey, CircId, FixedLayout, ReadAlong) ";
            string values = @"VALUES (@TitleId, @Title, @KindId, @ArtistName, @Demo, @Pa, @Edited, @ArtKey, @CircId, @FixedLayout, @ReadAlong);";

            string connstr = _config.GetConnectionString("SQLCONNSTR_DIGITALBOOK");

            using (IDbConnection connection = new SqlConnection(connstr))
            {
                connection.Open();

                using (IDbTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        var insertedRow = connection.Execute(query + values,
                                                             new
                        {
                            digitalItem.TitleId,
                            digitalItem.Title,
                            digitalItem.KindId,
                            digitalItem.ArtistName,
                            Demo   = (digitalItem.Demo == false) ? 0 : 1,
                            PA     = (digitalItem.PA == false) ? 0 : 1,
                            Edited = (digitalItem.Edited == false) ? 0 : 1,
                            digitalItem.ArtKey,
                            digitalItem.CircId,
                            FixedLayout = (digitalItem.FixedLayout == false) ? 0 : 1,
                            ReadAlong   = (digitalItem.ReadAlong == false) ? 0 : 1
                        }, transaction);

                        if (insertedRow != 1)
                        {
                            transaction.Rollback();
                        }

                        transaction.Commit();
                    }
                    catch (DbException de)
                    {
                        _log.LogError(de.Message, de);
                        transaction.Rollback();
                    }
                }
            }
        }
        public void Test_DigitalItem_EncodedUrls()
        {
            string url = CONST_URL;

            DigitalItem urlDigitalItem = new DigitalItem(new Uri(url), "Url Description for item");

            Assert.AreEqual(url, urlDigitalItem.Url);

            url = "HTTP://www.ConToso.com/thick%20and%20thin.htm";

            urlDigitalItem = new DigitalItem(new Uri(url), "Url Description for item");
            Assert.AreEqual(url.ToLower(), urlDigitalItem.Url);

            Uri uri = new Uri(url);

            Assert.AreEqual(url.ToLower(), uri.AbsoluteUri.ToLower());
            Assert.IsFalse(url.ToLower().Equals(uri.ToString().ToLower()));
        }
Ejemplo n.º 10
0
    protected virtual void FillSlot(ObjectData objectData, int amount)
    {
        DigitalItem newSlot = FindFreeSlot();

        newSlot.FillSlot(objectData, amount);
    }
Ejemplo n.º 11
0
 public void RemoveItemFromTable(DigitalItem item)
 {
     Inventory.Instance.AddItem(item.ObjectData, 1);
     RemoveSingleItem(item);
 }
 public void Test_Digital_Item_Expect_Failure_1024_Char_Limit()
 {
     DigitalItem aaa = new DigitalItem(new Uri(CONST_URL), "Url Description for item 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
 }
Ejemplo n.º 13
0
 // Decrease slotamount to a slot that already exists
 private void RemoveSlotAmount(DigitalItem item)
 {
     item.DecreaseAmount(1);
 }
Ejemplo n.º 14
0
 // Add slotamount to a slot that already exists
 private void AddSlotAmount(DigitalItem item)
 {
     item.IncreaseAmount(1);
 }
Ejemplo n.º 15
0
 private void RemoveSlot(DigitalItem item)
 {
     m_StoreItemList.Remove(item);
     Destroy(item.gameObject);
 }
    public void TestAlternateTaxTables() {
      CheckoutShoppingCartRequest request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "USD", 120);

      //Ensure the factory works as expected
      AlternateTaxTable ohio1 = new AlternateTaxTable("ohio");
      request.AlternateTaxTables.Add(ohio1);
      AlternateTaxTable ohio2 = request.AlternateTaxTables["ohio"];
      AlternateTaxTable ohio3 = new AlternateTaxTable("ohio", true);

      //Ensure that two Tax tables with the same name are not the same reference
      Assert.AreSame(ohio1, ohio2);
      Assert.IsFalse(object.ReferenceEquals(ohio1, ohio3));
      //Assert.AreEqual(ohio1, ohio3);

      //Now add some rules to the item
      ohio1.AddStateTaxRule("OH", .02);

      //Make sure we can add an item to the cart.
      ShoppingCartItem item = request.AddItem("Item 1", "Cool Candy 1", 2.00M, 1, ohio1);

      try {
        request.AddItem("Item 2", "Cool Candy 2", 2.00M, 1, ohio3);
        Assert.Fail("An exception should have been thrown when we tried to add an item that has a new Tax Reference");
      }
      catch (Exception) {

      }

      //Now this should work fine.
      request.AddItem("Item 3", "Cool Candy 3", string.Empty, 2.00M, 1, ohio2);

      //you could create this as an IShoppingCartItem or ShoppingCartItem
      IShoppingCartItem newItem = new ShoppingCartItem("Item 2", "Cool Candy 2", string.Empty, 2.00M, 2, AlternateTaxTable.Empty, "This is a test of a string of private data");
      //now decide to change your mind on the quantity and price
      newItem.Price = 20;
      newItem.Quantity = 4;

      request.AddItem(newItem);

      //Console.WriteLine("private data:" + newItem.MerchantPrivateItemData);

      Assert.AreEqual("This is a test of a string of private data", newItem.MerchantPrivateItemData);

      //now change the private data string and compare again.
      newItem.MerchantPrivateItemData = "This is a new String";
      Assert.AreEqual("This is a new String", newItem.MerchantPrivateItemData);

      //now change the private data string and compare again.
      newItem.MerchantPrivateItemData = string.Empty;
      Assert.AreEqual(string.Empty, newItem.MerchantPrivateItemData);

      Assert.AreEqual(1, ohio1.RuleCount);

      DigitalItem emailDigitalItem = new DigitalItem();
      request.AddItem("Email Digital Item", "Cool DigitalItem", 2.00m, 1, emailDigitalItem);

      DigitalItem urlDigitalItem = new DigitalItem(new Uri("http://www.google.com/download.aspx?myitem=1"), "Url Description for item");
      request.AddItem("Url Digital Item", "Cool Url DigitalItem", 2.00m, 1, urlDigitalItem);

      DigitalItem keyDigitalItem = new DigitalItem("24-235-sdf-123541-53", "Key Description for item");
      request.AddItem("Url Digital Item", "Cool Url DigitalItem", 2.00m, 1, keyDigitalItem);

      DigitalItem keyUrlItem = new DigitalItem("24-235-sdf-123541-53", "http://www.google.com/download.aspx?myitem=1", "Url/Key Description for item");
      request.AddItem("Url Digital Item", "Cool Url DigitalItem", 2.00m, 1, keyUrlItem);

      //lets make sure we can add 2 different flat rate shipping amounts

      request.AddFlatRateShippingMethod("UPS Ground", 5);
      request.AddFlatRateShippingMethod("UPS 2 Day Air", 25);
      request.AddFlatRateShippingMethod("Test", 12, new ShippingRestrictions());

      //You can't mix shipping methods
      try {
        request.AddMerchantCalculatedShippingMethod("Test", 12.95m);
        Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
      }
      catch {
      }

      //lets try adding a Carrier Calculated Shipping Type

      //this should fail because the city is empty
      try {
        request.AddShippingPackage("failedpackage", string.Empty, "OH", "44114", DeliveryAddressCategory.COMMERCIAL, 2, 3, 4);
        Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
      }
      catch {
      }

      //The first thing that needs to be done for carrier calculated shipping is we must set the FOB address.
      request.AddShippingPackage("main", "Cleveland", "OH", "44114", DeliveryAddressCategory.COMMERCIAL, 2, 3, 4);

      //this should fail because two packages exist
      try {
        request.AddShippingPackage("failedpackage", "Cleveland", "OH", "44114", DeliveryAddressCategory.COMMERCIAL, 2, 3, 4);
        Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
      }
      catch {
      }

      try {
        request.AddShippingPackage("main", "Cleveland", "OH", "44114");
        Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
      }
      catch {
      }

      //The next thing we will do is add a Fedex Home Package.
      //We will set the default to 3.99, the Pickup to Regular Pickup, the additional fixed charge to 1.29 and the discount to 2.5%
      CarrierCalculatedShippingOption option
        = request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Home_Delivery, 3.99m, CarrierPickup.REGULAR_PICKUP, 1.29m, -2.5);
      option.AdditionalVariableChargePercent = 0; //make sure we can set it back to 0;
      option.AdditionalFixedCharge = 0;

      Assert.AreEqual(option.StatedShippingType, ShippingType.Fedex_Home_Delivery);
      Assert.AreEqual(option.Price, 3.99m);

      Assert.AreEqual(option.AdditionalVariableChargePercent, 0);
      Assert.AreEqual(option.AdditionalFixedCharge, 0);

      try {
        option.AdditionalFixedCharge = -1;
        Assert.Fail("Additional charge must be >= 0");
      }
      catch {
      }

      option.AdditionalVariableChargePercent = 2; //make sure we can set it back to 0;
      option.AdditionalFixedCharge = 3;

      Assert.AreEqual(option.AdditionalVariableChargePercent, 2);
      Assert.AreEqual(option.AdditionalFixedCharge, 3);

      //this should fail
      try {
        request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Home_Delivery, 3.99m, CarrierPickup.REGULAR_PICKUP, 1.29m, -2.5);
        Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
      }
      catch {

      }

      //verify the rounding works
      CarrierCalculatedShippingOption ccso = request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Ground, 1.993m);
      Assert.AreEqual(1.99m, ccso.Price);
      ccso.Price = 1.975m;
      Assert.AreEqual(1.98m, ccso.Price);
      request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Second_Day, 9.99m, CarrierPickup.REGULAR_PICKUP, 2.34m, -24.5);

      //Ensure we are able to create the cart xml

      byte[] cart = request.GetXml();

      //Console.WriteLine(EncodeHelper.Utf8BytesToString(cart));

      //test to see if the item can desialize
      Assert.IsNotNull(GCheckout.Util.EncodeHelper.Deserialize(cart));
    }
        public void TestAlternateTaxTables()
        {
            CheckoutShoppingCartRequest request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "USD", 120);

            //Ensure the factory works as expected
            AlternateTaxTable ohio1 = new AlternateTaxTable("ohio");

            request.AlternateTaxTables.Add(ohio1);
            AlternateTaxTable ohio2 = request.AlternateTaxTables["ohio"];
            AlternateTaxTable ohio3 = new AlternateTaxTable("ohio", true);

            //Ensure that two Tax tables with the same name are not the same reference
            Assert.AreSame(ohio1, ohio2);
            Assert.IsFalse(object.ReferenceEquals(ohio1, ohio3));
            //Assert.AreEqual(ohio1, ohio3);

            //Now add some rules to the item
            ohio1.AddStateTaxRule("OH", .02);

            //Make sure we can add an item to the cart.
            ShoppingCartItem item = request.AddItem("Item 1", "Cool Candy 1", 2.00M, 1, ohio1);

            try {
                request.AddItem("Item 2", "Cool Candy 2", 2.00M, 1, ohio3);
                Assert.Fail("An exception should have been thrown when we tried to add an item that has a new Tax Reference");
            }
            catch (Exception) {
            }

            //Now this should work fine.
            request.AddItem("Item 3", "Cool Candy 3", string.Empty, 2.00M, 1, ohio2);

            //you could create this as an IShoppingCartItem or ShoppingCartItem
            IShoppingCartItem newItem = new ShoppingCartItem("Item 2", "Cool Candy 2", string.Empty, 2.00M, 2, AlternateTaxTable.Empty, "This is a test of a string of private data");

            //now decide to change your mind on the quantity and price
            newItem.Price    = 20;
            newItem.Quantity = 4;

            request.AddItem(newItem);

            //Console.WriteLine("private data:" + newItem.MerchantPrivateItemData);

            Assert.AreEqual("This is a test of a string of private data", newItem.MerchantPrivateItemData);

            //now change the private data string and compare again.
            newItem.MerchantPrivateItemData = "This is a new String";
            Assert.AreEqual("This is a new String", newItem.MerchantPrivateItemData);

            //now change the private data string and compare again.
            newItem.MerchantPrivateItemData = string.Empty;
            Assert.AreEqual(string.Empty, newItem.MerchantPrivateItemData);

            Assert.AreEqual(1, ohio1.RuleCount);

            DigitalItem emailDigitalItem = new DigitalItem();

            request.AddItem("Email Digital Item", "Cool DigitalItem", 2.00m, 1, emailDigitalItem);

            DigitalItem urlDigitalItem = new DigitalItem(new Uri("http://www.google.com/download.aspx?myitem=1"), "Url Description for item");

            request.AddItem("Url Digital Item", "Cool Url DigitalItem", 2.00m, 1, urlDigitalItem);

            DigitalItem keyDigitalItem = new DigitalItem("24-235-sdf-123541-53", "Key Description for item");

            request.AddItem("Url Digital Item", "Cool Url DigitalItem", 2.00m, 1, keyDigitalItem);

            DigitalItem keyUrlItem = new DigitalItem("24-235-sdf-123541-53", "http://www.google.com/download.aspx?myitem=1", "Url/Key Description for item");

            request.AddItem("Url Digital Item", "Cool Url DigitalItem", 2.00m, 1, keyUrlItem);

            //lets make sure we can add 2 different flat rate shipping amounts

            request.AddFlatRateShippingMethod("UPS Ground", 5);
            request.AddFlatRateShippingMethod("UPS 2 Day Air", 25);
            request.AddFlatRateShippingMethod("Test", 12, new ShippingRestrictions());

            //You can't mix shipping methods
            try {
                request.AddMerchantCalculatedShippingMethod("Test", 12.95m);
                Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
            }
            catch {
            }

            //lets try adding a Carrier Calculated Shipping Type

            //this should fail because the city is empty
            try {
                request.AddShippingPackage("failedpackage", string.Empty, "OH", "44114", DeliveryAddressCategory.COMMERCIAL, 2, 3, 4);
                Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
            }
            catch {
            }

            //The first thing that needs to be done for carrier calculated shipping is we must set the FOB address.
            request.AddShippingPackage("main", "Cleveland", "OH", "44114", DeliveryAddressCategory.COMMERCIAL, 2, 3, 4);

            //this should fail because two packages exist
            try {
                request.AddShippingPackage("failedpackage", "Cleveland", "OH", "44114", DeliveryAddressCategory.COMMERCIAL, 2, 3, 4);
                Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
            }
            catch {
            }

            try {
                request.AddShippingPackage("main", "Cleveland", "OH", "44114");
                Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
            }
            catch {
            }

            //The next thing we will do is add a Fedex Home Package.
            //We will set the default to 3.99, the Pickup to Regular Pickup, the additional fixed charge to 1.29 and the discount to 2.5%
            CarrierCalculatedShippingOption option
                = request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Home_Delivery, 3.99m, CarrierPickup.REGULAR_PICKUP, 1.29m, -2.5);

            option.AdditionalVariableChargePercent = 0; //make sure we can set it back to 0;
            option.AdditionalFixedCharge           = 0;

            Assert.AreEqual(option.StatedShippingType, ShippingType.Fedex_Home_Delivery);
            Assert.AreEqual(option.Price, 3.99m);

            Assert.AreEqual(option.AdditionalVariableChargePercent, 0);
            Assert.AreEqual(option.AdditionalFixedCharge, 0);

            try {
                option.AdditionalFixedCharge = -1;
                Assert.Fail("Additional charge must be >= 0");
            }
            catch {
            }

            option.AdditionalVariableChargePercent = 2; //make sure we can set it back to 0;
            option.AdditionalFixedCharge           = 3;

            Assert.AreEqual(option.AdditionalVariableChargePercent, 2);
            Assert.AreEqual(option.AdditionalFixedCharge, 3);

            //this should fail
            try {
                request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Home_Delivery, 3.99m, CarrierPickup.REGULAR_PICKUP, 1.29m, -2.5);
                Assert.Fail("AddCarrierCalculatedShippingOption should not allow duplicates.");
            }
            catch {
            }

            //verify the rounding works
            CarrierCalculatedShippingOption ccso = request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Ground, 1.993m);

            Assert.AreEqual(1.99m, ccso.Price);
            ccso.Price = 1.975m;
            Assert.AreEqual(1.98m, ccso.Price);
            request.AddCarrierCalculatedShippingOption(ShippingType.Fedex_Second_Day, 9.99m, CarrierPickup.REGULAR_PICKUP, 2.34m, -24.5);

            //Ensure we are able to create the cart xml

            byte[] cart = request.GetXml();

            //Console.WriteLine(EncodeHelper.Utf8BytesToString(cart));

            //test to see if the item can desialize
            Assert.IsNotNull(GCheckout.Util.EncodeHelper.Deserialize(cart));
        }
Ejemplo n.º 18
0
 private void AddItemToTable(DigitalItem item)
 {
     AddItem(item.ObjectData, 1);
     Inventory.Instance.RemoveSingleItem(item);
     StartCraftingIfPossible();
 }