Я являюсь интеграцией "Paytm Payment" на локальном хосте с использованием "Test MerchantKey", и я выполняю действия, указанные в документации PayTM Developer [https://developer.paytm.com/docs/v1/payment-gateway]
Моя проблема:
Моя страница не находится на странице входа или оплаты Paytm. Он выполняет обработку и перенаправляется на страницу «Response.aspx», выполняя эти два метода.
1. Контрольная сумма поколения и
2. Проверка контрольной суммы (возвращает true)
Default.aspx
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASP.NET
{
public partial class Default : System.Web.UI.Page
{
string merchantKey = ConfigurationManager.AppSettings["PaytmMerchantKey"];
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCheckout_Click(object sender, EventArgs e)
{
var number = new Random().Next(1, 999);
merchantKey = "X1aTH!1qk!fuHzM1"; //bQfzzkKzeCbR7jOl";
PaymentParameters parameters = new PaymentParameters
{
MerchantId = "vIoGbc27013128501609",
IndustryTypeId = "Retail",
CallbackUrl = "http://localhost:55888/Payment/Paytm/Response.aspx",
ChannelId = "WEB",
Website = "WEBSTAGING",
OrderId = "Ord"+number,
CustomerId = "Cust0"+number,
Amount = lblAmount.Text.Trim(),
Mobile = txtMobile.Text.Trim(),
Email="kumar.praveen179@gmail.com"
};
Dictionary<string, string> requestData = new PaymentParameters().Parameters(parameters);
PaytmPaymentService paymentService = new PaytmPaymentService();
string checksum = paymentService.GenerateCheck(merchantKey, requestData);
string paymentPageHtml = PaytmPaymentPage(requestData, parameters.OrderId, checksum);
Response.Write(paymentPageHtml);
}
string PaytmPaymentPage(Dictionary<string,string> parameters,string orderId,string checksum)
{
var paytmUrl = "https://securegw-stage.paytm.in/theia/processTransaction?orderid="+ orderId;
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 + "'>";
outputHTML += "</tbody>";
outputHTML += "</table>";
outputHTML += "<script type='text/javascript'>";
outputHTML += "document.f1.submit();";
outputHTML += "</script>";
outputHTML += "</form>";
outputHTML += "</body>";
outputHTML += "</html>";
return outputHTML;
}
}
}
Response.aspx.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASP.NET.Payment.Paytm
{
public partial class Response : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string merchantKey = ConfigurationManager.AppSettings["PaytmSecretKey"];
Dictionary<string, string> parameters = new Dictionary<string, string>();
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");
}
if (new PaytmPaymentService().VerifyCheckSum(merchantKey, paytmChecksum, parameters))
{
Response.Write("Checksum Matched");
}
else
{
Response.Write("Checksum MisMatch");
}
}
}
}