Ejemplo n.º 1
0
        public ResponseModel GeneratePaymentLink([FromBody] SentPaymentLink objRequest)
        {
            int           obj              = 0;
            HSOrderCaller hSOrderCaller    = new HSOrderCaller();
            ResponseModel objResponseModel = new ResponseModel();
            int           statusCode       = 0;
            string        statusMessage    = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                obj          = hSOrderCaller.GeneratePaymentLink(new HSOrderService(_connectionString), objRequest, _ClientAPIUrlForGenerateToken, _ClientAPIUrlForGeneratePaymentLink, authenticate.TenantId, authenticate.UserMasterID, authenticate.ProgramCode);
                statusCode   =
                    obj == 0 ?
                    (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;

                statusMessage                 = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);
                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = obj;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///Generate Link
 /// </summary>
 /// <param name="sentPaymentLink"></param>
 /// <param name="clientAPIUrlForGenerateToken"></param>
 /// <param name="clientAPIUrlForGeneratePaymentLink"></param>
 /// <param name="TenantID"></param>
 /// <param name="UserID"></param>
 /// <param name="programCode"></param>
 /// <returns></returns>
 public int GeneratePaymentLink(IHSOrder order, SentPaymentLink sentPaymentLink, string clientAPIUrlForGenerateToken, string clientAPIUrlForGeneratePaymentLink, int tenantID, int userID, string programCode)
 {
     _OrderRepository = order;
     return(_OrderRepository.GenerateLink(sentPaymentLink, clientAPIUrlForGenerateToken, clientAPIUrlForGeneratePaymentLink, tenantID, userID, programCode));
 }
Ejemplo n.º 3
0
        /// <summary>
        ///Generate Link
        /// </summary>
        /// <param name="sentPaymentLink"></param>
        /// <param name="clientAPIUrlForGenerateToken"></param>
        /// <param name="clientAPIUrlForGeneratePaymentLink"></param>
        /// <param name="TenantID"></param>
        /// <param name="UserID"></param>
        /// <param name="programCode"></param>
        /// <returns></returns>
        public int GenerateLink(SentPaymentLink sentPaymentLink, string clientAPIUrlForGenerateToken, string clientAPIUrlForGeneratePaymentLink, int tenantID, int userID, string programCode)
        {
            int     result  = 0;
            string  apiReq1 = "";
            string  URLGeneratePaymentLink = "";
            DataSet ds = new DataSet();
            HSRequestResendPaymentLink   hSRequestResendPaymentLink   = null;
            HSRequestGeneratePaymentLink hSRequestGeneratePaymentLink = null;

            try
            {
                if (conn != null && conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrderDetailForPaymentLink", conn)
                {
                    Connection  = conn,
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@Invoice_Number", sentPaymentLink.InvoiceNumber);
                cmd.Parameters.AddWithValue("@tenant_ID", tenantID);
                cmd.Parameters.AddWithValue("@user_ID", userID);

                MySqlDataAdapter da = new MySqlDataAdapter
                {
                    SelectCommand = cmd
                };
                da.Fill(ds);

                if (ds != null && ds.Tables[0] != null)
                {
                    hSRequestGeneratePaymentLink = new HSRequestGeneratePaymentLink
                    {
                        merchantTxnID = ds.Tables[0].Rows[0]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["InvoiceNo"]),
                        billDateTime  = ds.Tables[0].Rows[0]["billDateTime"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["billDateTime"]),
                        terminalId    = ds.Tables[0].Rows[0]["TerminalId"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["TerminalId"]),
                        name          = ds.Tables[0].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["CustomerName"]),
                        email         = ds.Tables[0].Rows[0]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["EmailID"]),
                        mobile        = ds.Tables[0].Rows[0]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[0]["MobileNumber"]),
                        amount        = ds.Tables[0].Rows[0]["Amount"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[0]["Amount"])
                    };
                }
                hSRequestGeneratePaymentLink.programCode = programCode;
                hSRequestGeneratePaymentLink.storeCode   = sentPaymentLink.StoreCode;
                DateTime dateTime_billdatetime = Convert.ToDateTime(hSRequestGeneratePaymentLink.billDateTime);
                var      settings = new JsonSerializerSettings {
                    DateFormatString = "yyyy-MM-ddTHH:mm:ss.fffZ"
                };
                var json    = JsonConvert.SerializeObject(dateTime_billdatetime, settings);
                var newdate = JsonConvert.DeserializeObject <string>(json);
                hSRequestGeneratePaymentLink.billDateTime = newdate;
                HSResponseGeneratePaymentLink responseGeneratePaymentLink = new HSResponseGeneratePaymentLink();

                HSRequestGenerateToken hSRequestGenerateToken = new HSRequestGenerateToken();
                string apiReq = JsonConvert.SerializeObject(hSRequestGenerateToken);
                apiResponse = CommonService.SendApiRequestToken(clientAPIUrlForGenerateToken + "connect/token", apiReq);
                HSResponseGenerateToken hSResponseGenerateToken = new HSResponseGenerateToken();
                hSResponseGenerateToken = JsonConvert.DeserializeObject <HSResponseGenerateToken>(apiResponse);

                if (!string.IsNullOrEmpty(hSResponseGenerateToken.access_Token))
                {
                    if (sentPaymentLink.SentPaymentLinkCount > 0)
                    {
                        hSRequestResendPaymentLink = new HSRequestResendPaymentLink
                        {
                            programCode   = programCode,
                            tokenId       = hSResponseGenerateToken.access_Token,
                            storeCode     = sentPaymentLink.StoreCode,
                            billDateTime  = hSRequestGeneratePaymentLink.billDateTime,
                            terminalId    = hSRequestGeneratePaymentLink.terminalId,
                            merchantTxnID = hSRequestGeneratePaymentLink.merchantTxnID,
                            mobile        = hSRequestGeneratePaymentLink.mobile,
                            reason        = "ABCD"
                        };
                        apiReq1 = JsonConvert.SerializeObject(hSRequestResendPaymentLink);
                        URLGeneratePaymentLink = clientAPIUrlForGeneratePaymentLink + "api/ResendPaymentLink";
                    }
                    else
                    {
                        apiReq1 = JsonConvert.SerializeObject(hSRequestGeneratePaymentLink);
                        URLGeneratePaymentLink = clientAPIUrlForGeneratePaymentLink + "api/GeneratePaymentLink";
                    }
                    apiResponse1 = CommonService.SendApiRequestMerchantApi(URLGeneratePaymentLink, apiReq1, hSResponseGenerateToken.access_Token);

                    responseGeneratePaymentLink = JsonConvert.DeserializeObject <HSResponseGeneratePaymentLink>(apiResponse1);
                }

                if (responseGeneratePaymentLink.returnMessage == "Success")
                {
                    if (conn != null && conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    MySqlCommand cmd1 = new MySqlCommand("SP_PHYUpdateOrderDetailForPaymentLink", conn)
                    {
                        Connection  = conn,
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd1.Parameters.AddWithValue("@Invoice_Number", sentPaymentLink.InvoiceNumber);
                    cmd1.Parameters.AddWithValue("@access_Token", hSResponseGenerateToken.access_Token);
                    cmd1.Parameters.AddWithValue("@tenant_ID", tenantID);
                    cmd1.Parameters.AddWithValue("@user_ID", userID);
                    cmd1.CommandType = CommandType.StoredProcedure;
                    result           = Convert.ToInt32(cmd1.ExecuteNonQuery());
                    conn.Close();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(result);
        }