Ejemplo n.º 1
0
        public static argtype TranslateToSfgRequest(CreditCardServiceRequest ahRequest)
        {
            EventLogger.LogEvent("ENTERING -> SFGWrapper.CreditCardTranslators.TranslateToSfgRequest()");
            argtype sfgRequest = new argtype();

            #region readonly properties
            sfgRequest.org = ahRequest.Org;
            sfgRequest.test_mode = ahRequest.TestMode ? "Y" : "N";
            sfgRequest.app_version = ahRequest.AppVersion;
            sfgRequest.program_id = ahRequest.ProgramId;
            sfgRequest.program_type_id = ahRequest.ProgramTypeId;
            #endregion
                        
            sfgRequest.cc_name = ahRequest.CreditCardData.CCName;
            sfgRequest.cc_number = ahRequest.CreditCardData.CCNumber;
            sfgRequest.cc_exp_mm = ahRequest.CreditCardData.CCExpMonth.ToString().PadLeft(2,'0');
            sfgRequest.cc_exp_yyyy = ahRequest.CreditCardData.CCExpYear.ToString().PadLeft(4,'0');
            sfgRequest.cc_amount = ahRequest.CreditCardData.AmountPaid;
            sfgRequest.cc_trans_type = ahRequest.CreditCardData.TransactionType;

            sfgRequest.cc_addr = ahRequest.CreditCardData.CCAddress;
            sfgRequest.cc_city = ahRequest.CreditCardData.CCCity;
            sfgRequest.cc_state = ahRequest.CreditCardData.CCState;
            sfgRequest.cc_zip = ahRequest.CreditCardData.CCPostalCode;
            sfgRequest.cc_country = ahRequest.CreditCardData.CCCountry;

            sfgRequest.business_name = ahRequest.MemberData.Address.BusinessName;
            sfgRequest.add1 = ahRequest.MemberData.Address.Address1;
            sfgRequest.add2 = ahRequest.MemberData.Address.Address2;
            sfgRequest.add3 = ahRequest.MemberData.Address.Address3;
            sfgRequest.city = ahRequest.MemberData.Address.City;
            sfgRequest.st = ahRequest.MemberData.Address.State;
            sfgRequest.zip = ahRequest.MemberData.Address.PostalCode;
            sfgRequest.phone = ahRequest.MemberData.Address.Phone;
            sfgRequest.fax = ahRequest.MemberData.Address.Fax;
            sfgRequest.altcity = ahRequest.MemberData.Address.AltCity;
            sfgRequest.country = ahRequest.MemberData.Address.Country;
            sfgRequest.title = ahRequest.MemberData.Salutation;
            sfgRequest.first = ahRequest.MemberData.FirstName;
            sfgRequest.mi = ahRequest.MemberData.MiddleInitial;
            sfgRequest.last = ahRequest.MemberData.LastName;
            sfgRequest.suffix = ahRequest.MemberData.Suffix;
            sfgRequest.professional_title = ahRequest.MemberData.ProfessionalTitle;
            sfgRequest.email = ahRequest.MemberData.Email;
            sfgRequest.optin = ahRequest.MemberData.OptIn ? "Y" : "N";

            sfgRequest.refresh_customer = "N";

            EventLogger.LogEvent("LEAVING -> SFGWrapper.CreditCardTranslators.TranslateToSfgRequest()");
            return sfgRequest;
        }
