Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have integrate paytm payment getway in my website.When i click the payTM button its not redirect to paymentgetway page,its just redirect to the callback url page.please help me to use this successfully in my website.

the code i have shown its written in gridview button RowCommand event.

What I have tried:

String merchantMid = "**removed**";
String merchantKey = "**removed**";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("MID", merchantMid);
parameters.Add("CHANNEL_ID", "WEB");
parameters.Add("INDUSTRY_TYPE_ID", "Retail");
parameters.Add("WEBSITE", "WEB_STAGING");
parameters.Add("EMAIL", "**removed**");
parameters.Add("MOBILE_NO", "7777777777");
parameters.Add("CUST_ID", "CUST_BIB");
parameters.Add("ORDER_ID", "XXLALALAYY");
parameters.Add("TXN_AMOUNT", "10.00");
parameters.Add("CALLBACK_URL", "http://**removed**"); //This parameter is not mandatory. Use this to pass the callback url dynamically.

string checksum_S =CheckSum.generateCheckSum(merchantKey, parameters);
string paytmURL = "https://securegw-stage.paytm.in/theia/processTransaction?orderid="+parameters.FirstOrDefault(x => x.Key == "ORDER_ID").Value;

string outputHTML = "<html>";
outputHTML += "<head>";
outputHTML += "<title>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_S + "'>";
outputHTML += "</tbody>";
outputHTML += "</table>";
outputHTML += "<script type='text/javascript'>";
outputHTML += "document.f1.submit();";
outputHTML += "</script>";
outputHTML += "</form>";
outputHTML += "</body>";
outputHTML += "</html>";

Response.Write(outputHTML);
Posted
Updated 15-Jan-19 0:39am
v2
Comments
F-ES Sitecore 15-Jan-19 6:43am    
You'll find this easier if you store the order specific information like order id etc in the Session and the redirect the browser to a payment page and that payment page will have your outputHTML on it, getting order-specific details from the Session
BIBASWAN 15-Jan-19 10:44am    
i have tried it.its not working too.
I have use their SANDBOX.payment page not showing but order is creating in the dashboard as pending.
Richard Deeming 18-Jan-19 11:43am    
parameters.FirstOrDefault(x => x.Key == "ORDER_ID").Value

You can simplify that to:
parameters["ORDER_ID"]

If the dictionary doesn't contain the specified key, you'll get a KeyNotFoundException; with your current code, you'd get a blank value instead.

1 solution

Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.

Only get such code from your payment gateway company - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!

Talk to them: they are used to it, and most are really helpful - remember, they don't get any commission until you are up and trading. Oh, and USE THEIR SANDBOX!
 
Share this answer
 
Comments
BIBASWAN 15-Jan-19 10:43am    
I have use their SANDBOX.payment page not showing but order is creating in the dashboard as pending.
OriginalGriff 15-Jan-19 10:53am    
Then you need to speak to them.
Seriously, do you think getting advice from total strangers on the web is the best way to deal with real money?
BIBASWAN 15-Jan-19 11:17am    
Do you think i am using real money?
OriginalGriff 15-Jan-19 11:27am    
Not yet - hopefully - but you will be at some point. And with the same code ... it really isn't worth the risk.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900