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.py
Or, download via GitHub

##
     # BluePay Python 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.
    ##
from __future__ import print_function
import os.path, sys
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
from BluePay import BluePay
import cgi

vars = cgi.FieldStorage()

account_id = "Merchant's Account ID Here"
secret_key = "Merchant's Secret Key Here"
mode = "TEST" 

tps = BluePay(
    account_id = account_id,
    secret_key = secret_key,
    mode = mode
)

try:
    # Assign values
    trans_id = vars["trans_id"]
    trans_status = vars["trans_status"]
    trans_type = vars["trans_type"]
    amount = vars["amount"]
    rebill_id = vars["rebill_id"]
    rebill_amount = vars["reb_amount"]
    rebill_status = vars["status"]
    tps_hash_type = vars["TPS_HASH_TYPE"]
    bp_stamp = vars["BP_STAMP"]
    bp_stamp_def = vars["BP_STAMP_DEF"]

    # Calculate expected bp_stamp
    bp_stamp_string = ''
    for field in bp_stamp_def.value.split(' '):
        bp_stamp_string += vars[field].value

    expected_stamp = tps.create_tps_hash(bp_stamp_string, tps_hash_type.value).upper()

    # check if expected bp_stamp = actual bp_stamp
    if exepcted_stamp == bp_stamp:

        # Get response from BluePay
        print('Transaction ID: ' + trans_id)
        print('Transaction Status: ' + trans_status)
        print('Transaction Type: ' + trans_type)
        print('Transaction Amount: ' + amount)
        print('Rebill ID: ' + rebill_id)
        print('Rebill Amount: ' + rebill_amount)
        print('Rebill Status: ' + rebill_status)
    else:
        print('ERROR IN RECEIVING DATA FROM BLUEPAY')
except KeyError:
    print("ERROR")
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.