Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();


            if (Request.Form.AllKeys.Length > 0)
            {
                string paytmChecksum = "";
                foreach (string key in Request.Form.Keys)
                {
                    parameters.Add(key.Trim(), Request.Form[key].Trim());
                }


                if (parameters.ContainsKey("CHECKSUMHASH"))
                {
                    paytmChecksum = parameters["CHECKSUMHASH"];
                    parameters.Remove("CHECKSUMHASH");
                }
                PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
                if (CheckSum.verifyCheckSum(lPayTmConfiguration.Merchant_Key, parameters, paytmChecksum))
                {
                    Create_Paytm_Payment(parameters);
                }
                else
                {
                    Response.Write("Invalid Request");
                }
            }
        }
Esempio n. 2
0
        public static PayTmConfiguration Get_Paytm_Configuration()
        {
            PayTmConfiguration lPayTmConfiguration = new PayTmConfiguration();

            if (CommonClass.Is_Production())
            {
                //lPayTmConfiguration.Website_Name = "gilldstore";
                //lPayTmConfiguration.MID = "GILLDO95102413872758";
                //lPayTmConfiguration.Merchant_Key = "7HWZdpS66qDTqnFh";
                //lPayTmConfiguration.Industry_Type = "Retail";
                //lPayTmConfiguration.Channel_Id = "WEB";
                //lPayTmConfiguration.Payment_Url = "https://pguat.paytm.com/oltp-web/processTransaction";
                //lPayTmConfiguration.Mobile_Number = "7777777777";
                //lPayTmConfiguration.Refund_Url = "https://pguat.paytm.com/oltp/HANDLER_INTERNAL/REFUND";
                lPayTmConfiguration.Website_Name  = "GILLDOweb";
                lPayTmConfiguration.MID           = "GILLDO65732891881355";
                lPayTmConfiguration.Merchant_Key  = "42d2UDzdHqRKnmC@";
                lPayTmConfiguration.Industry_Type = "Retail120";
                lPayTmConfiguration.Channel_Id    = "WEB";
                lPayTmConfiguration.Payment_Url   = "https://secure.paytm.in/oltp-web/processTransaction";
            }
            else
            {
                lPayTmConfiguration.Website_Name  = HttpContext.Current.Application["COMPANY_DISPLAY_NAME"].ToString();
                lPayTmConfiguration.MID           = "GILLDO95102413872758";
                lPayTmConfiguration.Merchant_Key  = "7HWZdpS66qDTqnFh";
                lPayTmConfiguration.Industry_Type = "Retail";
                lPayTmConfiguration.Channel_Id    = "WEB";
                lPayTmConfiguration.Payment_Url   = "https://pguat.paytm.com/oltp-web/processTransaction";
                lPayTmConfiguration.Mobile_Number = "7777777777";
                lPayTmConfiguration.Refund_Url    = "https://pguat.paytm.com/oltp/HANDLER_INTERNAL/REFUND";
            }
            return(lPayTmConfiguration);
        }
Esempio n. 3
0
        public static string Get_Payment_Status(string pOrderId)
        {
            PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
            WebRequest         lWebRequest         = WebRequest.Create("https://secure.paytm.in/oltp/HANDLER_INTERNAL/TXNSTATUS?JsonData={\"ORDERID\":\"" + pOrderId + "\",\"MID\":\"" + lPayTmConfiguration.MID + "\"}");
            HttpWebResponse    lHttpWebResponse    = (HttpWebResponse)lWebRequest.GetResponse();
            Stream             lStream             = lHttpWebResponse.GetResponseStream();
            StreamReader       lStreamReader       = new StreamReader(lStream);
            string             lResponseFromSender = lStreamReader.ReadToEnd();


            lStreamReader.Close();
            lStream.Close();
            lHttpWebResponse.Close();
            return(lResponseFromSender);
        }
