Beispiel #1
0
    private QueryRequest GetPegpayQueryObject(ValidateCustomerRequest tran, string utilityCode)
    {
        QueryRequest req = new QueryRequest();

        req.QueryField1 = tran.PayLoad.CustomerRef;
        if (utilityCode.ToUpper() == "DSTV" || utilityCode.ToUpper() == "GOTV")
        {
            req.QueryField2 = "";
        }
        else
        {
            req.QueryField2 = tran.PayLoad.Area;
        }
        req.QueryField4 = utilityCode;
        req.QueryField5 = "STANBIC_VAS";
        req.QueryField6 = "53P48KU262";
        if (utilityCode.ToUpper() == "FLEXIPAY")
        {
            req.QueryField4 = "STB_SCHOOL";
        }
        return(req);
    }
Beispiel #2
0
    public ValidateCustomerResponse QueryCustomerDetails(ValidateCustomerRequest requestData)
    {
        ValidateCustomerResponse queryResp = new ValidateCustomerResponse();

        try
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidation;

            //pick correct service name from db
            DataTable dt = dh.GetServiceDetailsFromDB(requestData.PayLoad.ServiceCode);

            if (dt.Rows.Count > 0)
            {
                DataRow dr              = dt.Rows[0];
                string  ServiceCode     = dr["ServiceCode"].ToString();
                string  ServiceName     = dr["ServiceName"].ToString();
                string  ServiceID       = dr["ServiceID"].ToString();
                string  requestCustType = "";

                if (ServiceCode.Equals("NWSC"))
                {
                    //read area from db
                    requestData.PayLoad.Area = ServiceName.Split(' ')[1];
                }
                else if (ServiceCode.Equals("UMEME"))
                {
                    requestCustType = ServiceName.Split(' ')[1].ToUpper();
                }
                //else if (ServiceCode == "FLEXIPAY-MERCHANT")
                //{
                //    return GetMerchantDetails(requestData, ServiceID);
                //}


                //generate level 1 query object
                QueryRequest levelOneQuery = GetPegpayQueryObject(requestData, ServiceCode);

                //query from level 1
                PegPay levelOneApi = new PegPay();
                ThirdPartyInterfaces.PegPay.Response levelOneResp = levelOneApi.QueryCustomerDetails(levelOneQuery);

                //return appropriate response
                if (levelOneResp.ResponseField6.Equals("0"))
                {
                    if (ServiceCode.Equals("UMEME"))
                    {
                        queryResp = ReturnUmemeResponse(levelOneResp, requestData, requestCustType);
                    }
                    else if (ServiceCode.Equals("FLEXIPAY"))
                    {
                        queryResp.Details.Status.StatusCode          = "";
                        queryResp.Details.Status.Description         = "";
                        queryResp.Details.Resultz.Area               = levelOneResp.ResponseField3;
                        queryResp.Details.Resultz.CustomerName       = levelOneResp.ResponseField2;
                        queryResp.Details.Resultz.CustomerReference  = levelOneResp.ResponseField1;
                        queryResp.Details.Resultz.CustomerType       = levelOneResp.ResponseField5;
                        queryResp.Details.Resultz.OutstandingBalance = levelOneResp.ResponseField4;
                        queryResp.Details.Resultz.Tin               = levelOneResp.ResponseField8;//requestData.PayLoad.Area;
                        queryResp.Details.Status.StatusCode         = "200";
                        queryResp.Details.Status.Description        = "Successful";
                        queryResp.Details.Resultz.StatusCode        = "0";
                        queryResp.Details.Resultz.StatusDescription = "SUCCESS";
                    }
                    else if (ServiceCode.Equals("URA"))
                    {
                        queryResp.Details.Status.StatusCode          = "";
                        queryResp.Details.Status.Description         = "";
                        queryResp.Details.Resultz.Area               = levelOneResp.ResponseField3;
                        queryResp.Details.Resultz.CustomerName       = levelOneResp.ResponseField2;
                        queryResp.Details.Resultz.CustomerReference  = levelOneResp.ResponseField1;
                        queryResp.Details.Resultz.CustomerType       = levelOneResp.ResponseField5;
                        queryResp.Details.Resultz.OutstandingBalance = levelOneResp.ResponseField4;
                        queryResp.Details.Resultz.Tin = levelOneResp.ResponseField3;
                        queryResp.Details.Resultz.RegistrationDate  = string.IsNullOrEmpty(levelOneResp.ResponseField8) ? "" : levelOneResp.ResponseField8;
                        queryResp.Details.Resultz.ExpiryDate        = string.IsNullOrEmpty(levelOneResp.ResponseField9) ? "" : levelOneResp.ResponseField9;
                        queryResp.Details.Status.StatusCode         = "200";
                        queryResp.Details.Status.Description        = "Successful";
                        queryResp.Details.Resultz.StatusCode        = "0";
                        queryResp.Details.Resultz.StatusDescription = "SUCCESS";
                    }
                    else if (ServiceCode.Equals("NSSF"))
                    {
                        queryResp.Details.Status.StatusCode          = "";
                        queryResp.Details.Status.Description         = "";
                        queryResp.Details.Resultz.Area               = levelOneResp.ResponseField10;
                        queryResp.Details.Resultz.CustomerName       = levelOneResp.ResponseField2;
                        queryResp.Details.Resultz.CustomerReference  = levelOneResp.ResponseField1;
                        queryResp.Details.Resultz.CustomerType       = levelOneResp.ResponseField5;
                        queryResp.Details.Resultz.OutstandingBalance = levelOneResp.ResponseField4;
                        queryResp.Details.Resultz.Tin = levelOneResp.ResponseField9;
                        queryResp.Details.Resultz.RegistrationDate  = "";
                        queryResp.Details.Resultz.ExpiryDate        = levelOneResp.ResponseField3;
                        queryResp.Details.Status.StatusCode         = "200";
                        queryResp.Details.Status.Description        = "Successful";
                        queryResp.Details.Resultz.StatusCode        = "0";
                        queryResp.Details.Resultz.StatusDescription = "SUCCESS";
                    }
                    else if (ServiceCode.Equals("DSTV") || ServiceCode.Equals("GOTV"))
                    {
                        queryResp = ReturnDSTVResponse(levelOneResp, requestData, ServiceCode);
                    }
                    else
                    {
                        queryResp.Details.Status.StatusCode          = "";
                        queryResp.Details.Status.Description         = "";
                        queryResp.Details.Resultz.Area               = levelOneResp.ResponseField3;
                        queryResp.Details.Resultz.CustomerName       = levelOneResp.ResponseField2;
                        queryResp.Details.Resultz.CustomerReference  = levelOneResp.ResponseField1;
                        queryResp.Details.Resultz.CustomerType       = levelOneResp.ResponseField5;
                        queryResp.Details.Resultz.OutstandingBalance = levelOneResp.ResponseField4;
                        queryResp.Details.Resultz.Tin               = levelOneResp.ResponseField3;
                        queryResp.Details.Status.StatusCode         = "200";
                        queryResp.Details.Status.Description        = "Successful";
                        queryResp.Details.Resultz.StatusCode        = "0";
                        queryResp.Details.Resultz.StatusDescription = "SUCCESS";
                    }
                }
                else
                {
                    if (ServiceCode.Equals("NSSF"))
                    {
                        if (levelOneResp.ResponseField7.ToUpper().Contains("EXPIRED"))
                        {
                            levelOneResp.ResponseField7 = "TRANSACTION NUMBER EXPIRED";
                        }
                        else if (levelOneResp.ResponseField7.ToUpper().Contains("DELETED"))
                        {
                            levelOneResp.ResponseField7 = "TRANSACTION NUMBER DELETED";
                        }
                        else if (levelOneResp.ResponseField7.ToUpper().Contains("EXISTS"))
                        {
                            levelOneResp.ResponseField7 = "NO TRANSACTION NUMBER";
                        }
                        else if (levelOneResp.ResponseField7.ToUpper().Contains("NUMBER PAID"))
                        {
                            levelOneResp.ResponseField7 = "TRANSACTION NUMBER ALREADY PAID";
                        }
                        queryResp.Details.Status.StatusCode         = "200";
                        queryResp.Details.Status.Description        = "Successful";
                        queryResp.Details.Resultz.StatusCode        = "100";
                        queryResp.Details.Resultz.StatusDescription = levelOneResp.ResponseField7;
                    }
                    else
                    {
                        queryResp.Details.Status.StatusCode         = "200";
                        queryResp.Details.Status.Description        = "Successful";
                        queryResp.Details.Resultz.StatusCode        = "100";
                        queryResp.Details.Resultz.StatusDescription = levelOneResp.ResponseField7;
                    }
                }
            }
            else
            {
                queryResp.Details.Status.StatusCode         = "200";
                queryResp.Details.Status.Description        = "Successful";
                queryResp.Details.Resultz.StatusCode        = "100";
                queryResp.Details.Resultz.StatusDescription = "INVALID MERCHANT ID";
            }

            return(queryResp);
        }
        catch (Exception e)
        {
            throw e;
        }
    }
