1

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,

Derek
  • 21
  • 3
  • How is the request flow setup? What's initiating the request to the Lambda function? Are you leveraging the GP eCommerce JavaScript library on the frontend? – Shane L. Apr 30 '20 at 13:57
  • We are learning as we go a little bit, but the Lambda is called via API Gateway from our front end. We are not using any specific payment JS, and we just retdirect to the response when it is returned. We've tried a few ways to run, both from the back end and the front so any hint on standard approach would be great – Derek May 01 '20 at 14:25
  • Any error messages from the hosted payment page? Is your return URL hosted via TLS 1.2? Typically, we'd suggest going down the path of leveraging our JavaScript library to facilitate the HPP setup (directions here: https://developer.globalpay.com/ecommerce/hosted-payment-page#hpp). – Shane L. May 04 '20 at 15:08
  • Would you be able to share the POST data that is sent to the HPP? (Please obscure the Merchant ID) – Global Payments May 05 '20 at 10:38

0 Answers0