private void SetProviderProperties(KeyValueBunch props)
		{
			//
			txtUsername.Text = props[PayPalProSettings.USERNAME];
			//
			chkLiveMode.Checked = ecUtils.ParseBoolean(props[PayPalProSettings.LIVE_MODE], false);
		}
Esempio n. 2
0
        public void Order()
        {
            int rootServiceId = Utils.ParseInt(ServiceSettings[ROOT_SERVICE_ID], 0);

            // each add-on should have root service id assigned
            if (rootServiceId < 0)
            {
                throw new Exception(
                          "Incorrect add-on settings. Root Service ID couldn't be found please review logs and correct this issue."
                          );
            }

            // get root service settings
            KeyValueBunch rootSettings = ServiceController.GetServiceSettings(
                ServiceInfo.SpaceId,
                rootServiceId
                );

            // failed to load root service settings
            if (rootSettings == null)
            {
                throw new Exception("Unable to load root service settings.");
            }

            // add package add-on
            PackageAddonInfo addon = new PackageAddonInfo();

            // load Package ID
            int packageId = 0;

            if (!Int32.TryParse(rootSettings[PACKAGE_ID], out packageId))
            {
                throw new Exception("Couldn't parse parent service settings: PackageID property. Parent Service ID: " + rootServiceId);
            }

            // load Plan ID
            int hostingAddon = 0;

            if (!Int32.TryParse(ServiceSettings[HOSTING_ADDON], out hostingAddon))
            {
                throw new Exception("Couldn't parse service settings: HostingAddon property. Service ID: " + ServiceInfo.ServiceId);
            }

            addon.PackageId    = packageId;
            addon.PlanId       = hostingAddon;
            addon.Quantity     = 1;
            addon.StatusId     = (int)PackageStatus.Active;
            addon.PurchaseDate = DateTime.UtcNow;

            PackageResult result = PackageController.AddPackageAddon(addon);

            // failed to create package add-on
            if (result.Result < 0)
            {
                throw new Exception("Unable to add package add-on. Status code: " + result.Result);
            }

            // save service settings
            PackageAddonID = result.Result.ToString();
        }
		private void SetProviderSettings(KeyValueBunch props)
		{
			// set business
			txtBusiness.Text = props[PayPalStdSettings.BUSINESS];
			// set live mode
			chkLiveMode.Checked = ecUtils.ParseBoolean(props[PayPalStdSettings.LIVE_MODE], false);
		}
