public IActionResult ValidateOTPLogin([FromBody] OTPValidatorRequest request)
        {
            if (!request.ValidateObject())
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.General_Error, (int)GeneralError.Nullable_Request, Constants.Constants.GeneralErrorDic[GeneralError.Nullable_Request]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            OTPValidatorResponse response   = new OTPValidatorResponse();
            AccountRep           accountRep = new AccountRep(Context);
            Account CurrentAccount          = accountRep.GetByMSDIN(request.BasicInfo.MobileNumberInfo.Number);

            if (CurrentAccount == null)
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Wallet_Number, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Wallet_Number]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            OTPRep oTPRep = new OTPRep(Context);
            bool   access = oTPRep.ValidateOTP(request.Otp, CurrentAccount.LastOtpid);

            if (access == true)
            {
                response.Status         = 1;
                response.CurrentBalance = (double)CurrentAccount.Balance;
                response.AdditionalInfo = "Login successfully with otp " + request.Otp + "\n"
                                          + "Basic Info: " + request.BasicInfo.ToString();
            }
            else
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Otp, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Otp]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            return(Ok(response));
        }
Exemple #2
0
        public IActionResult CheckTransactionStatus([FromBody] CheckStatusRequest request)
        {
            if (!request.ValidateObject())
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.General_Error, (int)GeneralError.Nullable_Request, Constants.Constants.GeneralErrorDic[GeneralError.Nullable_Request]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            ConfirmPaymentResponse response       = new ConfirmPaymentResponse();
            TransactionRep         transactionRep = new TransactionRep(Context);
            AccountRep             accountRep     = new AccountRep(Context);
            Account     account     = accountRep.GetByMSDIN(request.BasicInfo.MobileNumberInfo.Number);
            Transaction transaction = transactionRep.GetByTransactionID(request.TransactionId);

            //Question
            try
            {
                if (account != null)
                {
                    if (transaction != null)
                    {
                        response.TransactionStatus  = 1;
                        response.AdditionalInfo     = "string information" + "\n" + "Basic Info:" + request.BasicInfo.ToString();
                        response.TransactionId      = transaction.TransactionId;
                        response.CurrentBalance     = (double)account.Balance;
                        response.CompletionDateTime = transaction.IssueTime.ToString(Constants.Constants.DateTimeFormat);
                        response.TotalAmount        = (double)transaction.Amount;
                        response.CurrencyCode       = transaction.CurrencyCode;
                    }
                    else
                    {
                        ExceptionHandeling.FireError((int)ErrorCode.Payment_Error, (int)PaymentError.Transaction_Id_Not_Exist, Constants.Constants.PaymentErrorDic[PaymentError.Transaction_Id_Not_Exist]);
                    }
                }
                else
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Wallet_Number, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Wallet_Number]);
                }
            }
            catch (CodeLabException codelabExp)
            {
                return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
            }
            return(Ok(response));
        }
Exemple #3
0
        public IActionResult EstimateTransactionDetails([FromBody] MerchantPaymentRequest request)
        {
            if (!request.ValidateObject())
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.General_Error, (int)GeneralError.Nullable_Request, Constants.Constants.GeneralErrorDic[GeneralError.Nullable_Request]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            MerchantPaymentResponse response = new MerchantPaymentResponse();

            response.Amount             = new Amount();
            response.Amount.ServiceFees = Constants.Constants.TransactionFees;
            response.Amount.Commission  = (long)request.Amount - 1;
            response.Amount.Total       = (long)request.Amount + Constants.Constants.TransactionFees;
            response.TransactionId      = request.TransactionId + "--" + "\n" + "Basic Info:" + request.BasicInfo.ToString();
            return(Ok(response));
        }
        public IActionResult ValidateCredentials([FromBody] LoginRequest request)
        {
            if (!request.ValidateObject())
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.General_Error, (int)GeneralError.Nullable_Request, Constants.Constants.GeneralErrorDic[GeneralError.Nullable_Request]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            LoginResponse response       = new LoginResponse();
            AccountRep    accountRep     = new AccountRep(Context);
            int           y              = ExceptionHandeling.x();
            Account       CurrentAccount = accountRep.ValidateCorrectCredentials(request.BasicInfo.MobileNumberInfo.Number, request.Password);

            if (CurrentAccount != null)
            {
                response.LoginStatus    = 1;
                response.AdditionalInfo = "Login Success with password " + request.Password + "\n"
                                          + "Basic Info: " + request.BasicInfo.ToString();
            }

            else
            {
                //List<CodeLabException> allErrors = new List<CodeLabException>();
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Wallet_Number_OR_Password, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Wallet_Number_OR_Password]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            return(Ok(response));
        }
