public AccountEnquiryResponseData getAccountEnquiry(AccountEnquiryPayload accountEnquiryPayload, Credentials credentials) { AccountEnquiryResponseData altResult = new AccountEnquiryResponseData(); if (!Config.isCredentialAvailable(credentials)) { altResult.data = new AccountEnquiryDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseDescription = Config.emptyCredentialResponse; altResult.data.responseCode = Config.emptyCredentialResponseCode; return(altResult); } else { try { EnvironmentConfig environmentConfig = new EnvironmentConfig(); Dictionary <string, string> getHashValues = environmentConfig.getRitsEnvironment(credentials); Dictionary <string, int> getEnvTimeOut = environmentConfig.getTimeOut(credentials); EncryptionUtil enUtil = new EncryptionUtil(); string url = getHashValues["ACCOUNT_ENQUIRY_URL"]; long milliseconds = DateTime.Now.Ticks; string requestId = accountEnquiryPayload.RequestId; string hash_string = getHashValues["API_KEY"] + requestId + getHashValues["API_TOKEN"]; string hashed = Config.SHA512(hash_string); var accountNo = accountEnquiryPayload.AccountNo; var bankCode = accountEnquiryPayload.BankCode; //HEADERS List <Header> headers = new List <Header>(); headers.Add(new Header { header = "Content-Type", value = "application/json" }); headers.Add(new Header { header = "API_DETAILS_HASH", value = hashed }); headers.Add(new Header { header = "REQUEST_TS", value = Config.getTimeStamp() }); headers.Add(new Header { header = "REQUEST_ID", value = requestId }); headers.Add(new Header { header = "API_KEY", value = getHashValues["API_KEY"] }); headers.Add(new Header { header = "MERCHANT_ID", value = getHashValues["MERCHANT_ID"] }); var body = new { accountNo = enUtil.Encrypt(accountNo, getHashValues["KEY"], getHashValues["IV"]), bankCode = enUtil.Encrypt(bankCode, getHashValues["KEY"], getHashValues["IV"]) }; try { var response = WebClientUtil.PostResponse(url, JsonConvert.SerializeObject(body), headers); result = JsonConvert.DeserializeObject <AccountEnquiryResponseData>(response); } catch (Exception e1) { altResult.data = new AccountEnquiryDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_WHILE_CONNECTING_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_WHILE_CONNECTING; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_WHILE_CONNECTING); return(altResult); } } catch (Exception e2) { altResult.data = new AccountEnquiryDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_PROCESSING_REQUEST_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_PROCESSING_REQUEST; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_PROCESSING_REQUEST); return(altResult); } return(result); } }
public BankListResponseData getListOfActiveBanks(GetActiveBankPayload getActiveBankPayload, Credentials credentials) { BankListResponseData altResult = new BankListResponseData(); if (!Config.isCredentialAvailable(credentials)) { altResult.data = new BankDataDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseDescription = Config.emptyCredentialResponse; altResult.data.responseCode = Config.emptyCredentialResponseCode; return(altResult); } else { try { EnvironmentConfig environmentConfig = new EnvironmentConfig(); Dictionary <string, string> getHashValues = environmentConfig.getRitsEnvironment(credentials); Dictionary <string, int> getEnvTimeOut = environmentConfig.getTimeOut(credentials); EncryptionUtil enUtil = new EncryptionUtil(); string url = getHashValues["GET_BANK_LIST_URL"]; string requestId = getActiveBankPayload.RequestId; string hash_string = getHashValues["API_KEY"] + requestId + getHashValues["API_TOKEN"]; string hashed = Config.SHA512(hash_string); //HEADERS List <Header> headers = new List <Header>(); headers.Add(new Header { header = "Content-Type", value = "application/json" }); headers.Add(new Header { header = "API_DETAILS_HASH", value = hashed }); headers.Add(new Header { header = "REQUEST_TS", value = Config.getTimeStamp() }); headers.Add(new Header { header = "REQUEST_ID", value = requestId }); headers.Add(new Header { header = "API_KEY", value = getHashValues["API_KEY"] }); headers.Add(new Header { header = "MERCHANT_ID", value = getHashValues["MERCHANT_ID"] }); try { var response = WebClientUtil.PostResponse(url, "", headers); result = JsonConvert.DeserializeObject <BankListResponseData>(response); } catch (Exception e1) { e1.ToString(); altResult.data = new BankDataDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_WHILE_CONNECTING_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_WHILE_CONNECTING; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_WHILE_CONNECTING); return(altResult); } } catch (Exception e2) { e2.ToString(); altResult.data = new BankDataDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_PROCESSING_REQUEST_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_PROCESSING_REQUEST; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_PROCESSING_REQUEST); return(altResult); } return(result); } }
public ValidateAccountOtpResponseData validateAccountOtp(ValidateAccountOtpPayload validateAccountOtpPayload, Credentials credentials) { ValidateAccountOtpResponseData altResult = new ValidateAccountOtpResponseData(); if (!Config.isCredentialAvailable(credentials)) { altResult.data = new ValidateAccountOtpDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseDescription = Config.emptyCredentialResponse; altResult.data.responseCode = Config.emptyCredentialResponseCode; return(altResult); } else { try { EnvironmentConfig environmentConfig = new EnvironmentConfig(); Dictionary <string, string> getHashValues = environmentConfig.getRitsEnvironment(credentials); Dictionary <string, int> getEnvTimeOut = environmentConfig.getTimeOut(credentials); EncryptionUtil enUtil = new EncryptionUtil(); string url = getHashValues["VALIDATE_ACC_OTP__URL"]; long milliseconds = DateTime.Now.Ticks; string requestId = validateAccountOtpPayload.RequestId; string hash_string = getHashValues["API_KEY"] + requestId + getHashValues["API_TOKEN"]; string hashed = Config.SHA512(hash_string); var transRef = requestId; //HEADERS List <Header> headers = new List <Header>(); headers.Add(new Header { header = "Content-Type", value = "application/json" }); headers.Add(new Header { header = "API_DETAILS_HASH", value = hashed }); headers.Add(new Header { header = "REQUEST_TS", value = Config.getTimeStamp() }); headers.Add(new Header { header = "REQUEST_ID", value = requestId }); headers.Add(new Header { header = "API_KEY", value = getHashValues["API_KEY"] }); headers.Add(new Header { header = "MERCHANT_ID", value = getHashValues["MERCHANT_ID"] }); Dictionary <string, string> mpOtp = new Dictionary <string, string>(); Dictionary <string, string> mpCard = new Dictionary <string, string>(); var remitaTransRef = validateAccountOtpPayload.RemitaTransRef; var authParams = validateAccountOtpPayload._authParams; mpOtp.Add("param1", "OTP"); mpOtp.Add("value", enUtil.Encrypt(validateAccountOtpPayload.Otp, getHashValues["KEY"], getHashValues["IV"])); mpCard.Add("param2", "OTP"); mpCard.Add("value", enUtil.Encrypt(validateAccountOtpPayload.Card, getHashValues["KEY"], getHashValues["IV"])); List <Dictionary <string, string> > getAuth = new List <Dictionary <string, string> >(); getAuth.Add(mpOtp); getAuth.Add(mpCard); var body = new { remitaTransRef = enUtil.Encrypt(remitaTransRef, getHashValues["KEY"], getHashValues["IV"]), authParams = getAuth }; try { var response = WebClientUtil.PostResponse(url, JsonConvert.SerializeObject(body), headers); result = JsonConvert.DeserializeObject <ValidateAccountOtpResponseData>(response); } catch (Exception e1) { altResult.data = new ValidateAccountOtpDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_WHILE_CONNECTING_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_WHILE_CONNECTING; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_WHILE_CONNECTING); return(altResult); } } catch (Exception e2) { altResult.data = new ValidateAccountOtpDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_PROCESSING_REQUEST_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_PROCESSING_REQUEST; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_PROCESSING_REQUEST); return(altResult); } return(result); } }
public SingleResponseData makeSinglePayment(SinglePaymentPayload singlePaymentPayload, Credentials credentials) { SingleResponseData altResult = new SingleResponseData(); if (!Config.isCredentialAvailable(credentials)) { altResult.data = new SinglePaymentDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseDescription = Config.emptyCredentialResponse; altResult.data.responseCode = Config.emptyCredentialResponseCode; return(altResult); } else { try { EnvironmentConfig environmentConfig = new EnvironmentConfig(); Dictionary <string, string> getHashValues = environmentConfig.getRitsEnvironment(credentials); Dictionary <string, int> getEnvTimeOut = environmentConfig.getTimeOut(credentials); EncryptionUtil enUtil = new EncryptionUtil(); string url = getHashValues["SINGLE_PAYMENT_URL"]; long milliseconds = DateTime.Now.Ticks; string requestId = singlePaymentPayload.RequestId; string hash_string = getHashValues["API_KEY"] + requestId + getHashValues["API_TOKEN"]; string hashed = Config.SHA512(hash_string); var fromBank = singlePaymentPayload.FromBank; var debitAccount = singlePaymentPayload.DebitAccount; var toBank = singlePaymentPayload.ToBank; var creditAccount = singlePaymentPayload.CreditAccount; var narration = singlePaymentPayload.Narration; var amount = singlePaymentPayload.Amount; var beneficiaryEmail = "*****@*****.**"; var transRef = singlePaymentPayload.TransRef; //HEADERS List <Header> headers = new List <Header>(); headers.Add(new Header { header = "Content-Type", value = "application/json" }); headers.Add(new Header { header = "API_DETAILS_HASH", value = hashed }); headers.Add(new Header { header = "REQUEST_TS", value = Config.getTimeStamp() }); headers.Add(new Header { header = "REQUEST_ID", value = requestId }); headers.Add(new Header { header = "API_KEY", value = getHashValues["API_KEY"] }); headers.Add(new Header { header = "MERCHANT_ID", value = getHashValues["MERCHANT_ID"] }); var body = new { toBank = enUtil.Encrypt(toBank, getHashValues["KEY"], getHashValues["IV"]), creditAccount = enUtil.Encrypt(creditAccount, getHashValues["KEY"], getHashValues["IV"]), narration = enUtil.Encrypt(narration, getHashValues["KEY"], getHashValues["IV"]), amount = enUtil.Encrypt(amount.ToString(), getHashValues["KEY"], getHashValues["IV"]), transRef = enUtil.Encrypt(transRef, getHashValues["KEY"], getHashValues["IV"]), fromBank = enUtil.Encrypt(fromBank, getHashValues["KEY"], getHashValues["IV"]), debitAccount = enUtil.Encrypt(debitAccount, getHashValues["KEY"], getHashValues["IV"]), beneficiaryEmail = enUtil.Encrypt(beneficiaryEmail, getHashValues["KEY"], getHashValues["IV"]) }; try { var response = WebClientUtil.PostResponse(url, JsonConvert.SerializeObject(body), headers); result = JsonConvert.DeserializeObject <SingleResponseData>(response); } catch (Exception e1) { altResult.data = new SinglePaymentDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_WHILE_CONNECTING_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_WHILE_CONNECTING; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_WHILE_CONNECTING); return(altResult); } } catch (Exception e2) { altResult.data = new SinglePaymentDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_PROCESSING_REQUEST_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_PROCESSING_REQUEST; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_PROCESSING_REQUEST); return(altResult); } return(result); } }
public BulkPaymentResponseData makeBulkPayment(BulkPaymentPayload bulkPaymentPayload, Credentials credentials) { BulkPaymentResponseData altResult = new BulkPaymentResponseData(); if (!Config.isCredentialAvailable(credentials)) { altResult.data = new BulkPaymentDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseDescription = Config.emptyCredentialResponse; altResult.data.responseCode = Config.emptyCredentialResponseCode; return(altResult); } else { try { EnvironmentConfig environmentConfig = new EnvironmentConfig(); Dictionary <string, string> getHashValues = environmentConfig.getRitsEnvironment(credentials); Dictionary <string, int> getEnvTimeOut = environmentConfig.getTimeOut(credentials); EncryptionUtil enUtil = new EncryptionUtil(); string url = getHashValues["BULK_PAYMENT_URL"]; long milliseconds = DateTime.Now.Ticks; Dictionary <string, Object> paymentData = new Dictionary <string, Object>(); List <PaymentDetails> paymentDetailListFrmBulkPayload = bulkPaymentPayload.paymentDetails; List <EncryptPaymentDetails> encryptPaymentListFrmBulkPayloadList = new List <EncryptPaymentDetails>(); double sumPaymentDetailAmount = 0; EncryptPaymentDetails encryptPaymentListFrmBulkPayload = null; foreach (PaymentDetails pDetails in paymentDetailListFrmBulkPayload) { encryptPaymentListFrmBulkPayload = new EncryptPaymentDetails(); encryptPaymentListFrmBulkPayload.transRef = enUtil.Encrypt(pDetails.transRef, getHashValues["KEY"], getHashValues["IV"]); encryptPaymentListFrmBulkPayload.narration = enUtil.Encrypt(pDetails.narration, getHashValues["KEY"], getHashValues["IV"]); encryptPaymentListFrmBulkPayload.benficiaryEmail = enUtil.Encrypt(pDetails.benficiaryEmail, getHashValues["KEY"], getHashValues["IV"]); encryptPaymentListFrmBulkPayload.benficiaryBankCode = enUtil.Encrypt(pDetails.benficiaryBankCode, getHashValues["KEY"], getHashValues["IV"]); encryptPaymentListFrmBulkPayload.benficiaryAccountNumber = enUtil.Encrypt(pDetails.benficiaryAccountNumber, getHashValues["KEY"], getHashValues["IV"]); encryptPaymentListFrmBulkPayload.amount = enUtil.Encrypt(pDetails.amount.ToString(), getHashValues["KEY"], getHashValues["IV"]); sumPaymentDetailAmount += pDetails.amount; encryptPaymentListFrmBulkPayloadList.Add(encryptPaymentListFrmBulkPayload); } BulkPaymentInfo bulkPaymentInfoFrmBulkPaymentPayload = bulkPaymentPayload.bulkPaymentInfo; var batchRef = enUtil.Encrypt(bulkPaymentInfoFrmBulkPaymentPayload.batchRef, getHashValues["KEY"], getHashValues["IV"]); var debitAccount = enUtil.Encrypt(bulkPaymentInfoFrmBulkPaymentPayload.debitAccount, getHashValues["KEY"], getHashValues["IV"]); var narration = enUtil.Encrypt(bulkPaymentInfoFrmBulkPaymentPayload.narration, getHashValues["KEY"], getHashValues["IV"]); var bankCode = enUtil.Encrypt(bulkPaymentInfoFrmBulkPaymentPayload.bankCode, getHashValues["KEY"], getHashValues["IV"]); var totalAmount = enUtil.Encrypt(sumPaymentDetailAmount.ToString(), getHashValues["KEY"], getHashValues["IV"]); EncryptBulkPaymentInfo encryptedBulkPaymentInfoFrmBulkPaymentPayload = new EncryptBulkPaymentInfo(); encryptedBulkPaymentInfoFrmBulkPaymentPayload.batchRef = batchRef; encryptedBulkPaymentInfoFrmBulkPaymentPayload.debitAccount = debitAccount; encryptedBulkPaymentInfoFrmBulkPaymentPayload.narration = narration; encryptedBulkPaymentInfoFrmBulkPaymentPayload.bankCode = bankCode; encryptedBulkPaymentInfoFrmBulkPaymentPayload.totalAmount = totalAmount; string requestId = bulkPaymentInfoFrmBulkPaymentPayload.requestId; string hash_string = getHashValues["API_KEY"] + requestId + getHashValues["API_TOKEN"]; string hashed = Config.SHA512(hash_string); //HEADERS List <Header> headers = new List <Header>(); headers.Add(new Header { header = "Content-Type", value = "application/json" }); headers.Add(new Header { header = "API_DETAILS_HASH", value = hashed }); headers.Add(new Header { header = "REQUEST_TS", value = Config.getTimeStamp() }); headers.Add(new Header { header = "REQUEST_ID", value = requestId }); headers.Add(new Header { header = "API_KEY", value = getHashValues["API_KEY"] }); headers.Add(new Header { header = "MERCHANT_ID", value = getHashValues["MERCHANT_ID"] }); var body = new { bulkPaymentInfo = encryptedBulkPaymentInfoFrmBulkPaymentPayload, paymentDetails = encryptPaymentListFrmBulkPayloadList }; try { var response = WebClientUtil.PostResponse(url, JsonConvert.SerializeObject(body), headers); result = JsonConvert.DeserializeObject <BulkPaymentResponseData>(response); } catch (Exception e1) { altResult.data = new BulkPaymentDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_WHILE_CONNECTING_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_WHILE_CONNECTING; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_WHILE_CONNECTING); return(altResult); } } catch (Exception e2) { altResult.data = new BulkPaymentDto(); altResult.status = SdkResponseCode.CredentialStatus; altResult.data.responseCode = SdkResponseCode.ERROR_PROCESSING_REQUEST_CODE; altResult.data.responseDescription = SdkResponseCode.ERROR_PROCESSING_REQUEST; Console.WriteLine("ERROR : {0} ", SdkResponseCode.ERROR_PROCESSING_REQUEST); return(altResult); } return(result); } }