// Methods
        public static void InitialCharge()
        {
            //http://code.google.com/apis/checkout/developer/Google_Checkout_Beta_Subscriptions.html
              //using an initial charge with a recurring charge using a different item.

              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()

              ShoppingCartItem initialItem = new ShoppingCartItem();
              ShoppingCartItem recurrentItem = new ShoppingCartItem();

              initialItem.Price = decimal.Zero;
              initialItem.Quantity = 1;
              initialItem.Name = "Item that shows in cart";
              initialItem.Description = "This is the item that shows in the cart";

              recurrentItem.Price = 2M;
              recurrentItem.Quantity = 1;
              recurrentItem.Name = "Item that is charged every month";
              recurrentItem.Description = "Description for item that is charged every month";

              Subscription subscription = new Subscription();
              subscription.Period = GCheckout.AutoGen.DatePeriod.MONTHLY;
              subscription.Type = SubscriptionType.merchant;

              SubscriptionPayment payment = new SubscriptionPayment();
              payment.MaximumCharge = 120M;
              payment.Times = 12;

              subscription.AddSubscriptionPayment(payment);

              //You must set the item that will be charged for every month.
              subscription.RecurrentItem = recurrentItem;

              //you must set the subscription for the item
              initialItem.Subscription = subscription;

              cartRequest.AddItem(initialItem);

              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>");
              //}
        }
        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>");
              //}
        }
        public void TestSubscriptions_All_Data()
        {
            CheckoutShoppingCartRequest request = new CheckoutShoppingCartRequest(MERCHANT_ID, MERCHANT_KEY, EnvironmentType.Sandbox, "USD", 120);
              //Make sure we can add an item to the cart.
              Subscription sub = new Subscription();
              sub.AddSubscriptionPayment(new SubscriptionPayment(2, 12));
              sub.NoChargeAfter = new DateTime(2010, 1, 1);
              sub.Period = GCheckout.AutoGen.DatePeriod.DAILY;
              sub.RecurrentItem = new ShoppingCartItem("Sub Item", "Sub Item Description", "Item 1", 0, 3);
              sub.StartDate = new DateTime(2009, 7, 1);
              sub.Type = SubscriptionType.merchant;
              ShoppingCartItem item = request.AddItem("Item 1", "Cool Candy 1", 1, sub);
              //Console.WriteLine(EncodeHelper.Utf8BytesToString(request.GetXml()));

              //now deserialize it
              AutoGen.CheckoutShoppingCart cart = EncodeHelper.Deserialize(request.GetXml()) as AutoGen.CheckoutShoppingCart;
              //Console.WriteLine(EncodeHelper.Utf8BytesToString(EncodeHelper.Serialize(cart)));

              foreach (AutoGen.Item ai in cart.shoppingcart.items) {
            ShoppingCartItem ci = new ShoppingCartItem(ai);
            Assert.AreEqual(ci.Subscription.NoChargeAfter, sub.NoChargeAfter);
            SubscriptionPayment sp = new SubscriptionPayment(ai.subscription.payments[0]);
            SubscriptionPayment dp = sub.Payments[0];

            Assert.AreEqual(sp.MaximumCharge, dp.MaximumCharge);
            Assert.AreEqual(sp.Times, dp.Times);

            Assert.AreEqual(ci.Subscription.Period, sub.Period);
            Assert.AreEqual(ci.Subscription.StartDate, sub.StartDate);
            Assert.AreEqual(ci.Subscription.Type, sub.Type);

              }

              sub.NoChargeAfter = null;
              sub.Period = GCheckout.AutoGen.DatePeriod.QUARTERLY;
              sub.StartDate = null;
              sub.Type = SubscriptionType.google;

              //reset
              cart = EncodeHelper.Deserialize(request.GetXml()) as AutoGen.CheckoutShoppingCart;
              //Console.WriteLine(EncodeHelper.Utf8BytesToString(EncodeHelper.Serialize(cart)));

              foreach (AutoGen.Item ai in cart.shoppingcart.items) {
            ShoppingCartItem ci = new ShoppingCartItem(ai);
            //Console.WriteLine(ci.Subscription.NoChargeAfter);
            Assert.IsFalse(ci.Subscription.NoChargeAfter.HasValue, "NoChargeAfter should be null");
            SubscriptionPayment sp = new SubscriptionPayment(ai.subscription.payments[0]);
            SubscriptionPayment dp = sub.Payments[0];

            Assert.AreEqual(sp.MaximumCharge, dp.MaximumCharge);
            Assert.AreEqual(sp.Times, dp.Times);

            Assert.AreEqual(ci.Subscription.Period, DatePeriod.QUARTERLY);
            //Console.WriteLine(ci.Subscription.StartDate);
            //bug in .net
            //Assert.IsFalse(ci.Subscription.StartDate.HasValue, "StartDate should be null");
            Assert.AreEqual(ci.Subscription.Type, SubscriptionType.google);

              }
        }