GoogleCheckoutCFC ******************************************************************************* Copyright (C) 2008 Scott Pinkston Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ******************************************************************************* Why: I needed it, there didn't seem to be one, and I might help one other person. The bin2hex call is from a Roland Collins post on cfcdev http://www.mail-archive.com/cfcdev@cfczone.org/msg11566.html If I missed the author or need to pull this - let me know. These files are meant to serve as a starting point for creating an open source set of components for intergration with Google Checkout. Required Files: ----------------------------------------- components/checkout.ini.cfm components/googlecheckout.cfc components/googlecheckoutresponsehandler.cfc components/orders.cfc tags/sha_1.cfm tags/hmac.cfm logs/general/logs.txt Sample Files: ----------------------------------------- sample_checkoutcart.cfm sample_responsehandler.cfm Getting Started: Unzip the files into a folder checkout.ini.cfm ------------------ The configuration file for checkout - leave the comment markers but change the variables. [google] ; You should not need to change these unless Google changes the URLs ; See http://code.google.com/apis/checkout/developer/index.html#validating_xml_messages ; for information sandboxURL=https://sandbox.google.com/api/checkout/v2/request/Merchant/ productionURL=https://checkout.google.com/api/checkout/v2/request/Merchant/ merchantid=12312 Your Merchant ID merchantkey=yourKey Your Merchant Key continueurl=https://yoursite.com The url to return to after checkout editcarturl=https://www.yoursite.com/cart The url to edit the cart, lets Google link back to this if the user wants to change their cart chargetax=true If you want to charge a tax statetochargetax=FL The Default State to charge the tax to taxrate=0.065 The rate of tax chargeshipping=false Shipping charges allowfreepickup=true demosite=true Set to false for live intergration, when set to true - sends form postings to the Google Sandbox ; True logs all responses sent from Google to googlemessages.log ; anything other than debug logs summary data ; logging=debug logs full XML responses ; a folder named the order number will be created under the logs location then ; a file will be created for each type of response type ; suggest logging=basic for production logging=debug ; set fullpath for log files, defaults to ./logs ; recommend moving to folder outside web root ; examples: /var/log/checkout ; c:\logs log_location=c:\logs Save the changes. To add the checkout button to your cart page, add the following code: #googleCart.CreateForm()# You can also pass in the a customer ID that will be passed back from google, #googleCart.CreateForm(custnumber)# It will be passed and returned in xml like this: #arguments.CustNumber# GetCartItems returns a query with the following fields: itemName,itemDesc,itemPrice,itemQuanity,total. The other piece is the handler or listener for the Google API callback URL. (Merchant site - Settings - Integration) Rename the sample_responsehandler.cfm to what suits you best, like checkout_responsehandler.cfm Set the url to https://yoursite.com/pathtofolder/sample_responsehandler.cfm (replace sample_responsehandler.cfm with the name your create in the above step) This file calls processXmlData() in googlecheckoutreponsehandler.cfc. The function takes the posted xml data from google and calls the function associated with the type of notification. I tried to name the functions the same as in the asp sample found on Google's site. The functions in the response handler by default do no actions, they are just placeholders. Just add your own actions. Scott Pinkston scott@scottpinkston.org