Esempio n. 4
0
        public static KeyValueBunch FillSettingsBunch(IDataReader reader,
                                                      string keyNameColumn, string keyValueColumn)
        {
            KeyValueBunch bunch = null;

            try
            {
                bunch = new KeyValueBunch();

                while (reader.Read())
                {
                    bunch[(String)reader[keyNameColumn]] = (String)reader[keyValueColumn];
                }
            }
            catch
            {
                bunch = null;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(bunch);
        }
Esempio n. 5
0
        public static T FillSettingsBunch <T>(IDataReader reader, string keyNameColumn, string keyValueColumn)
        {
            Type type = typeof(T);

            KeyValueBunch bunch = (KeyValueBunch)Activator.CreateInstance(type);

            try
            {
                while (reader.Read())
                {
                    bunch[(String)reader[keyNameColumn]] = (String)reader[keyValueColumn];
                }
            }
            catch
            {
                bunch = null;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return((T)Convert.ChangeType(bunch, typeof(T)));
        }
Esempio n. 6
0
        public static KeyValueBunch FillControlsBunch(IDataReader reader)
        {
            KeyValueBunch bunch = null;

            try
            {
                bunch = new KeyValueBunch();

                while (reader.Read())
                {
                    bunch[(String)reader["ControlKey"]] = (String)reader["ControlSrc"];
                }
            }
            catch
            {
                bunch = null;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(bunch);
        }
Esempio n. 7
0
        public static KeyValueBunch FillProperties(IDataReader reader)
        {
            KeyValueBunch settings = null;

            try
            {
                settings = new KeyValueBunch();

                while (reader.Read())
                {
                    string name  = (string)reader["PropertyName"];
                    string value = (string)reader["PropertyValue"];
                    //
                    settings[name] = value;
                }
            }
            catch
            {
                settings = null;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(settings);
        }
Esempio n. 8
0
        public static KeyValueBunch FillSettings(IDataReader reader)
        {
            KeyValueBunch settings = null;

            try
            {
                settings = new KeyValueBunch();

                while (reader.Read())
                {
                    settings[(string)reader["SettingName"]] = (string)reader["SettingValue"];
                }
            }
            catch
            {
                settings = null;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(settings);
        }
		private void SetProviderProperties(KeyValueBunch props)
		{
			//
            txtTranNumberFormat.Text = props[OffPaymentSettings.TRANSACTION_NUMBER_FORMAT];
			//
			chkAutoApprove.Checked = ecUtils.ParseBoolean(props[OffPaymentSettings.AUTO_APPROVE], false);
		}
		private KeyValueBunch GetProviderProperties()
		{
			KeyValueBunch props = new KeyValueBunch();
			// copy payment prefix
            props[OffPaymentSettings.TRANSACTION_NUMBER_FORMAT] = txtTranNumberFormat.Text.Trim();
			//
			props[OffPaymentSettings.AUTO_APPROVE] = chkAutoApprove.Checked.ToString();
			//
			return props;
		}
Esempio n. 11
0
 public EnomResult ExecuteCommand(string commandName, KeyValueBunch commandArgs)
 {
     AddParam("Command", commandName);
     // copy attributes
     foreach (string keyName in commandArgs.GetAllKeys())
     {
         AddParam(keyName, commandArgs[keyName]);
     }
     //
     return(new EnomResult(ExecuteCommand()));
 }
        public static int SetPluginProperties(int userId, int pluginId, KeyValueBunch props)
        {
            string xmlText = String.Empty;

            string[][]     pluginProps = null;
            SecurityResult result      = StorehouseController.CheckAccountNotDemoAndActive();

            //
            if (!result.Success)
            {
                return(result.ResultCode);
            }
            if (props != null)
            {
                // create system plugin
                SystemPluginBase pluginObj = GetSystemPluginInstance(userId, pluginId, false);
                // crypt sensitive data
                foreach (string keyName in props.GetAllKeys())
                {
                    //
                    string keyValue = props[keyName];
                    //
                    if (pluginObj.SecureSettings != null)
                    {
                        int indexOf = Array.IndexOf(pluginObj.SecureSettings, keyName);
                        // crypt sensitive data
                        if (indexOf > -1)
                        {
                            keyValue = CryptoUtils.Encrypt(keyValue);
                        }
                    }
                    //
                    props[keyName] = keyValue;
                }

                // load old properties
                KeyValueBunch oldProps = GetPluginPropertiesInternal(userId, pluginId,
                                                                     false, pluginObj.SecureSettings);
                // merge old props with new props
                foreach (string keyName in props.GetAllKeys())
                {
                    // copy
                    oldProps[keyName] = props[keyName];
                }
                //
                pluginProps = oldProps.KeyValueArray;
            }
            // build update xml
            xmlText = SettingsHelper.ConvertObjectSettings(pluginProps, "properties", "property");
            //
            return(EcommerceProvider.SetPluginProperties(SecurityContext.User.UserId, userId, pluginId, xmlText));
        }
		private void SetProviderProperties(KeyValueBunch props)
		{
			if (!props.IsEmpty)
				txtSecretWord.EnableDefaultPassword();

			txt2COAccount.Text = props[ToCheckoutSettings.ACCOUNT_SID];
			//
			chkLiveMode.Checked = ecUtils.ParseBoolean(props[ToCheckoutSettings.LIVE_MODE], false);
			//
			chkFixedCart.Checked = ecUtils.ParseBoolean(props[ToCheckoutSettings.FIXED_CART], false);
			//
			ecUtils.SelectListItem(ddl2CO_Currency, props[ToCheckoutSettings.CURRENCY]);
		}
		private KeyValueBunch GetProviderProperties()
		{
			KeyValueBunch props = new KeyValueBunch();
			//
			props[PayPalProSettings.USERNAME] = txtUsername.Text.Trim();
			//
			props[PayPalProSettings.PASSWORD] = txtPassword.Text;
			//
			props[PayPalProSettings.SIGNATURE] = txtSignature.Text.Trim();
			//
			props[PayPalProSettings.LIVE_MODE] = chkLiveMode.Checked.ToString();
			//
			return props;
		}
		private KeyValueBunch GetProviderSettings()
		{
			KeyValueBunch props = new KeyValueBunch();
			// copy business
			props[PayPalStdSettings.BUSINESS] = txtBusiness.Text.Trim();
			// copy live mode
			props[PayPalStdSettings.LIVE_MODE] = chkLiveMode.Checked.ToString();
			// copy return url
			props[PayPalStdSettings.RETURN_URL] = EcommerceSettings.AbsoluteAppPath + "/DesktopModules/Ecommerce/Plugins/PayPalStd/PP_Routine.aspx";
			// copy cancel return url
			props[PayPalStdSettings.CANCEL_RETURN_URL] = EcommerceSettings.StorefrontUrl;
			//
			return props;
		}
		private void SetPluginProperties(KeyValueBunch settings)
		{
			// set demo account
			chkDemoAccount.Checked = ecUtils.ParseBoolean(settings[AuthNetSettings.DEMO_ACCOUNT], false);
			// set merchant email
			txtMerchantEmail.Text = settings[AuthNetSettings.MERCHANT_EMAIL];
			// set live mode
			chkLiveModeEnabled.Checked = ecUtils.ParseBoolean(settings[AuthNetSettings.LIVE_MODE], false);
			// set send confirmation
			chkSendConfirmation.Checked = ecUtils.ParseBoolean(settings[AuthNetSettings.SEND_CONFIRMATION], false);
			//
			txtMd5Hash.Text = settings[AuthNetSettings.MD5_HASH];
			//
			txtAccount.Text = settings[AuthNetSettings.USERNAME];
			//
			txtTransKey.Text = settings[AuthNetSettings.TRANSACTION_KEY];
		}
		private KeyValueBunch GetProviderProperties()
		{
			KeyValueBunch props = new KeyValueBunch();
			// change secret word only if it was changed
			if (txtSecretWord.PasswordChanged)
				props[ToCheckoutSettings.SECRET_WORD] = txtSecretWord.Text.Trim();
			//
			props[ToCheckoutSettings.ACCOUNT_SID] = txt2COAccount.Text.Trim();
			//
			props[ToCheckoutSettings.CURRENCY] = ddl2CO_Currency.SelectedValue;
			//
			props[ToCheckoutSettings.LIVE_MODE] = chkLiveMode.Checked.ToString();
			//
			props[ToCheckoutSettings.FIXED_CART] = chkFixedCart.Checked.ToString();
			//
			props[ToCheckoutSettings.CONTINUE_SHOPPING_URL] = EcommerceSettings.StorefrontUrl; 
			//
			return props;
		}
        internal static KeyValueBunch GetPluginPropertiesInternal(int userId, int pluginId, bool skipSensitive,
                                                                  string[] secureSettings)
        {
            // load plugin settings
            KeyValueBunch properties = SettingsHelper.FillProperties(EcommerceProvider.GetPluginProperties(
                                                                         SecurityContext.User.UserId, userId, pluginId));

            // cleanup plugin settings
            if (skipSensitive && secureSettings != null)
            {
                // iterate through secure settings
                foreach (string keyName in secureSettings)
                {
                    // remove secure setting
                    properties.RemoveKey(keyName);
                }
            }
            // return plugin settings
            return(properties);
        }
Esempio n. 19
0
        public static int SendNewInvoiceNotification(Invoice invoice, List <InvoiceItem> invoiceLines, KeyValueBunch extraArgs)
        {
            Contract                  contract        = ContractSystem.ContractController.GetContract(invoice.ContractId);
            ContractAccount           account         = ContractSystem.ContractController.GetContractAccountSettings(invoice.ContractId);
            Dictionary <int, Service> invoiceServices = ServiceController.GetServicesDictionary(invoiceLines);
            Hashtable                 items           = new Hashtable();

            items["Invoice"]         = invoice;
            items["InvoiceLines"]    = invoiceLines;
            items["InvoiceServices"] = invoiceServices;
            items["Tax"]             = StorehouseController.GetTaxation(contract.ResellerId, invoice.TaxationId);
            items["Customer"]        = account;
            items["IsEmail"]         = "1";
            if (extraArgs != null)
            {
                items["ExtraArgs"] = extraArgs;
            }

            return(SendSystemNotification(StoreSettings.NEW_INVOICE, account, items, "HtmlBody", "TextBody"));
        }
		private KeyValueBunch GetPluginProperties()
		{
			KeyValueBunch bunch = new KeyValueBunch();
			//
			// set demo account
			bunch[AuthNetSettings.DEMO_ACCOUNT] = chkDemoAccount.Checked.ToString();
			// set merchant email
			bunch[AuthNetSettings.MERCHANT_EMAIL] = txtMerchantEmail.Text.Trim();
			// set live mode
			bunch[AuthNetSettings.LIVE_MODE] = chkLiveModeEnabled.Checked.ToString();
			// set send confirmation
			bunch[AuthNetSettings.SEND_CONFIRMATION] = chkSendConfirmation.Checked.ToString();
			//
			bunch[AuthNetSettings.MD5_HASH] = txtMd5Hash.Text.Trim();
			//
			bunch[AuthNetSettings.USERNAME] = txtAccount.Text.Trim();
			//
			bunch[AuthNetSettings.TRANSACTION_KEY] = txtTransKey.Text.Trim();
			//
			return bunch;
		}
Esempio n. 21
0
        public void Order()
        {
            int parentId = Convert.ToInt32(ServiceSettings[ROOT_SERVICE_ID]);

            KeyValueBunch rootSettings = ServiceController.GetServiceSettings(
                ServiceInfo.SpaceId,
                parentId
                );

            // check whether the parent service has been provisioned
            if (String.IsNullOrEmpty(rootSettings[PACKAGE_ID]))
            {
                throw new Exception(
                          "Unable to provision service because parent service not provisioned yet"
                          );
            }

            int packageId = Utils.ParseInt(rootSettings[PACKAGE_ID], -1);

            // create remote domain on registrar's side
            CreateRegistrarDomain(packageId);
            // create local domain on WebsitePanel's side
            CreateWebsitePanelDomain(packageId);
        }
		private void BindPlanQuotas(KeyValueBunch quotas)
		{
			string[] groupKeys = quotas.GetAllKeys();
			//
			foreach (string groupKey in groupKeys)
			{
				//
				PlaceHolder container = (PlaceHolder)FindControl(groupKey);
				//
				if (container != null)
					container.Visible = true;

				//
				Repeater repeater = (Repeater)FindControl(groupKey + "_Quotas");
				//
				if (repeater != null)
				{
					//
					repeater.DataSource = quotas[groupKey].Split(',');
					//
					repeater.DataBind();
				}
			}
		}
Esempio n. 23
0
 /// <remarks/>
 public void SubmitCustomerOrderAsync(string contractId, OrderItem[] orderItems, KeyValueBunch extraArgs) {
     this.SubmitCustomerOrderAsync(contractId, orderItems, extraArgs, null);
 }
Esempio n. 24
0
 /// <remarks/>
 public void SubmitCustomerOrderAsync(string contractId, OrderItem[] orderItems, KeyValueBunch extraArgs, object userState) {
     if ((this.SubmitCustomerOrderOperationCompleted == null)) {
         this.SubmitCustomerOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSubmitCustomerOrderOperationCompleted);
     }
     this.InvokeAsync("SubmitCustomerOrder", new object[] {
                 contractId,
                 orderItems,
                 extraArgs}, this.SubmitCustomerOrderOperationCompleted, userState);
 }
        public static OrderResult SubmitCustomerOrder(string contractId, OrderItem[] orderItems, KeyValueBunch extraArgs)
        {
            //
            Contract contract = ContractSystem.ContractController.GetContract(contractId);

            // Impersonate
            ContractSystem.ContractController.ImpersonateAsContractReseller(contract);
            //
            OrderResult oResult = new OrderResult();
            // check account
            SecurityResult sResult = StorehouseController.CheckAccountActive();

            //
            if (!sResult.Success)
            {
                //
                oResult.Succeed = false;
                //
                oResult.ResultCode = sResult.ResultCode;
                //
                return(oResult);
            }
            // check order items not empty
            if (orderItems == null || orderItems.Length == 0)
            {
                //
                oResult.Succeed = false;
                //
                oResult.ResultCode = EMPTY_ORDER_ITEMS_CODE;
                //
                return(oResult);
            }
            //
            ES.TaskManager.StartTask("Storefront", "SUBMIT_CUSTOMER_ORDER");

            //
            try
            {
                string currency = StorehouseController.GetBaseCurrency(contract.ResellerId);
                // ordered services
                List <int> orderedSvcs = new List <int>();
                // build services to be ordered
                for (int i = 0; i < orderItems.Length; i++)
                {
                    //
                    OrderItem orderItem = orderItems[i];
                    //
                    int orderedSvcId = 0;
                    //
                    orderItem.ParentSvcId = (orderItem.ParentIndex > -1) ? orderedSvcs[orderItem.ParentIndex] : orderItem.ParentSvcId;
                    // load svc type
                    ProductType svcType = StorehouseController.GetProductType(orderItem.TypeId);
                    //
                    IServiceProvisioning controller = (IServiceProvisioning)Activator.CreateInstance(
                        Type.GetType(svcType.ProvisioningController));
                    // add service
                    orderedSvcId = controller.AddServiceInfo(contractId, currency, orderItem);
                    // check service controller result
                    if (orderedSvcId < 1)
                    {
                        // ROLLBACK HERE
                        StorehouseController.BulkServiceDelete(contractId, orderedSvcs.ToArray());
                        oResult.Succeed    = false;
                        oResult.ResultCode = orderedSvcId;
                        return(oResult);
                        // EXIT
                    }
                    //
                    orderedSvcs.Add(orderedSvcId);
                }
                // build invoice lines
                List <InvoiceItem> invoiceLines = InvoiceController.CalculateInvoiceLinesForServices(orderedSvcs);
                //
                int resultCode = InvoiceController.AddInvoice(contractId, invoiceLines, extraArgs);
                // ERROR
                if (resultCode < 1)
                {
                    // ROLLBACK HERE
                    StorehouseController.BulkServiceDelete(contractId, orderedSvcs.ToArray());
                    oResult.Succeed    = false;
                    oResult.ResultCode = resultCode;
                    return(oResult);
                }
                //
                oResult.OrderInvoice = resultCode;
                //
                oResult.Succeed = true;
            }
            catch (Exception ex)
            {
                //
                oResult.ResultCode = -1;
                //
                oResult.Succeed = false;
                //
                ES.TaskManager.WriteError(ex);
            }
            finally
            {
                //
                ES.TaskManager.CompleteTask();
            }
            //
            return(oResult);
        }
Esempio n. 26
0
 /// <remarks/>
 public System.IAsyncResult BeginSetPluginProperties(int userId, int pluginId, KeyValueBunch props, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("SetPluginProperties", new object[] {
                 userId,
                 pluginId,
                 props}, callback, asyncState);
 }
Esempio n. 27
0
        public static int AddInvoice(string contractId, DateTime created, DateTime dueDate,
                                     int taxationId, decimal totalAmount, decimal subTotalAmount, decimal taxAmount, List <InvoiceItem> invoiceLines, KeyValueBunch extraArgs)
        {
            //
            try
            {
                Contract contract = ContractSystem.ContractController.GetContract(contractId);
                //
                ES.TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.TASK_ADD_INVOICE);
                // build xml representation
                string invoiceLinesXml = BuildAddXmlForInvoiceItems(invoiceLines);
                // add invoice
                int result = EcommerceProvider.AddInvoice(contractId, created, dueDate,
                                                          taxationId, totalAmount, subTotalAmount, taxAmount, invoiceLinesXml,
                                                          StorehouseController.GetBaseCurrency(contract.ResellerId));

                // check error
                if (result < 1)
                {
                    return(result); // EXIT
                }
                // build invoice number
                Invoice       invoice  = GetCustomerInvoiceInternally(result);
                StoreSettings settings = StorehouseController.GetStoreSettings(contract.ResellerId, StoreSettings.SYSTEM_SETTINGS);
                if (!String.IsNullOrEmpty(settings["InvoiceNumberFormat"]))
                {
                    Hashtable options = new Hashtable();
                    options["ID"]         = result;
                    invoice.InvoiceNumber = StorehouseController.ApplyStringCustomFormat(
                        settings["InvoiceNumberFormat"], options);
                }
                else
                {
                    invoice.InvoiceNumber = result.ToString();
                }
                // update invoice
                InvoiceController.UpdateInvoice(invoice.InvoiceId, invoice.InvoiceNumber, invoice.DueDate,
                                                invoice.Total, invoice.SubTotal, invoice.TaxationId, invoice.TaxAmount, invoice.Currency);
                //

                Hashtable parameters = new Hashtable();

                parameters.Add(SystemTaskParams.PARAM_CONTRACT, contract);
                parameters.Add(SystemTaskParams.PARAM_INVOICE, invoice);
                parameters.Add(SystemTaskParams.PARAM_INVOICE_LINES, invoiceLines);
                parameters.Add(SystemTaskParams.PARAM_EXTRA_ARGS, extraArgs);

                TaskManager.UpdateParams(parameters);
                //
                return(result);
            }
            catch (Exception ex)
            {
                throw ES.TaskManager.WriteError(ex);
            }
            finally
            {
                ES.TaskManager.CompleteTask();
            }
        }
Esempio n. 28
0
 /// <remarks/>
 public void GetCheckoutFormParamsAsync(string contractId, int invoiceId, string methodName, KeyValueBunch options) {
     this.GetCheckoutFormParamsAsync(contractId, invoiceId, methodName, options, null);
 }
Esempio n. 29
0
 /// <remarks/>
 public void GetCheckoutFormParamsAsync(string contractId, int invoiceId, string methodName, KeyValueBunch options, object userState) {
     if ((this.GetCheckoutFormParamsOperationCompleted == null)) {
         this.GetCheckoutFormParamsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetCheckoutFormParamsOperationCompleted);
     }
     this.InvokeAsync("GetCheckoutFormParams", new object[] {
                 contractId,
                 invoiceId,
                 methodName,
                 options}, this.GetCheckoutFormParamsOperationCompleted, userState);
 }
		private void SaveRegistrarSettings()
		{
			try
			{
				KeyValueBunch props = new KeyValueBunch();
				//
				props[EnomSettings.USERNAME] = txtServiceUsername.Text.Trim();
				props[EnomSettings.LIVE_MODE] = chkLiveMode.Checked.ToString();
				if (txtServicePassword.PasswordChanged)
					props[EnomSettings.PASSWORD] = txtServicePassword.Text;
				// set plugins props
				int result = StorehouseHelper.SetPluginProperties(SupportedPlugin.ENOM, props);
				if (result < 0)
				{
					// ERROR
					ShowResultMessage(result);
					return;
				}
				//
				RedirectToBrowsePage();
			}
			catch (Exception ex)
			{
				ShowErrorMessage("SAVE_PLUGIN_SETTINGS", ex);
			}
		}
Esempio n. 31
0
 public OrderResult SubmitCustomerOrder(string contractId, OrderItem[] orderItems, KeyValueBunch extraArgs)
 {
     return(StorefrontController.SubmitCustomerOrder(contractId, orderItems, extraArgs));
 }
Esempio n. 32
0
 public CheckoutFormParams GetCheckoutFormParams(string contractId, int invoiceId,
                                                 string methodName, KeyValueBunch options)
 {
     return(SystemPluginController.GetCheckoutFormParams(contractId, invoiceId, methodName, options));
 }
Esempio n. 33
0
 /// <remarks/>
 public System.IAsyncResult BeginSubmitCustomerOrder(string contractId, OrderItem[] orderItems, KeyValueBunch extraArgs, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("SubmitCustomerOrder", new object[] {
                 contractId,
                 orderItems,
                 extraArgs}, callback, asyncState);
 }
		private void SaveRegistrarSettings()
		{
			try
			{
				//
				string username = txtServiceUsername.Text.Trim();
				string parentId = txtServiceParentId.Text.Trim();
				// init
				KeyValueBunch settings = new KeyValueBunch();
				settings[DirectiSettings.USERNAME] = username;
				settings[DirectiSettings.PARENT_ID] = parentId;
				// password has been changed
				if (txtServicePassword.PasswordChanged)
					settings[DirectiSettings.PASSWORD] = txtServicePassword.Text;
				//
				settings[DirectiSettings.LIVE_MODE] = chkLiveMode.Checked.ToString();
				settings[DirectiSettings.SECURE_CHANNEL] = chkSecureChannel.Checked.ToString();

				int result = StorehouseHelper.SetPluginProperties(SupportedPlugin.DIRECTI, settings);
				// ERROR
				if (result < 0)
				{
					HostModule.ShowResultMessage(result);
					return;
				}
				//
				RedirectToBrowsePage();
			}
			catch (Exception ex)
			{
				// ERROR
				ShowErrorMessage("SAVE_PLUGIN_SETTINGS", ex);
			}
		}
Esempio n. 35
0
 public OrderResult SubmitCustomerOrder(string contractId, OrderItem[] orderItems, KeyValueBunch extraArgs) {
     object[] results = this.Invoke("SubmitCustomerOrder", new object[] {
                 contractId,
                 orderItems,
                 extraArgs});
     return ((OrderResult)(results[0]));
 }
Esempio n. 36
0
 /// <remarks/>
 public System.IAsyncResult BeginGetCheckoutFormParams(string contractId, int invoiceId, string methodName, KeyValueBunch options, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("GetCheckoutFormParams", new object[] {
                 contractId,
                 invoiceId,
                 methodName,
                 options}, callback, asyncState);
 }
Esempio n. 37
0
        public static int AddInvoice(string contractId, List <InvoiceItem> invoiceLines, KeyValueBunch extraArgs)
        {
            ContractAccount account = ContractSystem.ContractController.GetContractAccountSettings(contractId);
            // read customer tax
            Taxation tax        = GetCustomerTaxation(contractId, account[ContractAccount.COUNTRY], account[ContractAccount.STATE]);
            int      taxationId = (tax == null) ? -1 : tax.TaxationId;

            // Calculate invoice amounts
            decimal totalAmount = 0, subTotalAmount = 0, taxAmount = 0;

            CalculateInvoiceChargeAmounts(tax, invoiceLines, out totalAmount, out subTotalAmount, out taxAmount);

            // align svcs suspend date
            int[] svcs = new int[invoiceLines.Count];
            for (int i = 0; i < invoiceLines.Count; i++)
            {
                svcs[i] = invoiceLines[i].ServiceId;
            }
            DateTime sdateAligned = ServiceController.GetSvcsSuspendDateAligned(svcs, DateTime.Now);
            //
            StoreSettings settings = StorehouseController.GetStoreSettings(ES.SecurityContext.User.UserId,
                                                                           StoreSettings.SYSTEM_SETTINGS);
            // get invoice grace period in days
            int gracePeriod = Common.Utils.Utils.ParseInt(settings["InvoiceGracePeriod"], 0);

            //
            if (gracePeriod < 0)
            {
                gracePeriod = 0;
            }
            //
            DateTime created = DateTime.Now;
            DateTime dueDate = sdateAligned.AddDays(gracePeriod);

            //
            return(AddInvoice(contractId, created, dueDate, taxationId, totalAmount, subTotalAmount, taxAmount,
                              invoiceLines, extraArgs));
        }
Esempio n. 38
0
 public CheckoutFormParams GetCheckoutFormParams(string contractId, int invoiceId, string methodName, KeyValueBunch options) {
     object[] results = this.Invoke("GetCheckoutFormParams", new object[] {
                 contractId,
                 invoiceId,
                 methodName,
                 options});
     return ((CheckoutFormParams)(results[0]));
 }
Esempio n. 39
0
 public int SetPluginProperties(int userId, int pluginId, KeyValueBunch props)
 {
     return(SystemPluginController.SetPluginProperties(userId, pluginId, props));
 }
        public static KeyValueBunch GetHostingPlansQuotas(int resellerId, int planId)
        {
            KeyValueBunch hpQuotas = new KeyValueBunch();

            //
            ES.SecurityContext.SetThreadPrincipal(resellerId);
            //
            ES.HostingPlanContext ctx = ES.PackageController.GetHostingPlanContext(planId);
            //
            if (ctx != null)
            {
                //
                ES.QuotaValueInfo[] quotasArray = ctx.QuotasArray;
                //
                for (int i = 0; i < ctx.GroupsArray.Length; i++)
                {
                    //
                    ES.HostingPlanGroupInfo group = ctx.GroupsArray[i];
                    //
                    if (group.Enabled)
                    {
                        //
                        List <string> planQuota = new List <string>();
                        //
                        foreach (ES.QuotaValueInfo quota in quotasArray)
                        {
                            //
                            if (quota.QuotaName.StartsWith(group.GroupName))
                            {
                                // boolean quota
                                if (quota.QuotaTypeId == 1)
                                {
                                    // only enabled quotas will be displayed
                                    if (quota.QuotaAllocatedValue == 1)
                                    {
                                        planQuota.Add(quota.QuotaName + "=Enabled");
                                    }
                                }
                                // numeric
                                else
                                {
                                    if (quota.QuotaAllocatedValue > 0)
                                    {
                                        planQuota.Add(quota.QuotaName + "=" + quota.QuotaAllocatedValue);
                                    }
                                    else if (quota.QuotaAllocatedValue == -1)
                                    {
                                        planQuota.Add(quota.QuotaName + "=Unlimited");
                                    }
                                }
                            }
                        }
                        // only filled-up groups are allowed to display
                        if (planQuota.Count > 0)
                        {
                            hpQuotas[group.GroupName] = String.Join(",", planQuota.ToArray());
                        }
                    }
                }
            }
            //
            return(hpQuotas);
        }
Esempio n. 41
0
 /// <remarks/>
 public void SetPluginPropertiesAsync(int userId, int pluginId, KeyValueBunch props) {
     this.SetPluginPropertiesAsync(userId, pluginId, props, null);
 }
Esempio n. 42
0
 public int SetPluginProperties(int userId, int pluginId, KeyValueBunch props) {
     object[] results = this.Invoke("SetPluginProperties", new object[] {
                 userId,
                 pluginId,
                 props});
     return ((int)(results[0]));
 }
        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()));
        }
Esempio n. 44
0
 /// <remarks/>
 public void SetPluginPropertiesAsync(int userId, int pluginId, KeyValueBunch props, object userState) {
     if ((this.SetPluginPropertiesOperationCompleted == null)) {
         this.SetPluginPropertiesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetPluginPropertiesOperationCompleted);
     }
     this.InvokeAsync("SetPluginProperties", new object[] {
                 userId,
                 pluginId,
                 props}, this.SetPluginPropertiesOperationCompleted, userState);
 }