Beispiel #1
0
    public string postForexPurchaseSummaryToNibss(string bvnBeneficiary, string bvnApplicant, string bvnApplicantAccount, int transactionType, string purpose, double amount, double rate, string requestDate, string requestId, string passportNumber)
    {
        RestServiceInvocator restServiceObj = new RestServiceInvocator();


        string reqId = utility.generateRequestId();

        //PurchaseInfoRecord transObj = SetARecord(bvnBeneficiary, bvnApplicant, bvnApplicantAccount, transactionType, purpose, amount, rate, requestDate, requestId, passportNumber);

        PurchaseInfoRecord transObj = SetARecord(bvnBeneficiary, bvnApplicant, bvnApplicantAccount, transactionType, purpose, amount, rate, requestDate, reqId, passportNumber);

        string response = restServiceObj.SendPurchaseInfoSummaryToNibss(transObj);

        return(response);
    }
Beispiel #2
0
    private static PurchaseInfoRecord SetARecord(string bvnBeneficiary, string bvnApplicant, string bvnApplicantAccount, int transactionType, string purpose, double amount, double rate, string requestDate, string requestId, string passportNumber)
    {
        try
        {
            //confirm the bvn at this point by calling the bvn validation service
            //if valid concatenate the date of birth|surname|firstname|middlename
            //else return a null object

            //DataSet bvnResponse =  Bank.GetBVN(thebvn);


            PurchaseInfoRecord transObj = new PurchaseInfoRecord()
            {
                bvnBeneficiary = bvnBeneficiary,

                bvnApplicant = bvnApplicant,

                bvnApplicantAccount = bvnApplicantAccount,

                transactionType = transactionType,

                purpose = purpose,

                amount = amount,

                rate = rate,

                requestDate = requestDate,

                requestID = requestId,

                passportNumber = passportNumber
            };



            return(transObj);
        }
        catch (Exception ex)
        {
            new ErrorLog(ex.ToString());
            return(null);
        }
    }
Beispiel #3
0
        public string SendPurchaseInfoSummaryToNibss(PurchaseInfoRecord transObj)
        {
            string nibbsurl = ConfigurationManager.AppSettings["nibbsurlforpurchaseinfo"]; //"http://192.234.10.104:86/icadservice/api/accountmanager"; //pick this from config manager instead incase IP later changes, there will then be no need to recompile the sourcecode
            string username = ConfigurationManager.AppSettings["username"];                //"*****@*****.**"; //pick from config manager
            string pswd     = ConfigurationManager.AppSettings["password"];                //"KLKG+!xooYqlKi@!";

            string authorization = Gizmo.Base64Encode(username + ":" + pswd);



            string signatureDate = DateTime.Now.ToString("yyyyMMdd");


            string signatureString = username + signatureDate + pswd;

            string signature = Gizmo.GenerateSHA512String(signatureString);


            RestClient client = new RestClient(nibbsurl);

            ByPassProxy(client);

            string nipcodeforsterling = ConfigurationManager.AppSettings["nipcodeforsterling"];



            var request = new RestRequest(Method.POST);

            string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            request.AddHeader("Accept", "text/plain");
            request.AddHeader("Content-Type", "text/plain");
            request.AddHeader("ContentType", "text/plain");
            request.AddHeader("InstitutionCode", nipcodeforsterling);
            request.AddHeader("Authorization", authorization);
            request.AddHeader("SIGNATURE", signature);
            request.AddHeader("SIGNATURE_METH", "SHA512");
            request.AddHeader("TIMESTAMP", timestamp);



            String key = ConfigurationManager.AppSettings["AESKey"]; //"OUGW5XNSc/82rXAr";
            String iv  = ConfigurationManager.AppSettings["IVKey"];  // "1BNEMKUJXi3svqFk";



            var json = new JavaScriptSerializer().Serialize(transObj);



            String encryptedRequest = AES.Encrypt(json.ToString(), key, iv);


            var requestBody = request.AddParameter("text/plain", encryptedRequest, ParameterType.RequestBody);



            String decryptedText = AES.Decrypt(encryptedRequest, key, iv);



            var response = client.Execute(request);


            // String decryptedText = AES.Decrypt(encryptedText, key, iv);
            //Console.WriteLine("Decrypted text :" + decryptedText);



            string realResponseCode    = "";
            string realResponseContent = "";

            //return bvnvalidationResponse;

            try
            {
                realResponseCode    = Convert.ToString(response.Headers.Where(x => x.Name == "error").SingleOrDefault().Value);
                realResponseContent = Convert.ToString(response.Headers.Where(x => x.Name == "responseInfo").SingleOrDefault().Value) + "-" + Convert.ToString(response.Headers.Where(x => x.Name == "respData").SingleOrDefault().Value);

                if (realResponseCode != "00")
                {
                    realResponseContent = Convert.ToString(response.Headers.Where(x => x.Name == "responseInfo").SingleOrDefault().Value);
                }
            }
            catch
            {
                realResponseCode    = "-1";
                realResponseContent = "Error Receiving response from nibss service";
            }

            //when bvn is down
            //StatusCode NoCOntent


            return(realResponseCode + "|" + realResponseContent);
        }