如何从中继响应 URL (SIM) Authorize.Net asp.net 获取交易数据,但它说不支持这种请求?
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://test.authorize.net/gateway/transact.dll");
byte[] param = Encoding.ASCII.GetBytes("x_login=5RV7a3kUww&x_tran_key=4SzL379Tbc7Nt4MP");
string strRequest = Encoding.ASCII.GetString(param);
// append PayPal verification code to end of string
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = strRequest.Length;
// req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(authKey)));
// req.Headers.Add("name","value");
// send data back to PayPal to request verification
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
// receive response from PayPal
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader streamIn = new StreamReader(resp.GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://test.authorize.net/gateway/transact.dll");
byte[] param = Encoding.ASCII.GetBytes("x_login=5RV7a3kUww&x_tran_key=4SzL379Tbc7Nt4MP");
string strRequest = Encoding.ASCII.GetString(param);
// append PayPal verification code to end of string
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = strRequest.Length;
// req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(authKey)));
// req.Headers.Add("name","value");
// send data back to PayPal to request verification
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
// receive response from PayPal
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader streamIn = new StreamReader(resp.GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
中继响应与服务器集成方法 (SIM) API 一起使用。这是他们托管的付款表格。您在发布的代码中没有使用 SIM 卡。您似乎正在使用高级集成方法 (AIM) API。 AIM 不适用于中继响应,因为您不需要它,因为用户永远不会离开您的站点。
我还看到评论提到 Paypal,这完全没有意义。我不知道为什么会出现这种情况。
Relay Response is used with the Server Integrated Method (SIM) API. That's their hosted payment form. You're not using SIM in the code you posted. It looks like you're using the Advanced Integration Method (AIM) API. AIM does not work with Relay Response because you don't need it since the user never leaves your site.
I also see comments mentioning Paypal which makes absolutely no sense. I'm not sure why that's even there.