Пример #1
0
    public string InsertIntoStanbicRecieved(PostTransactionRequest tran, string UtilityCode, string Status)
    {
        try
        {
            string Reason = "";
            if (string.IsNullOrEmpty(tran.PayLoad.Addendum))
            {
                tran.PayLoad.Addendum = "";
            }
            command = ThirdPartyDB.GetStoredProcCommand("InsertVasTransactionRecieved",
                                                        tran.PayLoad.MSISDN,
                                                        tran.PayLoad.BeneficiaryID,

                                                        tran.PayLoad.BeneficiaryName,
                                                        tran.PayLoad.Area,
                                                        tran.PayLoad.Amount,
                                                        tran.PayLoad.Currency,
                                                        tran.PayLoad.ReferenceID,
                                                        UtilityCode,
                                                        tran.PayLoad.Narration,
                                                        Status,
                                                        tran.PayLoad.MerchantID,
                                                        Reason,
                                                        tran.PayLoad.Addendum
                                                        );
            DataTable dt = ThirdPartyDB.ExecuteDataSet(command).Tables[0];
            return(dt.Rows[0][0].ToString());
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Пример #2
0
    public PostTransactionResponse PostTransaction(PostTransactionRequest requestData)
    {
        PostTransactionResponse resp = new PostTransactionResponse();

        try
        {
            //string UtilityCode = dh.GetServiceNameFromDB(requestData.Payload.MerchantID);
            string Id = dh.InsertIntoStanbicRecieved(requestData, requestData.PayLoad.UtilityCode, "PENDING");
            resp.Status               = new Status();
            resp.Status.StatusCode    = "100";
            resp.Status.Description   = "Successful request receipt";
            resp.PayLoad.C360UniqueID = Id;
            resp.PayLoad.Description  = "Request successfully logged";
            resp.PayLoad.ReferenceID  = requestData.PayLoad.ReferenceID;
            resp.PayLoad.StatusCode   = "113";
        }
        catch (Exception e)
        {
            resp.Status             = new Status();
            resp.Status.StatusCode  = "101";
            resp.Status.Description = "Technical error. Try and post again ";
            dh.LogError("Exception " + e.Message, "STANBIC_VAS", DateTime.Now, requestData.PayLoad.ReferenceID);
            //string path = @"E:\Logs\StanbicApiLogs\Errors\ErrorFile_" + DateTime.Today.ToString("yyyyddMM")+".txt";
            //string text = "\n";
            //if (File.Exists(path))
            //{
            //    text = File.ReadAllText(path);
            //}
            // File.WriteAllText(path, text+"\n"+e.Message);
            resp.PayLoad.StatusCode = "112";
        }
        return(resp);
    }
Пример #3
0
        public string RegisterClient(PostTransactionRequest req)
        {
            PostTransactionRequest requestData = new PostTransactionRequest();

            requestData.firstName   = req.firstName;
            requestData.lastName    = req.lastName;
            requestData.phoneNumber = req.phoneNumber;
            requestData.email       = req.email;
            try
            {
                bl.Serialize(requestData);
                return(bl.SaveClientToDatabase(requestData) > 0?"success":"insertion error");
            }
            catch (Exception e)
            {
                dh.LogError(DateTime.Now, e.Message, "");
                return("insertion error");
            }
        }
Пример #4
0
        public int InsertIntoClientTable(PostTransactionRequest tran)
        {
            int result = 0;

            try
            {
                command = ThirdPartyDB.GetStoredProcCommand("InsertIntoClientTable",

                                                            tran.firstName,
                                                            tran.lastName,
                                                            tran.phoneNumber,
                                                            tran.email

                                                            );
                return(ThirdPartyDB.ExecuteNonQuery(command));
            }
            catch (Exception ex)
            {
                LogError(DateTime.Now, ex.Message, "");
                return(result);
            }
        }
        public async Task <IActionResult> PosTransaction([FromRoute] Guid account_id, [FromBody] PostTransactionRequest request)
        {
            var response = await mediator.Send(new PublishTransaction(account_id, request.Value, request.Type));

            if (response.Invalid)
            {
                return(ValidationError(response));
            }

            return(Created("", PayloadResponse.Create()));
        }
Пример #6
0
    public PostTransactionResponse PostTransaction(PostTransactionRequest 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(requestData.PayLoad.ReferenceID, requestData.Credentials.Username, DateTime.Now, "POSTING", "", e.Message, "");
        }
        if (String.IsNullOrEmpty(strCert))
        {
            password = "";
        }
        else
        {
            password = strCert;
        }

        dh.SaveRequestlog(requestData.PayLoad.ReferenceID, requestData.Credentials.Username, requestData.PayLoad.Amount, password, "POSTING", DateTime.Now);

        PostTransactionResponse resp = new PostTransactionResponse();

        try
        {
            if (requestData.IsValidRequest())
            {
                resp = bll.PostTransaction(requestData);
            }
            else
            {
                resp.Status              = new Status();
                resp.Status.StatusCode   = "200";
                resp.Status.Description  = "Successful";
                resp.PayLoad.StatusCode  = requestData.PegPayStatusCode;
                resp.PayLoad.Description = requestData.PegPayStatusDescription;
            }
        }
        catch (Exception e)
        {
            requestData.PegPayStatusCode        = "101";
            requestData.PegPayStatusDescription = "GENERAL ERROR AT PEGASUS";
            resp.Status.StatusCode  = requestData.PegPayStatusCode;
            resp.Status.Description = requestData.PegPayStatusDescription;
        }
        return(resp);
    }
        public async Task <IActionResult> Post([FromBody] PostTransactionRequest request)
        {
            var response = await _mediator.Send(new CreateTransaction(request.From, request.To, request.Value));

            return(Response(response));
        }
Пример #8
0
 public Task <BaseApiResponse> PostTransactionAsync <T>(PostTransactionRequest <T> Request)
 => PostSimpleJsonAsync <BaseApiResponse, PostTransactionRequest <T> >(Request, Api.PeerPostTransactions);
Пример #9
0
 public BaseApiResponse PostTransaction <T>(PostTransactionRequest <T> Request)
 => PostTransactionAsync(Request).GetAwaiter().GetResult();