Beispiel #3
0
    private ValidateCustomerResponse ReturnUmemeResponse(ThirdPartyInterfaces.PegPay.Response levelOneResp, ValidateCustomerRequest requestData, string requestCustType)
    {
        ValidateCustomerResponse queryResp = new ValidateCustomerResponse();

        //stanbic requested that for UMEME
        //we only return success if customer type returned matches
        //customer type in request
        if (levelOneResp.ResponseField5 == requestCustType)
        {
            queryResp.Details.Status.StatusCode          = "";
            queryResp.Details.Status.Description         = "";
            queryResp.Details.Resultz.Area               = levelOneResp.ResponseField3;
            queryResp.Details.Resultz.CustomerName       = levelOneResp.ResponseField2;
            queryResp.Details.Resultz.CustomerReference  = levelOneResp.ResponseField1;
            queryResp.Details.Resultz.CustomerType       = levelOneResp.ResponseField5;
            queryResp.Details.Resultz.OutstandingBalance = levelOneResp.ResponseField4;
            queryResp.Details.Resultz.Tin               = levelOneResp.ResponseField3;
            queryResp.Details.Status.StatusCode         = "200";
            queryResp.Details.Status.Description        = "Successful";
            queryResp.Details.Resultz.StatusCode        = "0";
            queryResp.Details.Resultz.StatusDescription = "SUCCESS";
        }
        else
        {
            queryResp.Details.Status.StatusCode         = "200";
            queryResp.Details.Status.Description        = "Successful";
            queryResp.Details.Resultz.StatusCode        = "100";
            queryResp.Details.Resultz.StatusDescription = "INVALID CUSTOMER REFERENCE";
        }
        return(queryResp);
    }
