I'm making a call via a post request in code to Global Payments, but I have no idea whether it is taking the information or not.
It seems to ignore my configuration parameter and my return URLs so wonder whether it is getting any data all, though it does error if the order_id, amount, etc are incorrect. I get no transaction entry in the reporting portal either.
So I am calling from an AWS Lambda as :
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);
I know the code isn't exactly the most elegant(!) but it does appear to do the post. It does redirect to the payment page and appears to take the payment, but doesn't configure the page correctly, as in it only shows card payments - no paypal nor use my return URL.
Am I missing something?
Cheers,