Esempio n. 1
0
        public static List <GenericSvcResult> ActivateInvoice(int invoiceId, bool sendEmail)
        {
            List <GenericSvcResult> results = new List <GenericSvcResult>();

            try
            {
                Invoice invoice = InvoiceController.GetCustomerInvoiceInternally(invoiceId);
                //
                ES.TaskManager.StartTask("SPF", "ACTIVATE_INVOICE");
                ES.TaskManager.WriteParameter("InvoiceID", invoiceId);
                //
                ActivatePaidInvoicesTask task = new ActivatePaidInvoicesTask();
                // load invoice lines
                List <InvoiceItem> lines = InvoiceController.GetCustomerInvoiceItems(invoiceId);
                // iterate and activate
                foreach (InvoiceItem line in lines)
                {
                    if (!line.Processed && line.ServiceId > 0)
                    {
                        results.Add(task.ActivateInvoiceItem(line));
                    }
                }
            }
            catch (Exception ex)
            {
                ES.TaskManager.WriteError(ex);
            }
            finally
            {
                ES.TaskManager.CompleteTask();
            }
            //
            return(results);
        }
Esempio n. 2
0
        public static int SendNewInvoiceNotification(int invoiceId)
        {
            Invoice            invoice      = InvoiceController.GetCustomerInvoiceInternally(invoiceId);
            List <InvoiceItem> invoiceLines = InvoiceController.GetCustomerInvoiceItems(invoiceId);

            return(SendNewInvoiceNotification(invoice, invoiceLines, null));
        }
Esempio n. 3
0
 public override void ExecuteTrigger(TriggerEventArgs eventArgs)
 {
     //
     try
     {
         ActivatePaidInvoicesTask activator = new ActivatePaidInvoicesTask();
         // Load invoice items to activate
         List <InvoiceItem> items = InvoiceController.GetCustomerInvoiceItems(Convert.ToInt32(ReferenceId));
         //
         foreach (InvoiceItem item in items)
         {
             try
             {
                 ES.TaskManager.Write("Activating service");
                 // activating
                 GenericSvcResult result = activator.ActivateInvoiceItem(item);
                 // LOG ERROR
                 if (!result.Succeed)
                 {
                     ES.TaskManager.WriteError(result.Error);
                     if (!String.IsNullOrEmpty(result.ErrorCode))
                     {
                         ES.TaskManager.WriteParameter("Error code", result.ErrorCode);
                     }
                     ES.TaskManager.WriteParameter("Result code", result.ResultCode);
                     // go to next item
                     continue;
                 }
                 //
                 ES.TaskManager.Write("Activated");
             }
             catch (Exception ex)
             {
                 ES.TaskManager.WriteError(ex);
             }
         }
     }
     catch (Exception ex)
     {
         TriggerStatus = "ERROR";
         ES.TaskManager.WriteError(ex);
     }
 }
        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. 5
0
        public static int SendNewInvoiceNotification(Invoice invoice)
        {
            List <InvoiceItem> invoiceLines = InvoiceController.GetCustomerInvoiceItems(invoice.InvoiceId);

            return(SendNewInvoiceNotification(invoice, invoiceLines, null));
        }