Get Code
Download the most recent patch titled googleCheckout.patch from OFBIZ-71
Apply the patch to your development deployment. This will create several folders and files under hot-deploy/googleCheckout
SSL
Since we will be consuming services from Google over secure socket layer (SSL) we will need to add two certificates from google to our trusted key store, otherwise our call to Google will fail with the following error:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Obtain and Compile InstallCert.java
Andreas Sterbenz created a small program that will obtain the ssl certificate from a website and place it into keystore in the current directory. There is probably an easier way of doing this. This is just the first answer I came across that worked.
- Download the program from Andreas's Blog.
- Compile
% javac InstallCert.java
Obtain SSL Certificates
- Obtain the SSL certificate for sandbox.google.com
% java InstallCert sandbox.google.com
- Obtain the SSL certificatate for checkout.google.com
% java InstallCert checkout.google.com
Export Certificates to file
- Export the certificate for sandbox.google.com from the keystore created by InstallCert
% keytool -export -file sandbox.cer -alias sandbox.google.com-1 -keystore jssecacerts -storepass changeit
- Export the certificate for checkout.google.com from the keystore created by InstallCert
% keytool -export -file checkout.cer -alias checkout.google.com-1 -keystore jssecacerts -storepass changeit
- Copy both certificates to framework/base/config/
% copy *.cer %OFBIZ_HOME%/framework/base/config
- Change into the correct directory
% cd %OFBIZ_HOME%/framework/base/config
Import Certificates into OFBiz Trust Store
- Import the certificate for sandbox.google.com into ofbiztrust.jks
% keytool -import -alias sandbox.google.com-1 -file sandbox.cer -keypass changeit -storetype jks -keystore ofbiztrust.jks -storepass changeit
- Import the certificate for checkout.google.com into ofbiztrust.jks
% keytool -import -alias sandbox.google.com-1 -file sandbox.cer -keypass changeit -storetype jks -keystore ofbiztrust.jks -storepass changeit
Configure
Configurations are don in hot-deploy/googlecheckout/config/googleCheckout.properties
##your merchantId - sandbox will be different than live
- merchantId - obtain from checkout.google.com/sell
- merchantKey - obtain from checkout.google.com/sell
- editCartUrl - OOTB, should be http://yourDomainName/ecommerce/control/viewcart
- continueShoppingUrl - should be http://yourDomainName/ecommerce
- xmlTemplateUri - default should work, if you want to change the screen, this makes it easier
- requestPhone - true/false do you want to make a phone number mandatory in order to place an order
- ##Production URL
- #basePostUrl = https://checkout.google.com/cws/v2/Merchant/
- this has changed since the last patch
- ##Sandbox URL
- basePostUrl = https://sandbox.google.com/checkout/cws/v2/Merchant/
- checkout - currently not implemented
- request - should not be changed
- diagnose = currently not implemented
Use
- After updating the properties file, restart OFBiz
- in your ecomerce application, create a request-uri; for example:
<request-map uri="google"> <security auth="false" https="false"/> <event type="service" invoke="transmitRequest"/> <response type="view" name="success" value="google"/> </request-map>
- create a view-map that points to the redirect screen in the google component:
<view-map name="google" type="screen" page="component://googlecheckout/widget/GoogleCheckoutScreens.xml#redirect"/>
- place an link with the google checkout button that points to your google uri next to where ever you have a checkout link
<a href="<@ofbizUrl>google</@ofbizUrl>"><img src="googleButton.gif"/></a>
2 Comments
Jacques Le Roux
If you think some files are missing please have a look in https://issues.apache.org/jira/browse/OFBIZ-71. you will maybe have to update though...
Unknown User (bjfree@free-man.net)
Note: that ofbiztrust.jks is now ofbizssl.jks