Transaction Notification

This code steps you through the basics of configuring Web Hooks to handle data that gets posted to a URL that's associated with your BluePay Platform Account. When you're using this code in "test mode," only test transactions are returned.

Please contact our integration team with your gateway account ID & the URL of your receiving script to have this feature enabled.

The following sample code calls a routine from our Code Library.
Download BluePay.cs
Or, download via GitHub

* BluePay C#.NET Sample code.
* This code sample shows a very based approach
* on handling data that is posted to a script running
* a merchant's server after a transaction is processed
* through their BluePay gateway account.

using System;
using BluePayLibrary;
using System.Collections.Specialized;
using System.Web;
using System.Net;
using System.IO;
using System.Text;

namespace GetData
    class TransactionNotification
        public static void Main()
            string accountID = "Merchant's Account ID Here";
            string secretKey = "Merchant's Secret Key Here";
            string mode = "TEST";
            BluePay tps = new BluePay

            HttpListener listener = new HttpListener();
            string response = "";

                // Listen for incoming data
            catch (HttpListenerException)
            while (listener.IsListening)
                var context = listener.GetContext();
                var body = new StreamReader(context.Request.InputStream).ReadToEnd();

                byte[] b = Encoding.UTF8.GetBytes("ACK");

                // Return HTTP Status of 200 to BluePay
                context.Response.StatusCode = 200;
                context.Response.KeepAlive = false;
                context.Response.ContentLength64 = b.Length;

                var output = context.Response.OutputStream;
                output.Write(b, 0, b.Length);

                // Get Reponse
                using (StreamReader reader = new StreamReader(output))
                    response = reader.ReadToEnd();
            NameValueCollection vals = HttpUtility.ParseQueryString(response);

            // Parse data into a NVP collection
            string transID = vals["trans_id"];
            string transStatus = vals["trans_stats"];
            string transType = vals["trans_type"];
            string amount = vals["amount"];
            string rebillID = vals["rebill_id"];
            string rebillAmount = vals["rebill_amount"];
            string rebillStatus = vals["rebill_status"];
            string tpsHashType = vals["TPS_HASH_TYPE"];
            string bpStamp = vals["BP_STAMP"];
            string bpStampDef = vals["BP_STAMP_DEF"];

            // calculate the expected BP_STAMP
            string bpStampString = "";
            string[] defSeparator = new string[] { " " };
            string[] bpStampFields = bpStampDef.Split(defSeparator, StringSplitOptions.RemoveEmptyEntries);
            foreach (string field in bpStampFields)
                bpStampString += vals[field];
            string expectedStamp = tps.GenerateTPS(bpStampString, tpsHashType);

            // Output data if the expected BP_STAMP matches the actual BP_STAMP
            if (expectedStamp == bpStamp) {
                Console.Write("Transaction ID: " + transID);
                Console.Write("Transaction Status: " + transStatus);
                Console.Write("Transaction Type: " + transType);
                Console.Write("Transaction Amount: " + amount);
                Console.Write("Rebill ID: " + rebillID);
                Console.Write("Rebill Amount: " + rebillAmount);
                Console.Write("Rebill Status: " + rebillStatus);
            } else {
                Console.Write("ERROR IN RECEIVING DATA FROM BLUEPAY");
Can’t find what you’re
looking for? We can help.

Contact 800-350-2684 for Integration Support.

  • Microsoft Gold Partner Badge
  • Susan G. Komen for the Cure Supporter
  • 2018 American Business Awards Gold Stevie® Winner Badge for Best Payment and Electronic Commerce Solution
  • 2018 CNP Awards Customer Choice Winner Badge for Best E-Commerce Platform/Gateway
  • 2017 TSG Gateway Awards Winner Badge for Best Onboarding Process
  • Best in Biz Awards 2018 Silver Winner Badge for Business Development Department of the Year
BluePay Processing, LLC is a registered ISO of Wells Fargo Bank, N.A., Concord, CA, 94524 U.S.A.
BluePay Canada ULC, is a Registered ISO/MSP of Peoples Trust Company, Vancouver, Canada.