Esempio n. 4
0
        public static void Refund_PayTm_Order(string pOrderId,
                                              string pTxnId,
                                              string pRefundAmount,
                                              string pComments,
                                              string pReferenceId)
        {
            PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
            PayTmPaymentGatewayRefundRequest lPaymentGatewayRefundRequest = new PayTmPaymentGatewayRefundRequest();
            Dictionary <string, string>      parameters = new Dictionary <string, string>();

            lPaymentGatewayRefundRequest.MID          = lPayTmConfiguration.MID;
            lPaymentGatewayRefundRequest.TXNID        = pTxnId;
            lPaymentGatewayRefundRequest.ORDERID      = pOrderId;
            lPaymentGatewayRefundRequest.REFUNDAMOUNT = pRefundAmount;
            lPaymentGatewayRefundRequest.TXNTYPE      = "REFUND";
            lPaymentGatewayRefundRequest.COMMENTS     = pComments;
            lPaymentGatewayRefundRequest.REFID        = pReferenceId;
            parameters.Add("MID", lPayTmConfiguration.MID);
            parameters.Add("TXNID", pTxnId);
            parameters.Add("ORDERID", pOrderId);
            parameters.Add("REFUNDAMOUNT", pRefundAmount);
            parameters.Add("TXNTYPE", "REFUND");
            parameters.Add("COMMENTS", pComments);
            parameters.Add("REFID", pReferenceId);

            string checksum = CheckSum.generateCheckSum(lPayTmConfiguration.Merchant_Key, parameters);

            lPaymentGatewayRefundRequest.CHECKSUM = checksum;

            JavaScriptSerializer lJavaScriptSerializer = new JavaScriptSerializer();
            var lJson = lJavaScriptSerializer.Serialize(lPaymentGatewayRefundRequest);

            WebRequest      lWebRequest         = WebRequest.Create(lPayTmConfiguration.Refund_Url + "?JsonData=" + lJson);
            HttpWebResponse lHttpWebResponse    = (HttpWebResponse)lWebRequest.GetResponse();
            Stream          lStream             = lHttpWebResponse.GetResponseStream();
            StreamReader    lStreamReader       = new StreamReader(lStream);
            string          lResponseFromSender = lStreamReader.ReadToEnd();

            //    PaymentGatewayResponse lPaymentGatewayResponse = lJavaScriptSerializer.Deserialize<PaymentGatewayResponse>(lResponseFromSender);
            lStreamReader.Close();
            lStream.Close();
            lHttpWebResponse.Close();

            //    if (lPaymentGatewayResponse != null)
            //    {
        }
Esempio n. 5
0
        public static void Initiate_PayTm_Order(string pOrderId,
                                                string pTransactionAmount,
                                                string pEmail,
                                                string pMobileNumber)
        {
            PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
            string             lMobileNumber       = pMobileNumber;

            if (lPayTmConfiguration.Mobile_Number != null)
            {
                lMobileNumber = lPayTmConfiguration.Mobile_Number;
            }

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            //string lOrderId = lRecords[0];
            parameters.Add("REQUEST_TYPE", "DEFAULT");
            parameters.Add("MID", lPayTmConfiguration.MID);
            parameters.Add("CHANNEL_ID", lPayTmConfiguration.Channel_Id);
            parameters.Add("INDUSTRY_TYPE_ID", lPayTmConfiguration.Industry_Type);
            parameters.Add("WEBSITE", lPayTmConfiguration.Website_Name);
            parameters.Add("EMAIL", pEmail);
            parameters.Add("MOBILE_NO", lMobileNumber);
            parameters.Add("CUST_ID", ClaimsPrincipal.Current.FindFirst("user_id").Value);
            parameters.Add("ORDER_ID", pOrderId);
            parameters.Add("TXN_AMOUNT", pTransactionAmount);
            var lCallBackUrl = "http://" + HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + "/Order_Response.aspx"; //This parameter is not mandatory. Use this to pass the callback url dynamically.

            if (CommonClass.Is_Production())
            {
                lCallBackUrl = lCallBackUrl.Replace("http://", "https://");
            }
            parameters.Add("CALLBACK_URL", lCallBackUrl);
            string paytmURL = lPayTmConfiguration.Payment_Url;

            string checksum   = CheckSum.generateCheckSum(lPayTmConfiguration.Merchant_Key, parameters);
            string outputHTML = "<html>";

            outputHTML += "<head>";
            outputHTML += "<title>Paytm Merchant Check Out Page</title>";
            outputHTML += "</head>";
            outputHTML += "<body>";
            outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
            outputHTML += "<form method='post' action='" + paytmURL + "' name='f1'>";
            outputHTML += "<table border='1'>";
            outputHTML += "<tbody>";
            foreach (string key in parameters.Keys)
            {
                outputHTML += "<input type='hidden' name='" + key + "' value='" + parameters[key] + "'>";
            }
            outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "'>";
            outputHTML += "</tbody>";
            outputHTML += "</table>";
            outputHTML += "<script type='text/javascript'>";
            outputHTML += "document.f1.submit();";
            outputHTML += "</script>";
            outputHTML += "</form>";
            outputHTML += "</body>";
            outputHTML += "</html>";
            HttpContext.Current.Response.Write(outputHTML);
        }