我正在通过代码中的 post 请求向 Global Payments 拨打电话,但我不知道它是否正在获取信息。
它似乎忽略了我的配置参数和我的返回 URL,所以想知道它是否正在获取任何数据,尽管如果 order_id、amount 等不正确,它会出错。我在报告门户中也没有交易条目。
所以我从 AWS Lambda 打电话:
Payment pay = new Payment();
string URL = "https://pay.sandbox.realexpayments.com/pay";
// Create a payment object with built in validation, etc
pay.ORDER_ID = [ORDERID];
pay.MERCHANT_ID = [COMPANYNAME];
pay.ACCOUNT = [ACCOUNT];
pay.TIMESTAMP = DateTime.Now.Year.ToString() +
DateTime.Now.Month.ToString().PadLeft(2, pad) +
DateTime.Now.Day.ToString().PadLeft(2,pad) +
DateTime.Now.Hour.ToString().PadLeft(2, pad) +
DateTime.Now.Minute.ToString().PadLeft(2, pad) +
DateTime.Now.Second.ToString().PadLeft(2, pad);
pay.CURRENCY = [CURRENCY];
pay.AMOUNT = [PRICE];
**pay.PM_METHODS = "cards|paypal";**
**pay.MERCHANT_RESPONSE_URL = [VALID API GATEWAY MOCK ENDPOINT];**
pay.HPP_TX_STATUS_URL = ...
pay.VARREF = ...
pay.COMMENT1 = ...
pay.AUTO_SETTLE_FLAG = 1;
pay.SHIPPING_ADDRESS_ENABLE = 1;
pay.ADDRESS_OVERRIDE = 1;
pay.HPP_NAME = ...;
pay.HPP_STREET = ...;
pay.HPP_STREET2 = ...;
pay.HPP_CITY = ...;
pay.HPP_STATE = ...;
pay.HPP_ZIP = ...;
pay.HPP_COUNTRY = ...;
pay.HPP_PHONE = ...;
// Get the hash key
string tempToHash = HashIt(pay.TIMESTAMP + "." + pay.MERCHANT_ID + "." + pay.ORDER_ID + "." + pay.AMOUNT + "." + pay.CURRENCY);
string finalHash = HashIt(tempToHash + ".[hash key]");
pay.SHA1HASH = finalHash;
var httpWebRequest = (System.Net.HttpWebRequest)WebRequest.Create(URL);
var postData = "TIMESTAMP=" + pay.TIMESTAMP +
"&MERCHANT_ID=" + pay.MERCHANT_ID +
"&ACCOUNT=" + pay.ACCOUNT +
"&ORDER_ID=" + pay.ORDER_ID +
"&AMOUNT=" + pay.AMOUNT +
"&CURRENCY=" + pay.CURRENCY +
"&MERCHANT_RESPONSE_URL=" + pay.MERCHANT_RESPONSE_URL +
"&HPP_TX_STATUS_URL=" + pay.HPP_TX_STATUS_URL +
"&PM_METHODS=" + pay.PM_METHODS +
"&SHA1HASH=" + finalHash +
"&HPP_VERSION=2" +
"&VARREF=" + pay.VARREF +
"&COMMENT1=" + pay.COMMENT1 +
"&AUTO_SETTLE_FLAG=" + pay.AUTO_SETTLE_FLAG +
"&SHIPPING_ADDRESS_ENABLE=" + pay.SHIPPING_ADDRESS_ENABLE +
"&ADDRESS_OVERRIDE=" + pay.ADDRESS_OVERRIDE +
"&HPP_NAME=" + pay.HPP_NAME +
"&HPP_STREET=" + pay.HPP_STREET +
"&HPP_STREET2=" + pay.HPP_STREET2 +
"&HPP_CITY=" + pay.HPP_CITY +
"&HPP_STATE=" + pay.HPP_STATE +
"&HPP_ZIP=" + pay.HPP_ZIP +
"&HPP_COUNTRY=" + pay.HPP_COUNTRY +
"&HPP_PHONE=" + pay.HPP_PHONE;
var data = Encoding.ASCII.GetBytes(postData);
var data2 = Encoding.ASCII.GetChars(data);
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.ContentLength = data.Length;
Console.WriteLine(postData);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(data2, 0, data2.Length);
}
Console.WriteLine("Calling");
try
{
var httpResponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine(result);
我知道代码并不完全是最优雅的(!),但它似乎确实在发布。它确实重定向到付款页面并似乎接受了付款,但没有正确配置页面,因为它只显示卡付款 - 没有贝宝,也没有使用我的返回 URL。
我错过了什么吗?
干杯,