//------------------------------------------------------------------------------------------- private Billpayment SendPaymentViaBillPay(Accounting_Checks check) { using (WeavverEntityContainer data = new WeavverEntityContainer()) { var financialAccount = (from x in data.Accounting_Accounts where x.Id == AccountId select x).First(); Logistics_Addresses address = null; Billpayment billPayment = new Billpayment(); billPayment.FIUrl = Url; billPayment.FIId = FinancialInstitutionId.ToString(); billPayment.FIOrganization = FinancialInstitutionName; billPayment.OFXUser = Username; billPayment.OFXPassword = Password; billPayment.Payment.FromBankId = BankId; billPayment.Payment.FromAccountId = financialAccount.AccountNumber; billPayment.Payment.FromAccountType = ConvertWeavverLedgerTypeToEbankingAccountType((LedgerType) Enum.Parse(typeof(LedgerType), financialAccount.LedgerType)); billPayment.Payment.Memo = check.Memo; billPayment.Payment.Amount = check.Amount.ToString(); billPayment.Payment.DateDue = check.PostAt.ToString("MM/dd/yy"); billPayment.Payee.Account = check.Payee.ToString(); billPayment.Payee.State = address.State; billPayment.Payee.Addr1 = address.Line1; billPayment.PayBill(); // response stuff //lblCurrency.Text = billpayment1.Payment.CurrencyCode; //lblPaymentId.Text = billpayment1.Payment.Id; //lblPaymentDate.Text = billpayment1.Payment.DateProcessed; //lblStatus.Text = billpayment1.Payment.Status; //lblCheckNumber.Text = billpayment1.Payment.CheckNumber; return billPayment; } // , "Bill payment completed successfully! If payment was a scheduled transaction (not immediate), make a note of the Payment ID if want to modify or cancel this payment at a later time.", "Bill Payment Acknowledgment", MessageBoxButtons.OK, MessageBoxIcon.Information); }
//------------------------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <returns>Returns added check count</returns> private int ImportScheduledPayments() { var financialAccount = GetAccount(); if (financialAccount.LedgerType != LedgerType.Checking.ToString()) return -1; Billpayment billPaymentData = GetOFXBillPaymentObject(); billPaymentData.SynchronizePayments("REFRESH"); billPaymentData.SynchronizePayees("REFRESH"); using (WeavverEntityContainer data = new WeavverEntityContainer()) { foreach (var remotePayment in billPaymentData.SyncPayments) { Accounting_Checks matchingCheck = (from check in data.Accounting_Checks where check.OrganizationId == financialAccount.OrganizationId && check.ExternalId == remotePayment.Id select check).FirstOrDefault(); if (matchingCheck == null) { Accounting_Checks check = new Accounting_Checks(); check.Id = Guid.NewGuid(); check.OrganizationId = financialAccount.OrganizationId; check.ExternalId = remotePayment.Id; check.AccountId = financialAccount.Id; check.PostAt = DateTime.Parse(remotePayment.DateDue); check.CheckNumber = Int32.Parse(remotePayment.CheckNumber); check.Status = GetStandardCheckStatus(remotePayment.Status); check.Payee = GetOrganizationIdForPayee(remotePayment.PayeeListId); check.Memo = remotePayment.Memo; check.Amount = Decimal.Parse(remotePayment.Amount); data.Accounting_Checks.Add(check); } else { if (matchingCheck.Status != "Cleared" && matchingCheck.Status != GetStandardCheckStatus(remotePayment.Status)) { matchingCheck.Status = GetStandardCheckStatus(remotePayment.Status); } } } return data.SaveChanges(); } }