public string GetPaymentDetails()
        {
            try
            {
                payment OnlinePaymentDTO = new payment();  //OnlinePaymentDTO

                var queryString = HttpContext.Current.Request.QueryString;
                string payment_id = queryString["payment_id"];
                string status = queryString["status"];

                string PaymentDetailUrl = ConfigurationManager.AppSettings["PaymentDetailsUrl"].ToString();// "https://test.instamojo.com/api/1.1/payments/[payment_id]?api_key=4709c5655f99d3799ccc22d8da23a137&auth_token=820cb88637df64e703782970c729a5fb";

                PaymentDetailUrl = PaymentDetailUrl.Replace("%26", "&");
                PaymentDetailUrl = PaymentDetailUrl.Replace("[payment_id]", payment_id);

                WebRequest request = HttpWebRequest.Create(PaymentDetailUrl);
                WebResponse response = request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string responseText = reader.ReadToEnd();

               // OnlinePaymentDTO = urlpaymentId;
                return responseText;// OnlinePaymentDTO;

            }
            catch (TimeoutException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout)
                {
                    Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."),
                    ReasonPhrase = "Critical Exception"
                });
            }
            catch (Exception)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."),
                    ReasonPhrase = "Critical Exception"
                });
            }
        }
        public PaymentDTO GetPaymentDetailsURLByPaimentId(string paymentId)
        {
            try
            {
                payment OnlinePaymentDTO = new payment();  //OnlinePaymentDTO

                var queryString = HttpContext.Current.Request.QueryString;
                string payment_id = paymentId;
                string PaymentDetailUrl = ConfigurationManager.AppSettings["PaymentDetailsUrl"].ToString();//  "https://test.instamojo.com/api/1.1/payments/[payment_id]?api_key=4709c5655f99d3799ccc22d8da23a137&auth_token=820cb88637df64e703782970c729a5fb";
                PaymentDetailUrl = PaymentDetailUrl.Replace("%26", "&");
                PaymentDetailUrl = PaymentDetailUrl.Replace("[payment_id]", payment_id);

                WebRequest request = HttpWebRequest.Create(PaymentDetailUrl);
                WebResponse response = request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string responseText = reader.ReadToEnd();
                //responseText = responseText.Replace("\n","");

                PaymentDTO PaymentDTO = JsonConvert.DeserializeObject<PaymentDTO>(responseText);
                if (PaymentDTO != null)
                {
                    if (PaymentDTO.payment.custom_fields != null)
                    {
                        int CreditRequestId = Convert.ToInt32( PaymentDTO.payment.custom_fields.Field_52722.value);
                        CreditRequestDTO CreditRequestDTO = new CreditRequestDTO();
                        CreditRequestDTO = CreditRequestService.GetById(CreditRequestId);
                        if (PaymentDTO.success == true)
                        {
                            if (CreditRequestDTO.IsPaid != true)
                            {
                                CreditRequestDTO.PaymentId = PaymentDTO.payment.payment_id;
                                CreditRequestDTO.ProvidedCredit = CreditRequestDTO.RequestedCredit;
                                CreditRequestService.EditCreditRequestForOnlinePayment(CreditRequestDTO, true);
                            }
                        }
                        else
                        {
                            CreditRequestDTO.PaymentId = PaymentDTO.payment.payment_id;
                            CreditRequestDTO.IsPaid = false;
                            CreditRequestService.EditCreditRequestForOnlinePayment(CreditRequestDTO, false);
                        }

                    }
                }
               // PaymentInfoDTO PaymentInfoDTO = JsonConvert.DeserializeObject<PaymentInfoDTO>(responseText);

                // OnlinePaymentDTO = urlpaymentId;
                //return PaymentDetailUrl;
                return PaymentDTO;// OnlinePaymentDTO;

            }
            catch (TimeoutException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout)
                {
                    Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."),
                    ReasonPhrase = "Critical Exception"
                });
            }
            catch (Exception)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent("An error occurred, please try again or CreditRequest the administrator."),
                    ReasonPhrase = "Critical Exception"
                });
            }
        }