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); }
public static int SendNewInvoiceNotification(int invoiceId) { Invoice invoice = InvoiceController.GetCustomerInvoiceInternally(invoiceId); List <InvoiceItem> invoiceLines = InvoiceController.GetCustomerInvoiceItems(invoiceId); return(SendNewInvoiceNotification(invoice, invoiceLines, null)); }
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 Invoice GetCustomerInvoice(int invoiceId) { return(InvoiceController.GetCustomerInvoiceInternally(invoiceId)); }
/// <summary> /// Performs checkout operation /// </summary> /// <param name="spaceId">Space.</param> /// <param name="gatewayId">Gateway.</param> /// <param name="invoiceId">Invoice.</param> /// <param name="details">Array of parameters.</param> /// <returns>Checkout result object.</returns> public static CheckoutResult CheckOut(string contractId, int invoiceId, string methodName, CheckoutDetails details) { CheckoutResult result = new CheckoutResult(); try { Contract contractInfo = ContractSystem.ContractController.GetContract(contractId); // impersonate ContractSystem.ContractController.ImpersonateAsContractReseller(contractInfo); // TRACE ES.TaskManager.StartTask(TASK_SOURCE, CHECKOUT_TASK, methodName); ES.TaskManager.Write("Start accepting payment for invoice"); ES.TaskManager.WriteParameter("ContractID", contractId); ES.TaskManager.WriteParameter("InvoiceID", invoiceId); // get user details ContractAccount account = ContractSystem.ContractController.GetContractAccountSettings(contractId); // try to load plugin type and throw an exception if type not found IPaymentGatewayProvider provider = (IPaymentGatewayProvider)SystemPluginController.GetContractPaymentMethod( contractInfo, methodName); // add invoice details Invoice invoice = InvoiceController.GetCustomerInvoiceInternally(invoiceId); // append information for the provider details[CheckoutKeys.ContractNumber] = contractId; details[CheckoutKeys.Amount] = invoice.Total.ToString("0.00"); details[CheckoutKeys.InvoiceNumber] = invoice.InvoiceNumber; details[CheckoutKeys.Currency] = invoice.Currency; ES.TaskManager.Write("Submitting payment transaction"); // call checkout routine TransactionResult pgResult = provider.SubmitPaymentTransaction(details); // log provider response SystemPluginController.LogContractPayment(contractInfo, methodName, pgResult.RawResponse); // ERROR if (!pgResult.Succeed) { result.Succeed = false; result.StatusCode = pgResult.StatusCode; // ES.TaskManager.WriteError("Transaction failed"); ES.TaskManager.WriteParameter("StatusCode", result.StatusCode); ES.TaskManager.WriteParameter("RawResponse", pgResult.RawResponse); // EXIT return(result); } // OK ES.TaskManager.Write("Transaction is OK"); // check whether the transaction already exists CustomerPayment tran = StorehouseController.LookupForTransaction(pgResult.TransactionId); // lookup for pending transaction if (tran == null) { // add payment record result.PaymentId = StorehouseController.AddCustomerPayment(contractId, invoice.InvoiceId, pgResult.TransactionId, invoice.Total, invoice.Currency, methodName, pgResult.TransactionStatus); // ERROR if (result.PaymentId < 1) { result.Succeed = false; result.StatusCode = result.PaymentId.ToString(); // ES.TaskManager.WriteError("Could not add customer payment record to the db"); ES.TaskManager.WriteParameter("ResultCode", result.StatusCode); // EXIT return(result); } } // if transaction is already submitted just update it's status if (tran != null) { StorehouseController.UpdateTransactionStatus(tran.PaymentId, pgResult.TransactionStatus); } // OK result.Succeed = true; // ensure user requests to persist his payment details for credit card if (details.Persistent && methodName == PaymentMethod.CREDIT_CARD) { StorehouseController.SetPaymentProfile(contractId, details); } } catch (Exception ex) { result.Succeed = false; result.StatusCode = GENERAL_FAILURE; // ES.TaskManager.WriteError(ex); } finally { ES.TaskManager.CompleteTask(); } // EXIT return(result); }
public static Invoice GetCustomerInvoice(int resellerId, int userId, int invoiceId, string sessionId) { return(InvoiceController.GetCustomerInvoiceInternally(invoiceId)); }