Exemple #5
0
        public IActionResult ValidateCredentials([FromBody] LoginRequest request)
        {
            try
            {
                return(Ok(Authentication.ValidateCredentials(request)));
            }
            catch (CodeLabException ex)
            {
                return(ExceptionHandeling.GenerateErrorResponse(ex));
            }
            catch (Exception ex)
            {
                CodeLabException codelabExp = new CodeLabException
                {
                    ErrorCode            = (int)ErrorCode.General_Error,
                    SubErrorCode         = (int)GeneralError.Some_Thing_Went_Wrong,
                    ErrorReferenceNumber = "UU-266169856"
                };

                //codelabExp.ExtraInfoMessage = "call failed because " + Constants.GeneralErrorDic[GeneralError.Some_Thing_Went_Wrong];
                codelabExp.ExtraInfoMessage = ex.Message;
                return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
            }
        }
Exemple #6
0
        public IActionResult PerformTransaction([FromBody] ConfirmPaymentRequest request)
        {
            if (!request.ValidateObject())
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.General_Error, (int)GeneralError.Nullable_Request, Constants.Constants.GeneralErrorDic[GeneralError.Nullable_Request]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            ConfirmPaymentResponse response   = new ConfirmPaymentResponse();
            AccountRep             accountRep = new AccountRep(Context);
            Account fromWallet  = accountRep.GetByMSDIN(request.BasicInfo.MobileNumberInfo.Number);
            Account toWallet    = accountRep.GetByMSDIN(request.ToWalletNumber);
            decimal totalAmount = (decimal)request.TotalAmount;
            string  DecodedMPIN = "";

            try
            {
                byte[] data = Convert.FromBase64String(request.MPin);
                DecodedMPIN = Encoding.UTF8.GetString(data);
            }
            catch (Exception ex)
            {
                DecodedMPIN = "";
            }
            try
            {
                if (fromWallet != null && toWallet != null)
                {
                    if (fromWallet == toWallet)
                    {
                        ExceptionHandeling.FireError((int)ErrorCode.Payment_Error, (int)PaymentError.Same_From_To_Wallet, Constants.Constants.PaymentErrorDic[PaymentError.Same_From_To_Wallet]);
                    }
                    if (fromWallet.Mpin == DecodedMPIN)
                    {
                        if (toWallet.Balance >= totalAmount)
                        {
                            if (request.TotalAmount <= Constants.Constants.MaxLimit)
                            {
                                if (request.TotalAmount >= Constants.Constants.MinLimit)
                                {
                                    fromWallet.Balance -= totalAmount;
                                    toWallet.Balance   += totalAmount;
                                    accountRep.Update(fromWallet);
                                    accountRep.Update(toWallet);
                                    //insert Transaction
                                    Transaction transaction = new Transaction()
                                    {
                                        TransactionId  = request.TransactionId,
                                        FromAccount    = fromWallet.Id,
                                        ToAccount      = toWallet.Id,
                                        Status         = 2,
                                        IssueTime      = DateTime.Now,
                                        LastUpdateTime = DateTime.Now,
                                        Amount         = totalAmount,
                                        CurrencyCode   = request.CurrencyCode
                                    };
                                    TransactionRep transactionRep = new TransactionRep(Context);
                                    transactionRep.InsertTransaction(transaction);
                                    response.TransactionStatus  = 1;
                                    response.AdditionalInfo     = "string information" + "\n" + "Basic Info:" + request.BasicInfo.ToString();;
                                    response.TransactionId      = request.TransactionId;
                                    response.CurrentBalance     = (double)fromWallet.Balance;
                                    response.CompletionDateTime = transaction.IssueTime.ToString(Constants.Constants.DateTimeFormat);
                                    response.TotalAmount        = (double)transaction.Amount;
                                    response.CurrencyCode       = transaction.CurrencyCode;
                                }
                                else
                                {
                                    ExceptionHandeling.FireError((int)ErrorCode.Payment_Error, (int)PaymentError.Less_Than_Min_Amount, Constants.Constants.PaymentErrorDic[PaymentError.Less_Than_Min_Amount]);
                                }
                            }
                            else
                            {
                                ExceptionHandeling.FireError((int)ErrorCode.Payment_Error, (int)PaymentError.Greater_Than_Max_Amount, Constants.Constants.PaymentErrorDic[PaymentError.Greater_Than_Max_Amount]);
                            }
                        }
                        else
                        {
                            ExceptionHandeling.FireError((int)ErrorCode.Payment_Error, (int)PaymentError.Insufficient_Balance, Constants.Constants.PaymentErrorDic[PaymentError.Insufficient_Balance]);
                        }
                    }
                    else
                    {
                        ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_MPIN, Constants.Constants.WrongInputDic[WrongInputError.Wrong_MPIN]);
                    }
                }
                else
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Wallet_Number, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Wallet_Number]);
                }
            }
            catch (CodeLabException codelabExp)
            {
                return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
            }
            return(Ok(response));
        }