示例#1
0
        public TransactionResponse PayWithCreditCard(int peopleId, decimal amt, string cardnumber, string expires, string description, int tranid, string cardcode, string email, string first, string last, string addr, string addr2, string city, string state, string country, string zip, string phone)
        {
            var request = new AuthorizationRequest(cardnumber, expires, amt, description, includeCapture: true);

            request.AddCustomer(peopleId.ToString(), email, first, last, addr, city, state, zip);
            request.Country    = country;
            request.CardCode   = cardcode;
            request.Phone      = phone;
            request.InvoiceNum = tranid.ToString();

            var response = Gateway.Send(request);

            return(new TransactionResponse
            {
                Approved = response.Approved,
                AuthCode = response.AuthorizationCode,
                Message = response.Message,
                TransactionId = response.TransactionID
            });
        }
示例#2
0
        public TransactionResponse AuthCreditCard(int peopleId, decimal amt, string cardnumber, string expires, string description,
                                                  int tranid, string cardcode, string email, string first, string last, string addr, string addr2, string city, string state,
                                                  string country, string zip, string phone)
        {
            var request = new AuthorizationRequest(cardnumber, expires, amt, description, includeCapture: false);

            request.AddCustomer(peopleId.ToString(), first, last, addr, state, zip);
            request.City       = city; // hopefully will be resolved with https://github.com/AuthorizeNet/sdk-dotnet/pull/41
            request.Country    = country;
            request.CardCode   = cardcode;
            request.Phone      = phone;
            request.Email      = email;
            request.InvoiceNum = tranid.ToString();

            var response = Gateway.Send(request);

            return(new TransactionResponse
            {
                Approved = response.Approved,
                AuthCode = response.AuthorizationCode,
                Message = response.Message,
                TransactionId = response.TransactionID
            });
        }
示例#3
0
        protected void butConfirm_Click(object sender, ImageClickEventArgs e)
        {
            JobWrapper jobWrapper = new JobWrapper();

            if (jobWrapper.JobDetailsObject != null)
            {
                string  monthAndYear = ddlExpirationMonth.SelectedValue + ddlExpirationYear.SelectedValue;
                decimal amount       = (decimal)jobWrapper.JobDetailsObject.JobTotalPrise;
                var     request      = new AuthorizationRequest(txtCardNumber.Text, monthAndYear, amount, "Test Transaction",
                                                                false);
                request.AddCustomer(null, txtFirstName.Text, txtLastName.Text, null, null, txtZipCode.Text);
                //request.AddCardCode(txtCardNumber.Text);
                //step 2 - create the gateway, sending in your credentials
                var login          = ConfigurationManager.AppSettings["ApiLogin"];
                var transactionKey = ConfigurationManager.AppSettings["TransactionKey"];
                var gate           = new Gateway(login, transactionKey, false);

                //step 3 - make some money
                var response = gate.Send(request);

                if (response.Approved)
                {
                    LimoEntitiesEntityFremwork limmoEntity = new LimoEntitiesEntityFremwork();
                    Company company =
                        limmoEntity.Companies.Where(xx => xx.CompanyID == jobWrapper.JobDetailsObject.CompanyID).ToList().
                        FirstOrDefault();
                    string tripConfirmationNumber = string.Empty;
                    if (company != null)
                    {
                        string apiId  = company.LimoAPIID;  //Your Api ID
                        string apiKey = company.LimoAPIKey; //Your Api Key
                        tripConfirmationNumber = AddJobtoCompanyLimoAnyWhere(apiId, apiKey, company);

                        string limoAPIId     = ConfigurationSettings.AppSettings["apiId"];  //Your Api ID
                        string LimoAPIapiKey = ConfigurationSettings.AppSettings["apiKey"]; //Your Api Key
                        if (company.LimoAPIID != limoAPIId && company.LimoAPIKey != LimoAPIapiKey)
                        {
                            AddJobtoCompanyLimoAnyWhere(limoAPIId, LimoAPIapiKey, company, tripConfirmationNumber);
                        }
                    }

                    //try
                    //{
                    //if (string.IsNullOrEmpty(tripConfirmationNumber))
                    //    tripConfirmationNumber =
                    Job job = SaveJobInDatabase(tripConfirmationNumber, "", "");
                    SendEmail(job);
                    //}
                    //catch (Exception)
                    //{
                    //}
                    divConfirmation.Visible = true;
                    divProblem.Visible      = false;
                }
                else
                {
                    divConfirmation.Visible = false;
                    divProblem.Visible      = true;
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
        /// <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;
            }
        }