Ejemplo n.º 2
0
 public static BaseResponse GetResponse(CreditCardServiceRequest ahRequest)
 {
     string className = "SFGWrapper.CreditCardProcessing";
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         using (CCProcessorService svc = new CCProcessorService())
         {
             svc.Timeout = 20000;
             svc.Credentials = new System.Net.NetworkCredential(ahRequest.ServiceUsername, ahRequest.ServicePassword);
             argtype sfgRequest = CreditCardTranslators.TranslateToSfgRequest(ahRequest);
             baseResponse = CreditCardTranslators.GetResponse(svc.process_wsdl(sfgRequest));
         }
         if (baseResponse == null)
         {
             baseResponse = new BaseResponse();
             FatalErrorResponse fatalError = new FatalErrorResponse();
             baseResponse.TypedResponse = fatalError;
             baseResponse.Messages.Add(new Message("SFGFatalError"));
         }
         
     }
     catch (Exception ex)
     {
         baseResponse = new BaseResponse();
         FatalErrorResponse fatalError = new FatalErrorResponse();
         baseResponse.TypedResponse = fatalError;
         Message error = new Message("UnknownException");
         baseResponse.DebugStringLog.Add(ex.TargetSite.Name);
         baseResponse.DebugStringLog.Add(ex.Message);
         baseResponse.DebugStringLog.Add(ex.StackTrace);
         baseResponse.Messages.Add(error);
         EventLogger.LogError(string.Format("{0}()", new object[] { className }),
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;
 }
Ejemplo n.º 3
0
        //string optin,string fax,string altcity,
        private object[] ChargeCard(string memberid, string salutation, string firstname, string middleinitial, string lastname, string suffix,
            string professionaltitle, string email, string businessname, string address1, string address2, string address3,
            string city, string state, string postalcode, string country,
            string phone,  
            string ccnumber, string expmonth, string expyear, string amount,
            string ccname, string ccaddr, string cccity,
            string ccstate, string cczip, string cccountry, string pubcode, string username, string password, string refreshcustomer)
        {
            int response_code = 0;
            string routing_id = string.Empty;
            string auth_code = string.Empty;

            #region convert string input to correct types
            bool b_optin = false;
            short s_expmonth = 0;
            short s_expyear = 0;
            float f_amount = 0.0f;
            bool b_refreshcustomer = false;

            /*if (!bool.TryParse(optin, out b_optin))
            {
                response_code = 301;
            }*/
            if (!short.TryParse(expmonth, out s_expmonth))
            {
                response_code = 302;
            }
            if (!short.TryParse(expyear, out s_expyear))
            {
                response_code = 303;
            }
            if (!float.TryParse(amount, out f_amount))
            {
                response_code = 304;
            }
            if (!bool.TryParse(refreshcustomer, out b_refreshcustomer))
            {
                response_code = 305;
            }
            #endregion
            
            if(response_code == 0)
            {
                #region validate input
                Member memberData = new Member();
                memberData.MemberId = memberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.MiddleInitial = middleinitial;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                //memberData.OptIn = b_optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                //memberData.Address.Fax = fax;
                //memberData.Address.AltCity = altcity;

                CreditCard ccData = new CreditCard();
                ccData.CCNumber = ccnumber;
                ccData.CCExpMonth = s_expmonth;
                ccData.CCExpYear = s_expyear;
                ccData.AmountPaid = f_amount;
                ccData.CCName = ccname;
                ccData.CCAddress = ccaddr;
                ccData.CCCity = cccity;
                ccData.CCState = ccstate;
                ccData.CCPostalCode = cczip;
                ccData.CCCountry = cccountry;
                #endregion

                CreditCardServiceRequest request = new CreditCardServiceRequest(ccData, memberData, pubcode, username, password, b_refreshcustomer);
                BaseResponse cc_response = CreditCardProcessing.GetResponse(request);

                if (cc_response == null || cc_response.TypedResponse == null || cc_response.TypedResponse.Success == false)
                {
                    string msgs = string.Empty;
                    foreach (Message s in cc_response.Messages)
                    {
                        msgs += "[" + s.ToString() + "]";
                    }
                    tbl_AppEventLog logmsg = new tbl_AppEventLog();
                    logmsg.aelAppName = "HarperSERVICE";
                    logmsg.aelDateCreated = DateTime.Now;
                    logmsg.aelEvent = "306";
                    logmsg.aelMessage1 = "cc_response messages:" + msgs;
                    logmsg.aelMessage2 = "typed response:" + cc_response.TypedResponse.ToString();
                    logmsg.aelMessage3 = "success:" + cc_response.TypedResponse.Success;
                    logmsg.Save();
                    response_code = 306;
                }
                else
                {
                    routing_id = ((CreditCardServiceResponse)cc_response.TypedResponse).VerifoneRoutingId;
                    auth_code = ((CreditCardServiceResponse)cc_response.TypedResponse).AuthorizationCode;
                }
            }

            return new object[]{response_code, routing_id, auth_code};
        }