Skip to content

Instantly share code, notes, and snippets.

@thlinux1107
Last active April 23, 2021 13:05
Show Gist options
  • Save thlinux1107/4a3010159c191b30674e3ccd417c0b42 to your computer and use it in GitHub Desktop.
Save thlinux1107/4a3010159c191b30674e3ccd417c0b42 to your computer and use it in GitHub Desktop.
PayaGateway AccountUpdater 2.0 Request - ColdFusion
<cfsilent>
<cfset nonce = Right(ToString(rand("SHA1PRNG")),10)>
<cfset UnixStamp = left(getTickcount(), 10)>
<cfset Myurl = "https://api-cert.sagepayments.com/accountupdater/v1/accountupdater?startDate=2021-04-10&endDate=2021-04-12">
<cfset ToBeHashed = "GET" & "#Myurl#" & "417227771521" & "#nonce#" & "#UnixStamp#">
<cfset strHmac = hmac("#ToBeHashed#","iLzODV5AUsCGWGkr","HMACSHA512")>
<cfset Auth = binaryEncode(binaryDecode(strHmac, "hex"), "base64")>
<cfhttp url="#Myurl#" port="443" method="GET">
<cfhttpparam NAME="clientID" value="W8yvKQ5XbvAn7dUDJeAnaWCEwA4yXEgd" type="header" encoded="no" >
<cfhttpparam NAME="merchantID" value="417227771521" type="header" encoded="no">
<cfhttpparam NAME="merchantKey" value="I5T2R2K6V1Q3" type="header" encoded="no" >
<cfhttpparam NAME="nonce" value="#nonce#" type="header" encoded="no" >
<cfhttpparam NAME="timestamp" value="#UnixStamp#" type="header" encoded="no" >
<cfhttpparam NAME="Authorization" value="#Auth#" type="header" encoded="no" >
</cfhttp>
<cfset SResp = deserializeJSON(cfhttp.FileContent)>
</cfsilent>
<cfoutput>Authorization String: #ToBeHashed#</cfoutput><br>
<br>
<cfoutput>timestamp: #UnixStamp#</cfoutput><br>
<br>
<cfoutput>Auth: #Auth#</cfoutput><br>
<br>
<cfoutput>Nonce: #nonce#</cfoutput><br>
<br>
<cfdump var="#SResp#">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment