protected void ButtonSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } int selectedAddressId = int.Parse(BillingAddresses.SelectedValue); SkinBase page = HttpContext.Current.Handler as SkinBase; AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current; string errorMessage, errorCode; this.PaymentProfileId = ProcessTools.SaveProfileAndPaymentProfile(adnsfCustomer.CustomerID, adnsfCustomer.EMail, AspDotNetStorefrontCore.AppLogic.AppConfig("StoreName"), this.PaymentProfileId, selectedAddressId, TextCreditCard.Text, TextCardSecurity.Text, ExpirationMonth.SelectedValue, ExpirationYear.SelectedValue, out errorMessage, out errorCode); if (PaymentProfileId <= 0) { ShowError(String.Format("{0} {1}", AspDotNetStorefrontCore.AppLogic.GetString("AspDotNetStorefrontGateways.AuthorizeNet.Cim.ErrorMessage", adnsfCustomer.SkinID, adnsfCustomer.LocaleSetting), errorMessage)); return; } if (CBMakePrimaryCard.Checked) { AspDotNetStorefrontCore.Address adnsfAddress = new AspDotNetStorefrontCore.Address(); adnsfAddress.LoadFromDB(selectedAddressId); adnsfAddress.MakeCustomersPrimaryAddress(AspDotNetStorefrontCore.AddressTypes.Billing); DataUtility.SetPrimaryPaymentProfile(adnsfCustomer.CustomerID, this.PaymentProfileId); } BindPage(this.PaymentProfileId); FireCardEditComplete(); }
public void BindPage() { PanelAddPaymentType.Visible = false; ButtonAddPaymentType.Visible = true; AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current; ListViewCreditCards.DataSource = DataUtility.GetPaymentProfiles(adnsfCustomer.CustomerID, adnsfCustomer.EMail); ListViewCreditCards.DataBind(); }
void LogFailedTransaction( AspDotNetStorefrontCore.Customer customer, int originalRecurringOrderNumber, string paymentMethod, string command, string result, string recurringSubscriptionId) { DB.ExecuteSQL( @"insert into FailedTransaction( CustomerID, OrderNumber, IPAddress, OrderDate, PaymentGateway, PaymentMethod, TransactionCommand, TransactionResult, CustomerEMailed, RecurringSubscriptionID) values( @customerId, @originalOrderNumber, @ipAddress, getdate(), @gateway, @paymentMethod, @command, @status, 0, @subscriptionId)" , new SqlParameter("@customerId", customer.CustomerID), new SqlParameter("@originalOrderNumber", originalRecurringOrderNumber), new SqlParameter("@ipAddress", customer.LastIPAddress), new SqlParameter("@gateway", Gateway.eWAYGatewayName), new SqlParameter("@paymentMethod", paymentMethod), new SqlParameter("@command", command), new SqlParameter("@status", result), new SqlParameter("@subscriptionId", recurringSubscriptionId)); }
protected void ListViewCreditCards_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current; Int64 profileId = DataUtility.GetProfileId(adnsfCustomer.CustomerID); Int64 paymentProfileId = long.Parse((string)e.CommandArgument); var profileMgr = new ProfileManager(adnsfCustomer.CustomerID, adnsfCustomer.EMail, profileId); profileMgr.DeletePaymentProfile(paymentProfileId); DataUtility.DeletePaymentProfile(adnsfCustomer.CustomerID, paymentProfileId); this.BindPage(); } else if (e.CommandName == "Edit") { PanelAddPaymentType.Visible = true; ButtonAddPaymentType.Visible = false; CreditCardEditor1.BindPage(long.Parse((string)e.CommandArgument)); } }
public void BindPage(Int64 paymentProfileId) { DisableButtonOnClick(ButtonSave); ErrorMessage.Text = string.Empty; TextCardSecurity.Text = string.Empty; TextCreditCard.Text = string.Empty; AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current; int customerId = adnsfCustomer.CustomerID; PanelError.Visible = false; PopulateExpirationDates(); PopulateAddresses(customerId); this.PaymentProfileId = 0; // initially zero if (paymentProfileId <= 0) { return; } Int64 profileId = DataUtility.GetProfileId(customerId); if (profileId <= 0) { return; } var profileMgr = new ProfileManager(customerId, adnsfCustomer.EMail, profileId); var paymentProfile = profileMgr.GetPaymentProfile(paymentProfileId); if (paymentProfile == null) { return; } this.PaymentProfileId = paymentProfileId; var ccPayment = (GatewayAuthorizeNet.AuthorizeNetApi.CreditCardMaskedType)paymentProfile.payment.Item; var dataPaymentProfile = DataUtility.GetPaymentProfile(adnsfCustomer.CustomerID, this.PaymentProfileId); TextCreditCard.Text = ccPayment.cardNumber; TextCardSecurity.Text = string.Empty; ExpirationMonth.ClearSelection(); var foundItem = ExpirationMonth.Items.FindByValue(dataPaymentProfile.ExpirationMonth); if (foundItem != null) { foundItem.Selected = true; } ExpirationYear.ClearSelection(); foundItem = ExpirationYear.Items.FindByValue(dataPaymentProfile.ExpirationYear); if (foundItem != null) { foundItem.Selected = true; } var address = DataUtility.GetPaymentProfile(customerId, this.PaymentProfileId); if (address != null) { BillingAddresses.ClearSelection(); BillingAddresses.Items.FindByValue(address.AddressId.ToString()).Selected = true; } }
string AcceptJsProcessCardOrECheck( int customerId, decimal orderTotal, bool useLiveTransactions, TransactionModeEnum transactionMode, out string avsResult, out string authorizationResult, out string authorizationCode, out string authorizationTransId, out string transactionCommandOut, out string transactionResponse) { authorizationCode = string.Empty; authorizationResult = string.Empty; authorizationTransId = string.Empty; avsResult = string.Empty; transactionCommandOut = string.Empty; transactionResponse = string.Empty; orderTotal.ValidateNumberOfDigits(15); // Accept.js limit //We don't display the address form in the lightbox, so use the billing address the customer entered onsite var customer = new AspDotNetStorefrontCore.Customer(customerId); var acceptJsBillingAddress = new customerAddressType { firstName = customer.FirstName .ToAlphaNumeric() .Truncate(50), // Accept.js limit lastName = customer.LastName .ToAlphaNumeric() .Truncate(50), // Accept.js limit address = customer.PrimaryBillingAddress.Address1 .ToAlphaNumeric(). Truncate(60), // Accept.js limit city = customer.PrimaryBillingAddress.City .ToAlphaNumeric() .Truncate(40), // Accept.js limit state = customer.PrimaryBillingAddress.State .ToAlphaNumeric() .Truncate(40), // Accept.js limit, but really it's only ever going to be 2 characters zip = customer.PrimaryBillingAddress.Zip .ToAlphaNumeric() .Truncate(20) // Accept.js limit }; //Add line items to the order info var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); var lineItems = cart .CartItems .Take(30) // Accept.js only accepts 30 line items. Not very accepting of them. .Select(cartItem => new lineItemType { itemId = cartItem.ShoppingCartRecordID.ToString(), // Accept.js limit of 31 which we can't get with an int name = cartItem.ProductName.Truncate(31), // Accept.js limit quantity = cartItem.Quantity, // Accept.js limit of 4 decimal places which we can't get with an int unitPrice = Math.Round(cartItem.Price, 2) // Accept.js limit }) .ToArray(); //Add the customer's payment info from the Accept.js form var opaqueData = new opaqueDataType { dataDescriptor = customer.ThisCustomerSession[AppLogic.AcceptJsDataDescriptor], dataValue = customer.ThisCustomerSession[AppLogic.AcceptJsDataValue] }; var paymentType = new paymentType { Item = opaqueData }; var transactionRequest = new transactionRequestType { transactionType = transactionMode == TransactionModeEnum.auth ? transactionTypeEnum.authOnlyTransaction.ToString() : transactionTypeEnum.authCaptureTransaction.ToString(), amount = orderTotal, amountSpecified = true, payment = paymentType, billTo = acceptJsBillingAddress, lineItems = lineItems }; if (useLiveTransactions) { transactionRequest.solution = new solutionType { id = SolutionId } } ; var request = new createTransactionRequest { transactionRequest = transactionRequest, merchantAuthentication = GetMerchantAuthentication(useLiveTransactions) }; transactionCommandOut = JsonConvert.SerializeObject(request); var controller = new createTransactionController(request); controller.Execute( GetRunEnvironment(useLiveTransactions)); var response = controller.GetApiResponse(); if (response == null) { return("NO RESPONSE FROM GATEWAY!"); } transactionResponse = JsonConvert.SerializeObject(response); if (response.messages.resultCode != messageTypeEnum.Ok) { return(response.transactionResponse?.errors?[0].errorText ?? response.messages.message[0].text); } if (response.transactionResponse.messages == null) { return(response.transactionResponse.errors?[0].errorText ?? "Unspecified Error"); } authorizationCode = response.transactionResponse.authCode; authorizationResult = response.transactionResponse.messages[0].description; authorizationTransId = response.transactionResponse.transId; avsResult = response.transactionResponse.avsResultCode; return(AppLogic.ro_OK); }