If you still need it, try one of these three suggestions. 

The com object call is from Ryan Hickman.

I believe hex2bin function is from Roland Collins.  If it is someone else, I 
apologize.


Option 1 - GoogleCheckoutCFC
I updated the cfc so it *should* work with 6 now.
http://scott.pinkston.googlepages.com/home


Option 2 - COM Object:
Install the GCryptInstaller.MSI from the ASP sample code - 
http://code.google.com/apis/checkout/samplecode.html

<!--- Initiate the encryption object (make sure GCryptInstaller.MSI steps have 
been followed first) --->
<cfobject type = "com"
 action = "create"
 class = "GCrypt.g_crypt.2"
 name = "cryptobj">
 
<!---  HMACSHA1(input cart XML data as String, secret key as String)
- outputs base64 encoded binary string --->
<cfset  b64signature = 
cryptobj.generateSignature(GoogleCartXML,GoogleMerchantKey)>



Option 3:

You will need cf_hmac from:
http://devex.macromedia.com/developer/gallery/info.cfm?ID=B60D8F14-FC9F-11D6-840F00508B94F85A&method=Full


Add this function to your code:

<cffunction name="Hex2Bin" returntype="any" hint="Converts a Hex string to
binary">
<cfargument name="inputString" type="string" required="true"
hint="The hexadecimal string to be written.">

<cfset var outStream = CreateObject("java",
"java.io.ByteArrayOutputStream").init()>
<cfset var inputLength = Len(arguments.inputString)>
<cfset var outputString = "">
<cfset var i = 0>
<cfset var ch = "">

<cfif inputLength mod 2 neq 0>
<cfset arguments.inputString = "0" & inputString>
</cfif>

<cfloop from="1" to="#inputLength#" index="i" step="2">
<cfset ch = Mid(inputString, i, 2)>
<cfset outStream.write(javacast("int", InputBaseN(ch, 16)))>
</cfloop>

<cfset outStream.flush()>
<cfset outStream.close()>

<cfreturn outStream.toByteArray()>
</cffunction>


Call like this:
<!--- add your merchant key and your cart data --->
<cf_hmac key="--YOURMERCHANTKEY--" data="--YOURCARTXML--" hash_function="sha1">


<cfset b64signature = tobase64(hex2bin(digest))


<form 
action="https://sandbox.google.com/cws/v2/Merchant/--YOURMERCHANTID--/checkout"; 
method="post">
          <input type="hidden" name="cart" value="#toBase64(--YOURCARTXML--)#">
          <input type="hidden" name="signature" value="#b64signature#">
          <input type="image" name="Google Checkout" alt="Fast checkout through 
Google" 
src="http://checkout.google.com/buttons/checkout.gif?merchant_id=--YOURMERCHANTID--&w=180&h=46&style=white&variant=text&loc=en_US";
 height="46" width="180">
</form>


hope it helps

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:248769
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to