private void InitPaymentMethods() { AuthorizeNet authorizeNet = new AuthorizeNet(); if ((AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSECURENETVAULTV4 && AppLogic.SecureNetVaultIsEnabled()) || authorizeNet.IsCimEnabled) { tblPaymentMethods.Visible = true; PaymentMethods_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/paymentmethods.gif"); tblPaymentMethodsBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle") + "margin-top:-2px;"); } else { return; } pnlSecureNetPaymentMethods.Visible = AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSECURENETVAULTV4 && AppLogic.SecureNetVaultIsEnabled(); PanelWallet.Visible = authorizeNet.IsCimEnabled && ThisCustomer.PrimaryBillingAddressID != 0; if (ThisCustomer.PrimaryBillingAddressID == 0) { LabelPanelMessage.Visible = true; LabelPanelMessage.Text = AppLogic.GetString("account.aspx.92", SkinID, ThisCustomer.LocaleSetting); } else { LabelPanelMessage.Visible = false; } if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSECURENETVAULTV4 && AppLogic.SecureNetVaultIsEnabled()) { ctrlAccount.ShowSaveCC = true; ctrlAccount.SaveCC = true; } }
public long CreateCustomerProfile(string email, string description,out AuthorizeNet.APICore.messagesType messages) { long result = 0; string profileId = "0"; AuthorizeNet.APICore.customerProfileType profile = new AuthorizeNet.APICore.customerProfileType(); profile.email = email; profile.description = description; AuthorizeNet.APICore.createCustomerProfileRequest req = new AuthorizeNet.APICore.createCustomerProfileRequest(); req.profile = profile; AuthorizeNet.HttpXmlUtility util = new AuthorizeNet.HttpXmlUtility(ServiceMode, MerchantAuthenticationType.name, MerchantAuthenticationType.transactionKey); AuthorizeNet.APICore.createCustomerProfileResponse response = null; try { response = (AuthorizeNet.APICore.createCustomerProfileResponse)util.Send(req); long.TryParse(response.customerProfileId, out result); } catch (System.InvalidOperationException ex) { if (ex.Message.Contains(DUPLICATE_PROFILE_MESSAGE)) { profileId = ex.Message.Replace(DUPLICATE_PROFILE_MESSAGE, String.Empty).Replace(" already exists.", String.Empty); long.TryParse(profileId, out result); } } messages = response.messages; return result; }
private void InitPaymentMethods() { AuthorizeNet authorizeNet = new AuthorizeNet(); if ((AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSECURENETVAULTV4 && AppLogic.SecureNetVaultIsEnabled()) || authorizeNet.IsCimEnabled) { pnlPaymentMethods.Visible = true; } else { return; } pnlSecureNetPaymentMethods.Visible = AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSECURENETVAULTV4 && AppLogic.SecureNetVaultIsEnabled(); PanelWallet.Visible = authorizeNet.IsCimEnabled && ThisCustomer.PrimaryBillingAddressID != 0; if (ThisCustomer.PrimaryBillingAddressID == 0) { LabelPanelMessage.Visible = true; LabelPanelMessage.Text = AppLogic.GetString("account.aspx.92", SkinID, ThisCustomer.LocaleSetting); } else { LabelPanelMessage.Visible = false; } if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSECURENETVAULTV4 && AppLogic.SecureNetVaultIsEnabled()) { ctrlAccount.ShowSaveCC = true; ctrlAccount.SaveCC = true; } }
public AuthorizeNet.APICore.createCustomerPaymentProfileResponse CreateCustomerPaymentProfile(AuthorizeNet.APICore.customerPaymentProfileType paymentProfile, long profileId) { AuthorizeNet.APICore.createCustomerPaymentProfileRequest req = new AuthorizeNet.APICore.createCustomerPaymentProfileRequest(); req.customerProfileId = profileId.ToString(); req.paymentProfile = paymentProfile; AuthorizeNet.HttpXmlUtility util = new AuthorizeNet.HttpXmlUtility(ServiceMode, MerchantAuthenticationType.name, MerchantAuthenticationType.transactionKey); return (AuthorizeNet.APICore.createCustomerPaymentProfileResponse)util.Send(req); }
private AuthorizeNet AuthorizeNetReadLine(string line, int index) { AuthorizeNet authorizeNet = new AuthorizeNet(); authorizeNet.Index = index; authorizeNet.Status = false; try { line = line.Replace("\"", ""); authorizeNet.Load_Fields(line); authorizeNet.Load_Transaction_Date(authorizeNet.Transaction_Date); authorizeNet.Load_Payment_Method(authorizeNet.Payment_Method); authorizeNet.Load_Credit_Card_Number(authorizeNet.Credit_Card_Number); authorizeNet.Load_Auth_Code(authorizeNet.Auth_Code); authorizeNet.Load_Transaction_ID(authorizeNet.Transaction_ID); return(authorizeNet); } catch { authorizeNet.Error = "The line format incorrect."; return(authorizeNet); } }
private List <AuthorizeNet> AuthorizeNetReadFile(HttpPostedFileBase fileAuthorizeNet) { List <AuthorizeNet> AuthorizeNetList = new List <AuthorizeNet>(); AuthorizeNet authorizeNet = new AuthorizeNet(); string fileName = Path.GetFileName(fileAuthorizeNet.FileName); string folder = Server.MapPath("~/UploadedFiles"); string path = Path.Combine(folder, fileName); if (System.IO.File.Exists(path)) { int index = 0; string line; using (System.IO.StreamReader file = new System.IO.StreamReader(path)) { while ((line = file.ReadLine()) != null) { if (index == 0) { if (line.ToLower().Trim() != "Date_Ordered;Order_Number;Source_DNIS;KEYCODE;BILL_TO_First_Name;Last_Name;Address_1;Address_2;City;State_Province;Zip_Code;Country;Telephone_Number;E_mail_Address;Payment_Method;Credit_Card_Number;Expiry_Date;Auth_Code;Transaction_ID;TRANSACTION_DATE;Check_Routing_Number;Check_Account_Number;Check_Number;Amount_Paid_Check_Only;Ship_To_First_Name;Ship_To_Last_Name;Ship_To_Add1;Ship_To_Add2;Ship_To_City;Ship_To_State;Ship_To_Zip;Ship_To_Country;Order_Level_Tax;Order_Level_SH;Order_Level_Total_Amount;SKU_1;DESCRIPTION_1;QTY_1;PRICE_1;TAX_1;S_H_1;SKU_2;DESCRIPTION_2;QTY_2;PRICE_2;TAX_2;S_H_2;SKU_3;DESCRIPTION_3;QTY_3;PRICE_3;TAX_3;S_H_3;SKU_4;DESCRIPTION_4;QTY_4;PRICE_4;TAX_4;S_H_4;SKU_5;DESCRIPTION_5;QTY_5;PRICE_5;TAX_5;S_H_5;RESERVED_1;RESERVED_2;RESERVED_3;RESERVED_4;RESERVED_5;".ToLower()) { throw new Exception(string.Format("La cabecera del archivo '{0}' es incorrecta.!!", fileName)); } } if (index > 0) { authorizeNet = AuthorizeNetReadLine(line, index); authorizeNet.Validate(); AuthorizeNetList.Add(authorizeNet); } index++; } } } return(AuthorizeNetList); }
protected Result Validate(List <ShoppingCart> ShoppingCartList, List <AuthorizeNet> AuthorizeNetList) { Result result = new Result(); List <AuthorizeNet> ResultAuthorizeNet = new List <AuthorizeNet>(); int ShoppingCartCount = ShoppingCartList.Count; ShoppingCart ShoppingCartItem = null; AuthorizeNet AuthorizeNetItem = null; for (int i = 0; i <= ShoppingCartCount - 1; i++) { ShoppingCartItem = ShoppingCartList[i]; AuthorizeNetItem = AuthorizeNetList.Where(item => item.Key == ShoppingCartItem.Key && item.IndexShoppingCart == 0).FirstOrDefault(); if (AuthorizeNetItem != null) { AuthorizeNetItem.IndexShoppingCart = ShoppingCartItem.Index; ShoppingCartItem.IndexAuthorizeNet = AuthorizeNetItem.Index; } } List <ShoppingCart> ShoppingCartListInvalidate = new List <ShoppingCart>(); List <AuthorizeNet> AuthorizeNetListInvalidate = new List <AuthorizeNet>(); ShoppingCartListInvalidate = ShoppingCartList.Where(item => item.IndexAuthorizeNet == 0).ToList(); AuthorizeNetListInvalidate = AuthorizeNetList.Where(item => item.IndexShoppingCart == 0).ToList(); result.ShoppingCartList = ShoppingCartList; result.AuthorizeNetList = AuthorizeNetList; if (ShoppingCartListInvalidate.Count > 0) { result.Message = "!!File ShoppingCart Not equivalent " + ShoppingCartListInvalidate.Count.ToString() + " Rows.!!"; foreach (ShoppingCart item in ShoppingCartListInvalidate) { item.Error = "!!Row not Equivalent.!!"; item.Status = false; result.Message = result.Message + ";Row Incorrect: { " + item.Index.ToString() + " }"; } result.Status = false; result.ShowList = 1; return(result); } if (AuthorizeNetListInvalidate.Count > 0) { result.Message = "!!File AuthorizeNet Not equivalent " + AuthorizeNetListInvalidate.Count.ToString() + " Rows.!!"; foreach (AuthorizeNet item in AuthorizeNetListInvalidate) { item.Error = "!!Row not Equivalent.!!"; item.Status = false; result.Message = result.Message + ";Row Incorrect: { " + item.Index.ToString() + " }"; } result.Status = false; result.ShowList = 2; return(result); } result.Message = "!!Files ShoppingCart and AuthorizeNet equivalents!!.Total " + AuthorizeNetList.Count.ToString() + " Rows"; result.Status = true; result.ShowList = 2; return(result); }
protected string ProcessFields(AuthorizeNet item) { string line = string.Empty; line = line + item.Date_Ordered + ";"; line = line + ProcessField(item.Order_Number); line = line + ProcessField(item.Source_DNIS); line = line + ProcessField(item.KEYCODE); line = line + ProcessField(item.BILL_TO_First_Name); line = line + ProcessField(item.Last_Name); line = line + ProcessField(item.Address_1); line = line + ProcessField(item.Address_2); line = line + ProcessField(item.City); line = line + ProcessField(item.State_Province); line = line + ProcessField(item.Zip_Code); line = line + ProcessField(item.Country); line = line + ProcessField(item.Telephone_Number); line = line + ProcessField(item.E_mail_Address); line = line + ProcessField(item.Payment_Method); line = line + ProcessField(item.Credit_Card_Number); line = line + ProcessField(item.Expiry_Date); line = line + ProcessField(item.Auth_Code); line = line + ProcessField(item.Transaction_ID); line = line + ProcessField(item.Transaction_Date); line = line + ProcessField(item.Check_Routing_Number); line = line + ProcessField(item.Check_Account_Number); line = line + ProcessField(item.Check_Number); line = line + ProcessField(item.Amount_Paid_Check_Only); line = line + ProcessField(item.Ship_To_First_Name); line = line + ProcessField(item.Ship_To_Last_Name); line = line + ProcessField(item.Ship_To_Add1); line = line + ProcessField(item.Ship_To_Add2); line = line + ProcessField(item.Ship_To_City); line = line + ProcessField(item.Ship_To_State); line = line + ProcessField(item.Ship_To_Zip); line = line + ProcessField(item.Ship_To_Country); line = line + ProcessField(item.Order_Level_Tax); line = line + ProcessField(item.Order_Level_SH); line = line + ProcessField(item.Order_Level_Total_Amount); line = line + ProcessField(item.SKU_1); line = line + ProcessField(item.DESCRIPTION_1); line = line + ProcessField(item.QTY_1); line = line + ProcessField(item.PRICE_1); line = line + ProcessField(item.TAX_1); line = line + ProcessField(item.S_H_1); line = line + ProcessField(item.SKU_2); line = line + ProcessField(item.DESCRIPTION_2); line = line + ProcessField(item.QTY_2); line = line + ProcessField(item.PRICE_2); line = line + ProcessField(item.TAX_2); line = line + ProcessField(item.S_H_2); line = line + ProcessField(item.SKU_3); line = line + ProcessField(item.DESCRIPTION_3); line = line + ProcessField(item.QTY_3); line = line + ProcessField(item.PRICE_3); line = line + ProcessField(item.TAX_3); line = line + ProcessField(item.S_H_3); line = line + ProcessField(item.SKU_4); line = line + ProcessField(item.DESCRIPTION_4); line = line + ProcessField(item.QTY_4); line = line + ProcessField(item.PRICE_4); line = line + ProcessField(item.TAX_4); line = line + ProcessField(item.S_H_4); line = line + ProcessField(item.SKU_5); line = line + ProcessField(item.DESCRIPTION_5); line = line + ProcessField(item.QTY_5); line = line + ProcessField(item.PRICE_5); line = line + ProcessField(item.TAX_5); line = line + ProcessField(item.S_H_5); line = line + ProcessField(item.RESERVED_1); line = line + ProcessField(item.RESERVED_2); line = line + ProcessField(item.RESERVED_3); line = line + ProcessField(item.RESERVED_4); line = line + ProcessField(item.RESERVED_5); line = "\"" + line + "\""; return(line); }
IEnumerable<ITransactionMessage> GetTransactionMessage(AuthorizeNet.APICore.messagesType messages,string description) { TransactionMessageType messageType = messages.resultCode == AuthorizeNet.APICore.messageTypeEnum.Ok ? TransactionMessageType.Information : TransactionMessageType.Error; var result = messages.message.Select(n=>new TransactionMessage{ Code=n.code, MessageType=messageType, TransactionMessageResult=n.text, Description=description}); return result; }
public AuthorizeNet.APICore.ARBUpdateSubscriptionResponse UpdateARBSubscription(long subscriptionId, AuthorizeNet.APICore.ARBSubscriptionType subscription) { AuthorizeNet.APICore.ARBUpdateSubscriptionRequest req = new AuthorizeNet.APICore.ARBUpdateSubscriptionRequest(); req.subscriptionId = subscriptionId.ToString(); req.subscription = subscription; AuthorizeNet.HttpXmlUtility util = new AuthorizeNet.HttpXmlUtility(ServiceMode, MerchantAuthenticationType.name, MerchantAuthenticationType.transactionKey); return (AuthorizeNet.APICore.ARBUpdateSubscriptionResponse)util.Send(req); }
private Transaction ProcessPaymentTransaction(OnlineRegModel m, PaymentForm pf) { Transaction ti = null; if (m != null && m.Transaction != null) { ti = PaymentForm.CreateTransaction(DbUtil.Db, m.Transaction, pf.AmtToPay); } else { ti = pf.CreateTransaction(DbUtil.Db); } int?pid = null; if (m != null) { m.ParseSettings(); var terms = Util.PickFirst(m.Terms, ""); if (terms.HasValue()) { ViewData["Terms"] = terms; } pid = m.UserPeopleId; if (m.TranId == null) { m.TranId = ti.Id; } } if (!pid.HasValue) { var pds = DbUtil.Db.FindPerson(pf.First, pf.Last, null, pf.Email, pf.Phone); if (pds.Count() == 1) { pid = pds.Single().PeopleId.Value; } } TransactionResponse tinfo; var gateway = OnlineRegModel.GetTransactionGateway(); if (gateway == "authorizenet") { if (pf.SavePayInfo) { var anet = new AuthorizeNet(DbUtil.Db, pf.testing); tinfo = anet.createCustomerProfileTransactionRequest( pid ?? 0, pf.AmtToPay ?? 0, pf.Description, pf.TranId ?? 0); } else if (pf.Type == "B") { tinfo = OnlineRegModel.PostECheck( pf.Routing, pf.Account, pf.AmtToPay ?? 0, ti.Id, pf.Description, pid ?? 0, pf.First, pf.Last, pf.Address, pf.City, pf.State, pf.Zip, pf.testing); } else { tinfo = OnlineRegModel.PostTransaction( pf.CreditCard, pf.CCV, DbUtil.NormalizeExpires(pf.Expires).ToString2("MMyy"), pf.AmtToPay ?? 0, ti.Id, pf.Description, pid ?? 0, pf.Email, pf.First, pf.Last, pf.Address, pf.City, pf.State, pf.Zip, pf.testing); } } else if (gateway == "sage") { if (pf.SavePayInfo) { var sage = new SagePayments(DbUtil.Db, pf.testing); tinfo = sage.createVaultTransactionRequest( pid ?? 0, pf.AmtToPay ?? 0, pf.Description, ti.Id, pf.Type); } else if (pf.Type == "B") { tinfo = OnlineRegModel.PostVirtualCheckTransactionSage( pf.Routing, pf.Account, pf.AmtToPay ?? 0, ti.Id, pf.Description, pid ?? 0, pf.Email, pf.First, pf.MiddleInitial, pf.Last, pf.Suffix, pf.Address, pf.City, pf.State, pf.Zip, pf.Phone, pf.testing); } else { tinfo = OnlineRegModel.PostTransactionSage( pf.CreditCard, pf.CCV, DbUtil.NormalizeExpires(pf.Expires).ToString2("MMyy"), pf.AmtToPay ?? 0, ti.Id, pf.Description, pid ?? 0, pf.Email, pf.First, pf.MiddleInitial, pf.Last, pf.Suffix, pf.Address, pf.City, pf.State, pf.Zip, pf.Phone, pf.testing); } } else { throw new Exception("unknown gateway " + gateway); } ti.TransactionId = tinfo.TransactionId; if (ti.Testing == true && !ti.TransactionId.Contains("(testing)")) { ti.TransactionId += "(testing)"; } ti.Approved = tinfo.Approved; if (ti.Approved == false) { ti.Amtdue += ti.Amt; if (m != null && m.OnlineGiving()) { ti.Amtdue = 0; } } ti.Message = tinfo.Message; ti.AuthCode = tinfo.AuthCode; ti.TransactionDate = DateTime.Now; DbUtil.Db.SubmitChanges(); return(ti); }
public void Reporting_GetTransactionListTest_DateRange() { //check ApiLoginid / TransactionKey var sError = CheckApiLoginTransactionKey(); Assert.IsTrue(sError == "", sError); var responseStrings = new[] { "<?xml version=\"1.0\" encoding=\"utf-8\"?><getSettledBatchListResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><batchList><batch><batchId>3321516</batchId><settlementTimeUTC>2014-04-06T15:20:51Z</settlementTimeUTC><settlementTimeLocal>2014-04-06T08:20:51</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod></batch><batch><batchId>3323130</batchId><settlementTimeUTC>2014-04-07T15:20:19Z</settlementTimeUTC><settlementTimeLocal>2014-04-07T08:20:19</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod></batch></batchList></getSettledBatchListResponse>", "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionListResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><transactions><transaction><transId>2210220767</transId><submitTimeUTC>2014-04-06T08:48:39Z</submitTimeUTC><submitTimeLocal>2014-04-06T01:48:39</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><firstName>Sue</firstName><lastName>Zhu</lastName><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>1.31</settleAmount><subscription><id>2016601</id><payNum>2</payNum></subscription></transaction></transactions></getTransactionListResponse>", "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionListResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><transactions><transaction><transId>2210248566</transId><submitTimeUTC>2014-04-07T08:53:45Z</submitTimeUTC><submitTimeLocal>2014-04-07T01:53:45</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><firstName>Sue</firstName><lastName>Zhu</lastName><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>1.31</settleAmount><subscription><id>2017665</id><payNum>2</payNum></subscription></transaction></transactions></getTransactionListResponse>" }; LocalRequestObject.ResponseStrings = responseStrings; LocalRequestObject.ResponseStringCount = 0; var target = new ReportingGateway(ApiLogin, TransactionKey); List<Transaction> actual = null; var sErr = ""; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { // Get settled transactions within a date range. actual = target.GetTransactionList(DateTime.Today.AddDays(-30), DateTime.Today); } catch (Exception e) { sErr = e.Message; } Assert.IsNotNull(actual); foreach (var tx in actual) { Assert.IsNotNull(tx.TransactionID); Assert.IsNotNull(tx.DateSubmitted); Assert.IsNotNull(tx.Status); Assert.IsNotNull(tx.CardType); Assert.IsNotNull(tx.CardNumber); Assert.IsNotNull(tx.SettleAmount); Assert.IsNotNull(tx.MarketType); Assert.IsNull(tx.MobileDeviceID); Assert.AreEqual(tx.HasReturnedItems, NullableBooleanEnum.Null); if (tx.Subscription == null) continue; Assert.Greater(tx.Subscription.ID, 0); Assert.Greater(tx.Subscription.PayNum, 0); } }
public ActionResult ManageGiving(ManageGivingModel m) { SetHeaders(m.orgid); RemoveNonDigitsIfNecessary(m); m.ValidateModel(ModelState); if (!ModelState.IsValid) { return(View(m)); } try { var gateway = OnlineRegModel.GetTransactionGateway(); if (gateway == "authorizenet") { var au = new AuthorizeNet(DbUtil.Db, m.testing); au.AddUpdateCustomerProfile(m.pid, m.Type, m.Cardnumber, m.Expires, m.Cardcode, m.Routing, m.Account); } else if (gateway == "sage") { var sg = new SagePayments(DbUtil.Db, m.testing); sg.storeVault(m.pid, m.Type, m.Cardnumber, m.Expires, m.Cardcode, m.Routing, m.Account, giving: true); } else { throw new Exception("ServiceU not supported"); } var mg = m.person.ManagedGiving(); if (mg == null) { mg = new ManagedGiving(); m.person.ManagedGivings.Add(mg); } mg.SemiEvery = m.SemiEvery; mg.Day1 = m.Day1; mg.Day2 = m.Day2; mg.EveryN = m.EveryN; mg.Period = m.Period; mg.StartWhen = m.StartWhen; mg.StopWhen = m.StopWhen; mg.NextDate = mg.FindNextDate(DateTime.Today); var pi = m.person.PaymentInfo(); pi.FirstName = m.firstname.Truncate(50); pi.MiddleInitial = m.middleinitial.Truncate(10); pi.LastName = m.lastname.Truncate(50); pi.Suffix = m.suffix.Truncate(10); pi.Address = m.address.Truncate(50); pi.City = m.city.Truncate(50); pi.State = m.state.Truncate(10); pi.Zip = m.zip.Truncate(15); pi.Phone = m.phone.Truncate(25); var q = from ra in DbUtil.Db.RecurringAmounts where ra.PeopleId == m.pid select ra; DbUtil.Db.RecurringAmounts.DeleteAllOnSubmit(q); DbUtil.Db.SubmitChanges(); foreach (var c in m.FundItemsChosen()) { var ra = new RecurringAmount { PeopleId = m.pid, FundId = c.fundid, Amt = c.amt }; DbUtil.Db.RecurringAmounts.InsertOnSubmit(ra); } DbUtil.Db.SubmitChanges(); } catch (Exception ex) { ModelState.AddModelError("form", ex.Message); } if (!ModelState.IsValid) { return(View(m)); } TempData["managegiving"] = m; return(Redirect("ConfirmRecurringGiving")); }
public AuthorizeNet.APICore.createCustomerProfileTransactionResponse CreateProfileTransaction(AuthorizeNet.APICore.profileTransactionType transaction) { AuthorizeNet.APICore.createCustomerProfileTransactionRequest req = new AuthorizeNet.APICore.createCustomerProfileTransactionRequest(); req.transaction = transaction; req.merchantAuthentication = MerchantAuthenticationType; AuthorizeNet.HttpXmlUtility util = new AuthorizeNet.HttpXmlUtility(ServiceMode, MerchantAuthenticationType.name, MerchantAuthenticationType.transactionKey); return (AuthorizeNet.APICore.createCustomerProfileTransactionResponse)util.Send(req); }
public ActionResult ProcessPayment(PaymentForm pf) { #if DEBUG #else if (Session["FormId"] != null) { if ((Guid)Session["FormId"] == pf.FormId) { return(Content("Already submitted")); } } #endif OnlineRegModel m = null; var ed = DbUtil.Db.RegistrationDatas.SingleOrDefault(e => e.Id == pf.DatumId); if (ed != null) { m = Util.DeSerialize <OnlineRegModel>(ed.Data); } #if DEBUG #else if (m != null && m.History.Contains("ProcessPayment") && !pf.PayBalance) { return(Content("Already submitted")); } #endif if (pf.AmtToPay < 0) { pf.AmtToPay = 0; } if (pf.Donate < 0) { pf.Donate = 0; } pf.AllowCoupon = false; SetHeaders(pf.OrgId ?? 0); if ((pf.AmtToPay ?? 0) <= 0 && (pf.Donate ?? 0) <= 0) { DbUtil.Db.SubmitChanges(); ModelState.AddModelError("form", "amount zero"); return(View("Payment/Process", pf)); } try { if (pf.Type == "B") { Payments.ValidateBankAccountInfo(ModelState, pf.Routing, pf.Account); } if (pf.Type == "C") { Payments.ValidateCreditCardInfo(ModelState, pf); } if (!ModelState.IsValid) { return(View("Payment/Process", pf)); } if (pf.IsLoggedIn == true && pf.SavePayInfo) { var gateway = OnlineRegModel.GetTransactionGateway(); if (gateway == "authorizenet") { var au = new AuthorizeNet(DbUtil.Db, m.testing ?? false); if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X")) || (pf.Type == "C" && !pf.CreditCard.StartsWith("X"))) { au.AddUpdateCustomerProfile(m.UserPeopleId.Value, pf.Type, pf.CreditCard, DbUtil.NormalizeExpires(pf.Expires).ToString2("MMyy"), pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV, pf.Routing, pf.Account); } } else if (gateway == "sage") { var sg = new CmsData.SagePayments(DbUtil.Db, m.testing ?? false); if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X")) || (pf.Type == "C" && !pf.CreditCard.StartsWith("X"))) { sg.storeVault(m.UserPeopleId.Value, pf.Type, pf.CreditCard, DbUtil.NormalizeExpires(pf.Expires).ToString2("MMyy"), pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV, pf.Routing, pf.Account, pf.IsGiving == true); } } else { throw new Exception("ServiceU not supported"); } } if (pf.UseBootstrap) { var r = AddressVerify.LookupAddress(pf.Address, "", "", "", pf.Zip); var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == pf.Zip.Zip5()); if (z != null && !z.State.HasValue()) { pf.State = r.State = z.State; pf.City = r.City = z.City; } if (r.Line1 != "error" && r.Line1.HasValue()) { if (r.found == false) { ModelState.AddModelError("Zip", r.address + ", to skip address check, Change the country to USA, Not Validated"); return(View("Payment/Process", pf)); } if (r.Line1 != pf.Address) { pf.Address = r.Line1; } if (r.City != (pf.City ?? "")) { pf.City = r.City; } if (r.State != (pf.State ?? "")) { pf.State = r.State; } if (r.Zip != (pf.Zip ?? "")) { pf.Zip = r.Zip; } } } var ti = ProcessPaymentTransaction(m, pf); if (ti.Approved == false) { ModelState.AddModelError("form", ti.Message); return(View("Payment/Process", pf)); } if (m != null) { m.TranId = ti.Id; m.History.Add("ProcessPayment"); ed.Data = Util.Serialize <OnlineRegModel>(m); ed.Completed = true; DbUtil.Db.SubmitChanges(); } Session["FormId"] = pf.FormId; if (pf.DatumId > 0) { try { var view = ConfirmTransaction(m, ti.TransactionId); switch (view) { case ConfirmEnum.Confirm: return(View("Confirm", m)); case ConfirmEnum.ConfirmAccount: return(View("ConfirmAccount")); } } catch (Exception ex) { TempData["error"] = ex.Message; return(Redirect("/Error")); } } ConfirmDuePaidTransaction(ti, ti.TransactionId, sendmail: true); ViewBag.amtdue = PaymentForm.AmountDueTrans(DbUtil.Db, ti).ToString("C"); return(View("PayAmtDue/Confirm", ti)); } catch (Exception ex) { ModelState.AddModelError("form", ex.Message); return(View("Payment/Process", pf)); } }
public void Update() { var gateway = OnlineRegModel.GetTransactionGateway(); if (gateway == "authorizenet") { var au = new AuthorizeNet(DbUtil.Db, testing); au.AddUpdateCustomerProfile(pid, Type, Cardnumber, Expires, Cardcode, Routing, Account); } else if (gateway == "sage") { var sg = new SagePayments(DbUtil.Db, testing); sg.storeVault(pid, Type, Cardnumber, Expires, Cardcode, Routing, Account, giving: true); } else { throw new Exception("ServiceU not supported"); } var mg = person.ManagedGiving(); if (mg == null) { mg = new ManagedGiving(); person.ManagedGivings.Add(mg); } mg.SemiEvery = SemiEvery; mg.Day1 = Day1; mg.Day2 = Day2; mg.EveryN = EveryN; mg.Period = Period; mg.StartWhen = StartWhen; mg.StopWhen = StopWhen; mg.NextDate = mg.FindNextDate(DateTime.Today); var pi = person.PaymentInfo(); pi.FirstName = FirstName.Truncate(50); pi.MiddleInitial = Middle.Truncate(10); pi.LastName = LastName.Truncate(50); pi.Suffix = Suffix.Truncate(10); pi.Address = Address.Truncate(50); pi.City = City.Truncate(50); pi.State = State.Truncate(10); pi.Zip = Zip.Truncate(15); pi.Phone = Phone.Truncate(25); var q = from ra in DbUtil.Db.RecurringAmounts where ra.PeopleId == pid select ra; DbUtil.Db.RecurringAmounts.DeleteAllOnSubmit(q); DbUtil.Db.SubmitChanges(); foreach (var c in FundItemsChosen()) { var ra = new RecurringAmount { PeopleId = pid, FundId = c.fundid, Amt = c.amt }; DbUtil.Db.RecurringAmounts.InsertOnSubmit(ra); } DbUtil.Db.SubmitChanges(); }
public ActionResult ProcessPayment(PaymentForm pf) { if (Session["FormId"] != null) { if ((Guid)Session["FormId"] == pf.FormId) { return(Content("Already submitted")); } } OnlineRegModel m = null; var ed = DbUtil.Db.ExtraDatas.SingleOrDefault(e => e.Id == pf.DatumId); if (ed != null) { m = Util.DeSerialize <OnlineRegModel>(ed.Data); } if (pf.AmtToPay < 0) { pf.AmtToPay = 0; } if (pf.Donate < 0) { pf.Donate = 0; } pf.AllowCoupon = false; SetHeaders(pf.OrgId ?? 0); ViewBag.Url = pf.Url; ViewBag.timeout = INT_timeout; if ((pf.AmtToPay ?? 0) <= 0 && (pf.Donate ?? 0) <= 0) { DbUtil.Db.SubmitChanges(); ModelState.AddModelError("form", "amount zero"); return(View("ProcessPayment", pf)); } try { if (pf.Type == "B") { Payments.ValidateBankAccountInfo(ModelState, pf.Routing, pf.Account); } if (pf.Type == "C") { Payments.ValidateCreditCardInfo(ModelState, pf.CreditCard, pf.Expires, pf.CCV); } if (!ModelState.IsValid) { return(View("ProcessPayment", pf)); } if (pf.IsLoggedIn == true && pf.SavePayInfo == true) { var gateway = OnlineRegModel.GetTransactionGateway(); if (gateway == "authorizenet") { var au = new AuthorizeNet(DbUtil.Db, m.testing ?? false); if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X")) || (pf.Type == "C" && !pf.CreditCard.StartsWith("X"))) { au.AddUpdateCustomerProfile(m.UserPeopleId.Value, pf.Type, pf.CreditCard, pf.Expires, pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV, pf.Routing, pf.Account); } } else if (gateway == "sage") { var sg = new CmsData.SagePayments(DbUtil.Db, m.testing ?? false); if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X")) || (pf.Type == "C" && !pf.CreditCard.StartsWith("X"))) { sg.storeVault(m.UserPeopleId.Value, pf.Type, pf.CreditCard, pf.Expires, pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV, pf.Routing, pf.Account, pf.IsGiving == true); } } else { throw new Exception("ServiceU not supported"); } } var ti = ProcessPaymentTransaction(m, pf); if (ti.Approved == false) { ModelState.AddModelError("form", ti.Message); return(View("ProcessPayment", pf)); } if (m != null) { m.TranId = ti.Id; ed.Data = Util.Serialize <OnlineRegModel>(m); DbUtil.Db.SubmitChanges(); } Session["FormId"] = pf.FormId; if (pf.DatumId > 0) { confirm = ConfirmTransaction(m, ti.TransactionId); if (confirm.StartsWith("error:")) { TempData["error"] = confirm.Substring(6); return(Redirect("/Error")); } return(View(confirm)); } ConfirmDuePaidTransaction(ti, ti.TransactionId, sendmail: true); return(View("ConfirmDuePaid", ti)); } catch (Exception ex) { ModelState.AddModelError("form", ex.Message); return(View("ProcessPayment", pf)); } }