/// <summary> /// Processes the CC. /// </summary> /// <param name="ccNumber">The cc number.</param> /// <param name="ccExpDate">The cc exp date.</param> /// <param name="chargeAmount">The charge amount.</param> /// <param name="orderNumber">The order number.</param> /// <returns></returns> private string ProcessCC(string ccNumber, string ccExpDate, decimal chargeAmount, string orderNumber) { try { if (chargeAmount > 0) { var request = new AuthorizationRequest(ccNumber, ccExpDate, chargeAmount, "Bettery Charge"); // TODO: Add the following once the Membership Cache is in place. //request.AddCardCode("321"); //Customer info - this is used for Fraud Detection //request.AddCustomer("id", "first", "last", "address", "state", "zip"); //Custom values that will be returned with the response //request.AddMerchantValue("merchantValue", "value"); //Shipping Address //request.AddShipping("id", "first", "last", "address", "state", "zip"); //order number request.AddInvoice(orderNumber); // string apiLogin = Application.Current.Properties["apiLogin"].ToString(); string transactionKey = Application.Current.Properties["transactionKey"].ToString(); var gate = new Gateway(apiLogin, transactionKey, true); //step 3 - make some money var response = gate.Send(request); return(response.AuthorizationCode); } else { return(""); } } catch (Exception ex) { // TODO: Log Error message throw; } }
/// <summary> /// Processes the CC. /// </summary> /// <param name="ccNumber">The cc number.</param> /// <param name="ccExpDate">The cc exp date.</param> /// <param name="chargeAmount">The charge amount.</param> /// <param name="orderNumber">The order number.</param> /// <param name="zipCode">The zip code.</param> /// <returns></returns> private static string ProcessCC(string ccNumber, string ccExpDate, decimal chargeAmount, string orderNumber, string zipCode, string name) { try { if (chargeAmount > 0) { var request = new AuthorizationRequest(ccNumber, ccExpDate, chargeAmount, "Bettery Charge"); request.Zip = zipCode; // Store the Swap Station ID in the CustID field request.CustId = ConfigurationManager.AppSettings[Constants.SettingKeys.StationId]; // Add customer info if user is logged in. //if (BaseController.CurrentTransaction.Email != null || BaseController.CurrentTransaction.Email != String.Empty) // request.Email = BaseController.CurrentTransaction.Email; if (BaseController.LoggedOnUser != null) { request.AddCustomer(BaseController.LoggedOnUser.MemberId.ToString(), BaseController.LoggedOnUser.MemberFirstName, BaseController.LoggedOnUser.MemberLastName, "", "", BaseController.CurrentTransaction.ZipCode); } else { request.FirstName = name; request.Zip = BaseController.CurrentTransaction.ZipCode; } // Get Test Request setting from config file request.TestRequest = ConfigurationManager.AppSettings["TestTransaction"].ToString(); // Set Test Request true for admins if (BaseController.LoggedOnUser != null && (BaseController.LoggedOnUser.GroupID == Constants.Group.SuperUser || BaseController.LoggedOnUser.GroupID == Constants.Group.SwapStationAdmin || BaseController.LoggedOnUser.GroupID == Constants.Group.CompanyAccount)) { request.TestRequest = "TRUE"; } //order number request.AddInvoice(orderNumber); var gate = new CardPresentGateway(BaseController.ApiLogin, BaseController.TransactionKey, false); //step 3 - make some money var response = gate.Send(request); if (!response.Approved) { BaseController.CurrentTransaction.ZipCode = null; throw new KioskException(Constants.Messages.NonApprovedRequest); } BaseController.CurrentTransaction.TransactionID = response.TransactionID; return(response.AuthorizationCode); } else { return(""); } } catch (KioskException kioskException) { AlertController.AuthorizeDotNetAlert(kioskException); throw kioskException; } catch (Exception ex) { KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize); kioskException.OriginalException = ex; AlertController.AuthorizeDotNetAlert(ex); Logger.Log(EventLogEntryType.Error, "Could Not Connect to Authorize.NET or other Authorize.NET failure", BaseController.StationId); throw kioskException; } }