Beispiel #4
0
    public ValidateCustomerResponse ValidateCustomer(ValidateCustomerRequest requestData)
    {
        string strCert = null;

        //Hashing the password
        try
        {
            string text        = requestData.Credentials.Password;
            string certificate = @"E:\Certs\pegasus.pfx";

            X509Certificate2         cert = new X509Certificate2(certificate, "Tingate710", X509KeyStorageFlags.UserKeySet);
            RSACryptoServiceProvider rsa  = (RSACryptoServiceProvider)cert.PrivateKey;

            // Hash the data
            SHA1Managed   sha1     = new SHA1Managed();
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[]        data     = encoding.GetBytes(text);
            byte[]        hash     = sha1.ComputeHash(data);

            // Sign the hash
            byte[] digitalCert = rsa.SignHash(hash, CryptoConfig.MapNameToOID("SHA1"));
            strCert = Convert.ToBase64String(digitalCert);
        }
        catch (Exception e)
        {
            dh.LogErrorKCB("", "", DateTime.Now, "", "", e.Message, "");
        }
        if (String.IsNullOrEmpty(strCert))
        {
            password = "";
        }
        else
        {
            password = strCert;
        }


        dh.SaveRequestlog("", requestData.Credentials.Username, "", password, "VALIDATION", DateTime.Now);
        ValidateCustomerResponse resp = new ValidateCustomerResponse();

        try
        {
            if (requestData.IsValidRequest())
            {
                resp = bll.QueryCustomerDetails(requestData);
            }
            else
            {
                resp.Details.Status.StatusCode         = "200";
                resp.Details.Status.Description        = "Successful";
                resp.Details.Resultz.StatusCode        = requestData.PegPayStatusCode;
                resp.Details.Resultz.StatusDescription = requestData.PegPayStatusDescription;
            }
        }
        catch (Exception e)
        {
            requestData.PegPayStatusCode        = "200";
            requestData.PegPayStatusDescription = "Successful";
            resp.Details.Status.StatusCode      = "100";
            resp.Details.Status.Description     = "UNABLE TO VERIFY CUSTOMER REFERENCE AT THE MOMENT";
            //  dh.LogError("SendPendingTransactionsToUtility TranId: " + tran.VendorTranId + " : " + e.Message, tran.VendorCode, DateTime.Now, tran.UtilityCompany);
        }
        return(resp);
    }