【发布时间】:2019-10-23 03:08:13
【问题描述】:
致力于将 Paytm 与 C# 应用程序集成。
我正在使用自动借记流进行整合。
作为此流程的一部分,需要调用 Paytm 提供的 SENDOTP API 以将 OTP 发送到客户手机。
我使用了从 Paytm 开发者网站获得的代码。
https://developer.paytm.com/docs/send-otp-api/
.Net 代码:
字符串 url = "https://accounts-uat.paytm.com/signin/otp";
Dictionary<String, String> paytmParams = new Dictionary<String, String>();
paytmParams.Add("email", xxxxxxx@xxxxxxx.xxx);
paytmParams.Add("phone", xxxxxxxxxx);
paytmParams.Add("clientId", xxxxxxxx-xxx);
paytmParams.Add("scope", wallet);
paytmParams.Add("responseType", token);
try {
String postData = "JsonData="+ new JavaScriptSerializer().Serialize(paytmParams);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Headers.Add("ContentType", "application/json");
webRequest.Method = "POST";
using (StreamWriter streamWriter = new StreamWriter(webRequest.GetRequestStream())) {
streamWriter.Write(postData);
streamWriter.Flush();
streamWriter.Close();
}
string string responseData = string.Empty;
using (StreamReader responseReader = new StreamReader(webRequest.GetResponse())) {
responseData = responseReader.ReadToEnd();
}
} catch (Exception ex) {
Response.Write("Exception message: " + ex.Message.ToString());
}
以下是请求格式:
JsonData = {
"email":"login2kkr@gmail.com",
"phone":"XXXXXXXXXX",
"clientId":"merchant-ABC",
"scope":"Wallet",
"responseType":"Token"
}
回复:
{
"status":"FAILURE",
"responseCode":"434",
"message":"Bad Request"
}
问候, 基肖尔。
【问题讨论】: