private Boolean CG_ModifyCustomer()
    {
        try
        {
            //Create a new customer
            CustomerPost newCustomer = new CustomerPost();

            newCustomer.Company = CompanyTextBox.Text;
            newCustomer.FirstName = FirstNameTextBox.Text;
            newCustomer.LastName = LastNameTextBox.Text;
            newCustomer.Email = EmailTextBox.Text;

            //Extra fields required for nonFREE plans
            newCustomer.CCFirstName = CCFirstNameTextbox.Text;
            newCustomer.CCLastName = CCLastNameTextBox.Text;
            newCustomer.CCNumber = CCNumberTextBox.Text;
            newCustomer.CCExpiration = CCExpirationTextBox.Text;
            newCustomer.CCZip = CCZipTextBox.Text;
            newCustomer.CCCardCode = CCCardCodeTextBox.Text;

            if (SelectedPlanCode != 0)
            {
                    newCustomer.PlanCode = SelectedPlanCode;                 //The updated plan code goes here
                    newCustomer.Code = AppID;                           //existing customer code
                    System.Diagnostics.Debug.WriteLine("using customer code" + newCustomer.Code + "To modifyplan to " + newCustomer.PlanCode);

                    //Send it to the server
                    CGError servererror = new CGError();
                    Customer returnCustomer = CheddarGetter.UpdateCustomerAndSubscription(newCustomer, servererror);

                    //FAILURE
                    if (String.IsNullOrEmpty(servererror.Code) == false)
                    {
                        //CG.InnerHtml += "<li>ERROR:" + servererror.Message;
                        RadNotification1.Title = "WARNING";
                        RadNotification1.Text = servererror.Message;
                        RadNotification1.Visible = true;
                        RadNotification1.Show();
                        return false;
                    }

                    //SUCCESS
                    if (String.IsNullOrEmpty(returnCustomer.Code) == false)
                    {
                        AppCGCustomerCode = returnCustomer.Code;
                        CGResponseFlag.Text = AppCGCustomerCode;

                        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
                        BillingUtil billingutil = new BillingUtil();
                        string confirm = returnCustomer.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();

                        string sku = returnCustomer.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();

                        billingutil.UpdatePaidServicesDB(confirm,sku,State);
                    }
                }

            return true;

        }//end try
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            throw;
        }
    }
    private void CG_CreateCustomer()
    {
        try
        {
            //Create a new customer
            CustomerPost newCustomer = new CustomerPost();

            newCustomer.Company = CompanyTextBox.Text;
            newCustomer.FirstName = FirstNameTextBox.Text;
            newCustomer.LastName = LastNameTextBox.Text;
            newCustomer.Email = EmailTextBox.Text;

            //Extra fields required for nonFREE plans
            newCustomer.CCFirstName = CCFirstNameTextbox.Text;
            newCustomer.CCLastName = CCLastNameTextBox.Text;
            newCustomer.CCNumber = CCNumberTextBox.Text;
            newCustomer.CCExpiration = CCExpirationTextBox.Text;
            newCustomer.CCZip = CCZipTextBox.Text;
            newCustomer.CCCardCode = CCCardCodeTextBox.Text;

             if (SelectedPlanCode != 0)
             {
                 newCustomer.PlanCode = SelectedPlanCode;
                    newCustomer.Code = AppID;

                    //Send it to the server
                    CGError servererror = new CGError();
                    Customer returnCustomer = CheddarGetter.CreateCustomer(newCustomer, servererror);

                    //FAILURE
                    if (String.IsNullOrEmpty(servererror.Code) == false)
                    {
                        //CG.InnerHtml += "<li>ERROR:" + servererror.Message;
                        RadNotification1.Title = "WARNING";
                        RadNotification1.Text = servererror.Message;
                        RadNotification1.Visible = true;
                        RadNotification1.Show();

                        string clickHandler = "this.disabled = false; this.value=\'Submit\'; ";
                        SubmitButton.Attributes.Add("onclick", clickHandler);

                        return;
                    }

                    //SUCCESS
                    if (String.IsNullOrEmpty(returnCustomer.Code) == false)
                    {
                        AppCGCustomerCode = returnCustomer.Code;

                        CGResponseFlag.Text = AppCGCustomerCode;

                        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

                        //If the App was submitted to a store [native & hybrid] then just update the paid_services table entry with status to paid.
                        //If not [web apps] create a new entry in paid_services and update status to paid.
                        String app_name = State["SelectedApp"].ToString();
                        BillingUtil billingutil = new BillingUtil();
                        if (billingutil.IsAppStoreSubmissionPaid(State, app_name))
                        {
                            string confirm = returnCustomer.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();

                            string sku = returnCustomer.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();

                            billingutil.UpdatePaidServicesDB(confirm,sku, State);
                        }
                        else
                        {
                            string confirm = returnCustomer.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();
                            string sku = returnCustomer.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();
                            billingutil.StorePaidServicesDB(confirm, sku, State, true);
                        }

                    }
                }

        }//end try
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            throw;
        }
    }