Exemplo n.º 1
0
        protected void BtnSubscribe_Click(Object sender, EventArgs e)
        {
            Registration registration = Registrations.Load(this.Guid);

            double total = SubscriptionManager.CalculateCost(registration);
            if (total > 0)
            {
                //Create all of the billing agreements
                PaypalExpressCheckout checkout = new PaypalExpressCheckout();
                checkout.AddBillingAgreement(registration);

                String redirect = checkout.SetExpressCheckout(registration.Email, registration.Guid);
                Response.Redirect(redirect, true);
            }
            else
            {
                String encrypted = TextEncryption.Encode(registration.Guid);
                Response.Redirect("Activate.aspx?_ftoken=" + Server.UrlEncode(encrypted));
            }
        }
Exemplo n.º 2
0
        protected void BtnUpgradePlan_Click(Object sender, EventArgs e)
        {
            String returnurl = "http://" + GooeyConfigManager.AdminSiteHost + "/auth/Manage.aspx";
            String cancelurl = returnurl;

            CmsSubscription subscription = SubscriptionManager.GetSubscription(CurrentSite.Guid);
            subscription.IsCampaignEnabled = false;
            subscription.IsSalesforceEnabled = false;

            if (this.ChkUpgradeCampaignOption.Checked)
                subscription.IsCampaignEnabled = true;

            if (this.ChkUpgradeSalesforceOption.Checked)
                subscription.IsSalesforceEnabled = true;

            String options = String.Format("{0}|{1}",subscription.IsCampaignEnabled.StringValue(), subscription.IsSalesforceEnabled.StringValue());
            options = TextEncryption.Encode(options);

            int freeTrialLength = (int)SubscriptionManager.CalculateFreeTrialRemaining(subscription);

            //Cookie the user with what options need enabled
            HttpCookie cookie = new HttpCookie("upgrade-options",options);
            Response.Cookies.Add(cookie);

            subscription.SubscriptionPlan = SubscriptionManager.GetSubscriptionPlan(Constants.SubscriptionPlans.Business);

            PaypalExpressCheckout checkout = new PaypalExpressCheckout();
            checkout.AddBillingAgreement(PaypalExpressCheckout.GetBillingAgreement(subscription,freeTrialLength));
            String redirect = checkout.SetExpressCheckout(LoggedInUser.Email, subscription.Guid,returnurl,cancelurl);

            Response.Redirect(redirect, true);
        }