public static CheckoutFormParams GetCheckoutFormParams(string contractId, int invoiceId, string methodName, KeyValueBunch options) { Contract contractInfo = ContractSystem.ContractController.GetContract(contractId); // Impersonate ContractSystem.ContractController.ImpersonateAsContractReseller(contractInfo); // SupportedPlugin pmPlugin = GetResellerPMPlugin(contractInfo.ResellerId, methodName); // if (pmPlugin == null) { throw new Exception("Incorrect payment method has been specified"); } // create instance of plugin IInteractivePaymentGatewayProvider provider = (IInteractivePaymentGatewayProvider) SystemPluginController.GetSystemPluginInstance(contractInfo, pmPlugin, true); // Invoice userInvoice = InvoiceController.GetCustomerInvoiceInternally(invoiceId); // List <InvoiceItem> invoiceLines = InvoiceController.GetCustomerInvoiceItems(invoiceId); // load contract account ContractAccount account = ContractSystem.ContractController.GetContractAccountSettings(contractId); // build form parameters FormParameters formParams = new FormParameters(); // copy reseller id formParams[FormParameters.CONTRACT] = userInvoice.ContractId; // copy invoice number formParams[FormParameters.INVOICE] = userInvoice.InvoiceId.ToString(); // copy invoice amount formParams[FormParameters.AMOUNT] = userInvoice.Total.ToString("0.00"); // copy invoice tax amount formParams[FormParameters.TAX_AMOUNT] = userInvoice.TaxAmount.ToString("0.00"); // copy invoice currency formParams[FormParameters.CURRENCY] = userInvoice.Currency; // copy first name formParams[FormParameters.FIRST_NAME] = account[ContractAccount.FIRST_NAME]; // copy last name formParams[FormParameters.LAST_NAME] = account[ContractAccount.LAST_NAME]; // copy email formParams[FormParameters.EMAIL] = account[ContractAccount.EMAIL]; // copy address formParams[FormParameters.ADDRESS] = account[ContractAccount.ADDRESS]; // copy country formParams[FormParameters.COUNTRY] = account[ContractAccount.COUNTRY]; // copy phone number formParams[FormParameters.PHONE] = account[ContractAccount.PHONE_NUMBER]; // copy city formParams[FormParameters.CITY] = account[ContractAccount.CITY]; // copy state formParams[FormParameters.STATE] = account[ContractAccount.STATE]; // copy zip formParams[FormParameters.ZIP] = account[ContractAccount.ZIP]; // copy options if any if (options != null) { foreach (string keyName in options.GetAllKeys()) { formParams[keyName] = options[keyName]; } } // return result return(provider.GetCheckoutFormParams(formParams, invoiceLines.ToArray())); }
public GenericSvcResult ActivateService(ProvisioningContext context) { GenericSvcResult result = new GenericSvcResult(); // remeber svc state SaveObjectState(SERVICE_INFO, context.ServiceInfo); // concretize service to be provisioned DomainNameSvc domainSvc = (DomainNameSvc)context.ServiceInfo; // concretize parent service HostingPackageSvc packageSvc = (HostingPackageSvc)context.ParentSvcInfo; try { // LOG INFO TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.SVC_ACTIVATE); TaskManager.WriteParameter(CONTRACT_PARAM, domainSvc.ContractId); TaskManager.WriteParameter(SVC_PARAM, domainSvc.ServiceName); TaskManager.WriteParameter(SVC_ID_PARAM, domainSvc.ServiceId); // 0. Do security checks if (!CheckOperationClientPermissions(result)) { // LOG ERROR TaskManager.WriteError(ERROR_CLIENT_OPERATION_PERMISSIONS); TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode); // EXIT return(result); } // if (!CheckOperationClientStatus(result)) { // LOG ERROR TaskManager.WriteError(ERROR_CLIENT_OPERATION_STATUS); TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode); // EXIT return(result); } // error: hosting addon should have parent svc assigned if (packageSvc == null || packageSvc.PackageId == 0) { result.Succeed = false; // result.Error = PARENT_SVC_NOT_FOUND_MSG; // result.ResultCode = EcommerceErrorCodes.ERROR_PARENT_SVC_NOT_FOUND; // LOG ERROR TaskManager.WriteError(result.Error); TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode); // EXIT return(result); } // first of all - create internal domain in WebsitePanel if (domainSvc.Status == ServiceStatus.Ordered) { // create domain info object DomainInfo domain = ServerController.GetDomain(domainSvc.Fqdn); // if (domain != null) { domainSvc.DomainId = domain.DomainId; } // if (domain == null) { domain = new DomainInfo(); domain.DomainName = domainSvc.Fqdn; domain.HostingAllowed = false; domain.PackageId = packageSvc.PackageId; // add internal domain domainSvc.DomainId = ServerController.AddDomain(domain); // check API result if (domainSvc.DomainId < 1) { // ASSEMBLE ERROR result.Succeed = false; // try to find corresponding error code->error message mapping if (ApiErrorCodesMap.ContainsKey(domainSvc.DomainId)) { result.Error = ApiErrorCodesMap[domainSvc.DomainId]; } else { result.Error = ERROR_ADD_INTERNAL_DOMAIN; } // copy result code result.ResultCode = domainSvc.DomainId; // LOG ERROR TaskManager.WriteError(result.Error); TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode); // EXIT return(result); } } } // update nameservers only if (domainSvc["SPF_ACTION"] == "UPDATE_NS") { // remove service here... ServiceController.DeleteCustomerService(domainSvc.ServiceId); // result.Succeed = true; // EXIT return(result); } // load registrar wrapper IDomainRegistrar registrar = (IDomainRegistrar)SystemPluginController.GetSystemPluginInstance( domainSvc.ContractId, domainSvc.PluginId, true); #region Commented operations // prepare consumer account information /*CommandParams cmdParams = PrepeareAccountParams(context.ConsumerInfo); * // copy svc properties * foreach (string keyName in domainSvc.GetAllKeys()) * cmdParams[keyName] = domainSvc[keyName]; * * // check registrar requires sub-account to be created * if (registrar.SubAccountRequired) * { * // 1. Load user's settings * UserSettings userSettings = LoadUserSettings(context.ConsumerInfo.UserId, registrar.PluginName); * // 2. Ensure user has account on registrar's side * if (userSettings.SettingsArray == null || userSettings.SettingsArray.Length == 0) * { * // 3. Check account exists * bool exists = registrar.CheckSubAccountExists(context.ConsumerInfo.Username, context.ConsumerInfo.Email); * // * AccountResult accResult = null; * // * if (!exists) * { * // 4. Create user account * accResult = registrar.CreateSubAccount(cmdParams); * // copy keys & values * foreach (string keyName in accResult.AllKeys) * { * userSettings[keyName] = accResult[keyName]; * } * } * else * { * // 4a. Get sub-account info * accResult = registrar.GetSubAccount(context.ConsumerInfo.Username, * context.ConsumerInfo.Email); * // * foreach (string keyName in accResult.AllKeys) * userSettings[keyName] = accResult[keyName]; * } * // 5. Update user settings * int apiResult = UserController.UpdateUserSettings(userSettings); * // check API result * if (apiResult < 0) * { * // BUILD ERROR * result.Error = ERROR_UPDATE_USR_SETTINGS_MSG; * result.Succeed = false; * result.ResultCode = apiResult; * // LOG ERROR * TaskManager.WriteError(result.Error); * TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode); * // ROLLBACK * RollbackOperation(domainSvc.DomainId); * // EXIT * return result; * } * } * // copy registrar-specific data * foreach (string[] pair in userSettings.SettingsArray) * { * // copy 2 * cmdParams[pair[0]] = pair[1]; * } * }*/ #endregion // load NS settings PackageSettings nsSettings = PackageController.GetPackageSettings(packageSvc.PackageId, PackageSettings.NAME_SERVERS); // build name servers array string[] nameServers = null; if (!String.IsNullOrEmpty(nsSettings[PackageSettings.NAME_SERVERS])) { nameServers = nsSettings[PackageSettings.NAME_SERVERS].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } // register or renew domain if (domainSvc.Status == ServiceStatus.Ordered) { // try to register domain registrar.RegisterDomain(domainSvc, context.ConsumerInfo, nameServers); } else { // try to renew domain registrar.RenewDomain(domainSvc, context.ConsumerInfo, nameServers); } // change svc status to active domainSvc.Status = ServiceStatus.Active; // update service info int updResult = UpdateServiceInfo(domainSvc); // check update result for errors if (updResult < 0) { // BUILD ERROR result.ResultCode = updResult; result.Succeed = false; result.Error = ERROR_SVC_UPDATE_MSG; // LOG ERROR TaskManager.WriteError(result.Error); TaskManager.WriteParameter(RESULT_CODE_PARAM, result.ResultCode); // ROLLBACK RollbackOperation(domainSvc.DomainId); // EXIT return(result); } // result.Succeed = true; // SetOutboundParameters(context); } catch (Exception ex) { // LOG ERROR TaskManager.WriteError(ex); result.Succeed = false; // ROLLBACK RollbackOperation(result.ResultCode); } finally { TaskManager.CompleteTask(); } // return(result); }