public ActionResult SSLProcessPoll(string plan) { // check if payment has gone through var done = false; var uniqueid = string.Format("{0}:{1}", accountSubdomainName, plan); var payment = repository.GetPaymentByReference(uniqueid); if (payment == null) { return(Json(accountHostname.ToDomainUrl("/dashboard").ToJsonOKData())); } if (payment.status == PaymentStatus.Accepted.ToString()) { done = true; } // payment has gone thru if (done) { var owner = MASTERdomain.organisation.users.First(); var country = owner.organisation1.country.ToCountry(); // get formatted phone numbers var phoneutil = PhoneNumberUtil.GetInstance(); var parsedNumber = phoneutil.Parse(owner.organisation1.phone, country.code); PhoneNumber parsedFax = null; if (!string.IsNullOrEmpty(owner.organisation1.fax)) { parsedFax = phoneutil.Parse(owner.organisation1.fax, country.code); } var contact = new Contact(owner.firstName, owner.lastName, owner.organisation1.name, owner.organisation1.address, owner.organisation1.MASTERcity.name, owner.organisation1.state, owner.organisation1.postcode, country.code, string.Format("+{0}.{1}", parsedNumber.CountryCode, parsedNumber.NationalNumber), parsedFax == null ? "" : string.Format("+{0}.{1}", parsedFax.CountryCode, parsedFax.NationalNumber), owner.email); // now we start moving the domain int numberOfYears; switch (plan) { case "one_year_ssl": numberOfYears = 1; break; case "two_year_ssl": numberOfYears = 2; break; case "three_year_ssl": numberOfYears = 3; break; case "four_year_ssl": numberOfYears = 4; break; case "five_year_ssl": numberOfYears = 5; break; default: throw new NotImplementedException(); } var opensrs = new Trust(); var respcode = opensrs.RegisterSSL(accountHostname, numberOfYears, contact); if (respcode == null) { Syslog.Write("Unable to register SSL for " + subdomainid.Value); return(Json("/error".ToJsonOKData())); } Syslog.Write(string.Format("{0}:{1}", subdomainid.Value, respcode.text)); if (respcode.code == "200") { // update user details and redirect to login page return(Json(accountHostname.ToDomainUrl("/dashboard").ToJsonOKData())); } } return(Json("".ToJsonFailData())); }
public ActionResult DomainProcessPoll(string domain_name) { // check if payment has gone through var done = false; var payment = repository.GetPaymentByReference(domain_name); if (payment == null) { return(Json(accountHostname.ToDomainUrl("/dashboard").ToJsonOKData())); } if (payment.status == PaymentStatus.Accepted.ToString()) { done = true; } // payment has gone thru if (done) { bool privacy; int numberOfYears; // get order details var orderitems = payment.order.orderItems; if (orderitems.Count() == 2) { privacy = true; numberOfYears = orderitems.Single(x => x.product_variant.sku != "id_theft").quantity; } else { privacy = false; numberOfYears = orderitems.Single().quantity; } var owner = MASTERdomain.organisation.users.First(); var country = owner.organisation1.country.ToCountry(); // get formatted phone numbers var phoneutil = PhoneNumberUtil.GetInstance(); var parsedNumber = phoneutil.Parse(owner.organisation1.phone, country.code); PhoneNumber parsedFax = null; if (!string.IsNullOrEmpty(owner.organisation1.fax)) { parsedFax = phoneutil.Parse(owner.organisation1.fax, country.code); } var contact = new Contact(owner.firstName, owner.lastName, owner.organisation1.name, owner.organisation1.address, owner.organisation1.MASTERcity.name, owner.organisation1.state, owner.organisation1.postcode, country.code, string.Format("+{0}.{1}", parsedNumber.CountryCode, parsedNumber.NationalNumber), parsedFax == null?"":string.Format("+{0}.{1}", parsedFax.CountryCode, parsedFax.NationalNumber), owner.email); // now we start moving the domain var opensrs = new Domain(); var respcode = opensrs.RegisterDomain(domain_name, privacy, numberOfYears, contact); if (respcode == null) { Syslog.Write("Unable to register domain for " + subdomainid.Value); return(Json("/error".ToJsonOKData())); } Syslog.Write(string.Format("{0}:{1}", subdomainid.Value, respcode.text)); if (respcode.code == "200") { // update user details and redirect to login page MASTERdomain.customDomain = domain_name; repository.Save(); return(Json(domain_name.ToDomainUrl("/login").ToJsonOKData())); } } return(Json("".ToJsonFailData())); }