Permalink
Browse files

Added Z-Checkout Integration with Force.com

  • Loading branch information...
1 parent fdd8a6d commit 50ebbb24cf2f828f59b693918fb2bc47eae19f3e Tina Kung committed Jun 7, 2012
Showing with 1,661 additions and 1 deletion.
  1. +1 −1 HPMSampleCode/README
  2. +75 −0 ZCheckoutIntegration/README
  3. +16 −0 ZCheckoutIntegration/build.properties
  4. +8 −0 ZCheckoutIntegration/build.xml
  5. +25 −0 ZCheckoutIntegration/src/classes/CheckoutCallbackController.cls
  6. +5 −0 ZCheckoutIntegration/src/classes/CheckoutCallbackController.cls-meta.xml
  7. +35 −0 ZCheckoutIntegration/src/classes/CheckoutController.cls
  8. +5 −0 ZCheckoutIntegration/src/classes/CheckoutController.cls-meta.xml
  9. +47 −0 ZCheckoutIntegration/src/classes/ErrorCodeMapping.cls
  10. +15 −0 ZCheckoutIntegration/src/classes/ErrorCodeMapping.cls-meta.xml
  11. +21 −0 ZCheckoutIntegration/src/classes/HPMCallbackController.cls
  12. +15 −0 ZCheckoutIntegration/src/classes/HPMCallbackController.cls-meta.xml
  13. +167 −0 ZCheckoutIntegration/src/classes/HPMCallbackControllerTest.cls
  14. +15 −0 ZCheckoutIntegration/src/classes/HPMCallbackControllerTest.cls-meta.xml
  15. +2 −0 ZCheckoutIntegration/src/classes/HPMConfigException.cls
  16. +5 −0 ZCheckoutIntegration/src/classes/HPMConfigException.cls-meta.xml
  17. +123 −0 ZCheckoutIntegration/src/classes/HPMPostProcessController.cls
  18. +15 −0 ZCheckoutIntegration/src/classes/HPMPostProcessController.cls-meta.xml
  19. +59 −0 ZCheckoutIntegration/src/classes/HPMPostProcessControllerTest.cls
  20. +15 −0 ZCheckoutIntegration/src/classes/HPMPostProcessControllerTest.cls-meta.xml
  21. +36 −0 ZCheckoutIntegration/src/classes/HPMSampleController.cls
  22. +15 −0 ZCheckoutIntegration/src/classes/HPMSampleController.cls-meta.xml
  23. +158 −0 ZCheckoutIntegration/src/classes/HPMSampleControllerTest.cls
  24. +15 −0 ZCheckoutIntegration/src/classes/HPMSampleControllerTest.cls-meta.xml
  25. +114 −0 ZCheckoutIntegration/src/classes/ZCheckoutBaseCallbackController.cls
  26. +5 −0 ZCheckoutIntegration/src/classes/ZCheckoutBaseCallbackController.cls-meta.xml
  27. +171 −0 ZCheckoutIntegration/src/classes/ZCheckoutBaseController.cls
  28. +5 −0 ZCheckoutIntegration/src/classes/ZCheckoutBaseController.cls-meta.xml
  29. +47 −0 ZCheckoutIntegration/src/objects/HPM_Setting__c.object
  30. +14 −0 ZCheckoutIntegration/src/objects/Zuora__CustomerAccount__c.object
  31. +14 −0 ZCheckoutIntegration/src/objects/zqu__Quote__c.object
  32. +55 −0 ZCheckoutIntegration/src/package.xml
  33. +13 −0 ZCheckoutIntegration/src/pages/CheckoutCallback.page
  34. +5 −0 ZCheckoutIntegration/src/pages/CheckoutCallback.page-meta.xml
  35. +8 −0 ZCheckoutIntegration/src/pages/CheckoutConfirm.page
  36. +5 −0 ZCheckoutIntegration/src/pages/CheckoutConfirm.page-meta.xml
  37. +34 −0 ZCheckoutIntegration/src/pages/CheckoutSample.page
  38. +5 −0 ZCheckoutIntegration/src/pages/CheckoutSample.page-meta.xml
  39. +13 −0 ZCheckoutIntegration/src/pages/HPMCallBack.page
  40. +5 −0 ZCheckoutIntegration/src/pages/HPMCallBack.page-meta.xml
  41. +8 −0 ZCheckoutIntegration/src/pages/HPMConfirm.page
  42. +5 −0 ZCheckoutIntegration/src/pages/HPMConfirm.page-meta.xml
  43. +31 −0 ZCheckoutIntegration/src/pages/HPMSample.page
  44. +15 −0 ZCheckoutIntegration/src/pages/HPMSample.page-meta.xml
  45. +6 −0 ZCheckoutIntegration/src/pages/PaymentMethodConfirm.page
  46. +5 −0 ZCheckoutIntegration/src/pages/PaymentMethodConfirm.page-meta.xml
  47. +3 −0 ZCheckoutIntegration/src/pages/PaymentMethodCreation.page
  48. +10 −0 ZCheckoutIntegration/src/pages/PaymentMethodCreation.page-meta.xml
  49. +3 −0 ZCheckoutIntegration/src/pages/PaymentMethodCreationBillingAccount.page
  50. +15 −0 ZCheckoutIntegration/src/pages/PaymentMethodCreationBillingAccount.page-meta.xml
  51. +42 −0 ZCheckoutIntegration/src/staticresources/HPMSampleCSS.resource
  52. +5 −0 ZCheckoutIntegration/src/staticresources/HPMSampleCSS.resource-meta.xml
  53. BIN ZCheckoutIntegration/src/staticresources/HPMSubmitButton.resource
  54. +5 −0 ZCheckoutIntegration/src/staticresources/HPMSubmitButton.resource-meta.xml
  55. +97 −0 ZCheckoutIntegration/src/staticresources/postmessage_js.resource
  56. +5 −0 ZCheckoutIntegration/src/staticresources/postmessage_js.resource-meta.xml
View
@@ -48,7 +48,7 @@ INSTALLATION INSTRUCTIONS
1. Install this sample code package using the following Force.com Installation URL (Version 1.1):
-https://login.salesforce.com/packaging/installPackage.apexp?p0=04td0000000AEgw
+https://login.salesforce.com/packaging/installPackage.apexp?p0=04td0000000AFwd
This will install sample code unmanaged package into your Salesforce.com organization.
@@ -0,0 +1,75 @@
+/* Copyright (c) 2012 Zuora, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to use copy,
+ * modify, merge, publish the Software and to distribute, and sublicense copies of
+ * the Software, provided no fee is charged for the Software. In addition the
+ * rights specified above are conditioned upon the following:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * Zuora, Inc. or any other trademarks of Zuora, Inc. may not be used to endorse
+ * or promote products derived from this Software without specific prior written
+ * permission from Zuora, Inc.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * ZUORA, INC. BE LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+Zuora Z-Force Sample Code Package: Zuora Z-Checkout and Salesforce.com Integration Sample
+
+INTRODUCTION
+------------
+
+This sample implementation of Z-Checkout pages in Salesforce.com contains the following 3 scenarios:
+(1) Create a payment method from a Billing Account detail page
+(2) Create a payment method from Quote detail page that is associated with the quote that has been sent to Z-Billing.
+(3) Create a subscription from a particular rate plan through Z-Checkout page
+
+The newly created payment method will be set as the default payment method of the associated billing account, and "Auto-Pay" will be enabled for the associated billing account.
+The default payment method and the Auto-Pay information will be available on the Billing Account record in SFDC after the next SFDC Sync is run.
+
+PRE-REQUISITES
+-------------
+
+This sample code package is an unmanaged package that depends on the following Z-Force managed packages:
+- Z-Force 360 Version 2.2
+- Z-Force Quotes Version 5.3
+
+INSTALLATION INSTRUCTIONS
+-------------------------
+
+1. Install this sample code package using the following Force.com Installation URL (Version 1.1):
+
+https://login.salesforce.com/packaging/installPackage.apexp?p0=04td0000000AGnp
+
+This will install sample code unmanaged package into your Salesforce.com organization.
+
+CONFIGURATION INSTRUCTIONS
+--------------------------
+
+1. Add "New Payment Method" button onto the following Quote V5.0 Layouts:
+Quote Layout Default V5.0
+Quote Layout Amendment V5.0
+Quote Layout Renewal V5.0
+Quote Layout Default Read-only V5.0
+Quote Layout Amendment Read-only V5.0
+Quote Layout Renewal Read-only V5.0
+
+2. Add "New Payment Method" button onto the Billing Account Layouts.
+
+3. Follow the instructions on the following link to configure a Z-Payment Page in Zuora:
+http://knowledgecenter.zuora.com/C_Zuora_User_Guides/B_Commerce/Z-Payments_Page_User_Guide/Implementing_Z-Payments_Page_with_Salesforce.com/B_Create_a_Hosted_Payment_Page_in_Zuora
+
+4. Follow the instructions on the following link to configure Z-Payment settings in Salesforce.com organization:
+http://knowledgecenter.zuora.com/C_Zuora_User_Guides/B_Commerce/Z-Payments_Page_User_Guide/Implementing_Z-Payments_Page_with_Salesforce.com/C_Configure_the_Z-Payments_Page_Settings_in_Salesforce.com
+
+For more information on Salesforce.com and Z-Checkout integration please refer to the Z-Payment Pages chapter on Zuora knowledge center.
@@ -0,0 +1,16 @@
+# Specify the login credentials for the dev Salesforce organization
+sf.username=admin@samplecode.zuora.com
+sf.password=Agile#1234h8MJqLZFs2lohSOKDSU4tHI3
+#sf.username=tina.kung@29trialforce.com
+#sf.password=Agile#1234VZ7fVeGQGcfvmmm5VznaqGj3
+
+sf.devsrc=src
+sf.retrievesrc=src
+sf.namespace=
+sf.serverurl=https://www.salesforce.com
+
+sf.ga_namespace=Zuora
+sf.rc_src=rc_src
+sf.rc_namespace=z360ci01
+
+zforce.package.names=Zuora Z-Checkout and Salesforce.com Integration Sample Implementation
@@ -0,0 +1,8 @@
+<project name="zforce.sample.HPMSampleCode" default="" basedir="." xmlns:sf="antlib:com.salesforce">
+
+ <property file="build.properties" />
+ <property environment="env" />
+
+ <import file="../sample-imports.xml"/>
+
+</project>
@@ -0,0 +1,25 @@
+public with sharing class CheckoutCallbackController extends ZCheckoutBaseCallbackController{
+
+ public String accountId { get; set; }
+ public String firstName { get; set; }
+ public String lastName { get; set; }
+ public String email { get; set; }
+ public String subscriptionId { get; set; }
+ public String productId { get; set; }
+ public String productRatePlanId { get; set; }
+
+ public override void processCallbackParameters() {
+ super.processCallbackParameters();
+ this.accountId = callbackparameters.get('account_id');
+ this.firstName = callbackparameters.get('firstName');
+ this.lastName = callbackparameters.get('lastName');
+ this.email = callbackparameters.get('email');
+ this.subscriptionId = callbackparameters.get('subscriptionId');
+ this.productId = callbackparameters.get('productId');
+ this.productRatePlanId = callbackparameters.get('productRatePlanId');
+ }
+
+ public override String getCustomSettingName() {
+ return 'Z-Checkout';
+ }
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>24.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
@@ -0,0 +1,35 @@
+public with sharing class CheckoutController extends ZCheckoutBaseController {
+
+ public static String CUSTOM_SETTING_NAME = 'Z-Checkout';
+
+ public override String getCustomSettingName() {
+ return CUSTOM_SETTING_NAME;
+ }
+
+ @isTest
+ private static void testOnLoad() {
+ CheckoutController.prepareCustomSetting();
+ PageReference pageRef = Page.CheckoutSample;
+ System.Test.setCurrentPage(pageRef);
+ CheckoutController cc = new CheckoutController();
+ cc.onload();
+ }
+
+ @isTest
+ public static void prepareCustomSetting() {
+ HPM_Setting__c hpmsetting = HPM_Setting__c.getInstance( CheckoutController.CUSTOM_SETTING_NAME );
+ if (hpmsetting == null) hpmsetting = new HPM_Setting__c();
+ hpmsetting.Name = CheckoutController.CUSTOM_SETTING_NAME;
+ hpmsetting.HPM_Page_Id__c = 'page_id';
+ hpmsetting.HPM_Tenant_Id__c = '100';
+ hpmsetting.HPM_Security_Token__c = 'security_token';
+ hpmsetting.HPM_App_Url__c = 'www.zuora.com/service/a/27.0';
+ upsert hpmsetting;
+ }
+
+ @isTest
+ public static void removeCustomSetting() {
+ HPM_Setting__c hpmsetting = HPM_Setting__c.getInstance( CheckoutController.CUSTOM_SETTING_NAME );
+ if (hpmsetting != null) delete hpmsetting;
+ }
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>24.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
@@ -0,0 +1,47 @@
+/**
+ * This class holds the Error Code and Message Mapping, as well as Error Field Code and Name Mapping.
+ */
+public without sharing class ErrorCodeMapping {
+
+ /* Error code and message mapping */
+ public static Map<String, String> VALUES = new Map<String, String> {
+ /* HPM General Errors */
+ 'GeneralSystemError' => 'General system error(s) have occurred',
+ 'BusinessValidationError' => 'Business validation error(s) have occurred',
+ 'GatewayTransactionError' => 'Gateway transaction error(s) have occurred',
+ 'HostedPageFieldValidationError' => 'Field validation error(s) have occurred',
+
+ /* HPM Field Validation Errors */
+ 'NullValue' => 'Field is required but no value has been entered',
+ 'InvalidFormat' => 'Format of value does not match its definition',
+ 'ExceededMaxLength' => 'Length of value entered exceeds the maximum length',
+ 'InvalidCallbackSecurity' => 'The transaction is invalid',
+
+ /* SFDC Errors */
+ 'Sfdc.ErrorLoadingFrame' => 'An error occurred while loading Payment Method Page frame. ',
+ 'Sfdc.NoConfiguration' => 'There is no \"Zuora HPM Setting\" record found in HPM custom setting. Please create it first.',
+ 'Sfdc.InvalidConfiguration' => 'Please enter a valid value for the following field(s) in the HPM custom setting:',
+ 'Sfdc.InvalidField' => 'Please enter a valid value for the following field(s): ',
+ 'Sfdc.CannotFindAccountId' => 'There is no billing account associated with the payment method. ',
+ 'Sfdc.ZoqlError' => 'An error occurred while executing SOQL: ',
+ 'Sfdc.ErrorSettingDefaultPaymentMethod' => 'An error occurred while setting default payment method and autopay: '
+ };
+
+ /* Error field code and name mapping */
+ public static Map<String, String> ERROR_FIELD_MAPPING = new Map<String, String> {
+ 'errorField_creditCardType' => 'Card Type',
+ 'errorField_creditCardNumber' => 'Card Number',
+ 'errorField_creditCardExpirationMonth' => 'Expiration Month',
+ 'errorField_creditCardExpirationYear' => 'Expiration Year',
+ 'errorField_cardSecurityCode' => 'CVV',
+ 'errorField_creditCardHolderName' => 'Cardholder Name',
+ 'errorField_creditCardCountry' => 'Country',
+ 'errorField_creditCardAddress1' => 'Address 1',
+ 'errorField_creditCardAddress2' => 'Address 2',
+ 'errorField_creditCardCity' => 'City',
+ 'errorField_creditCardState' => 'State',
+ 'errorField_creditCardPostalCode' => 'Postal Code',
+ 'errorField_phone' => 'Contact Phone Number',
+ 'errorField_email' => 'Email Address'
+ };
+}
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>20.0</apiVersion>
+ <packageVersions>
+ <majorNumber>2</majorNumber>
+ <minorNumber>2</minorNumber>
+ <namespace>Zuora</namespace>
+ </packageVersions>
+ <packageVersions>
+ <majorNumber>5</majorNumber>
+ <minorNumber>3</minorNumber>
+ <namespace>zqu</namespace>
+ </packageVersions>
+ <status>Active</status>
+</ApexClass>
@@ -0,0 +1,21 @@
+public with sharing class HPMCallbackController extends ZCheckoutBaseCallbackController {
+
+ public override String getCustomSettingName() {
+ return 'Zuora HPM Setting';
+ }
+
+ public override void postProcess() {
+ HPMPostProcessController postProcessController = new HPMPostProcessController( this );
+ postProcessController.execute();
+ }
+
+ public String refId {
+ get;
+ set;
+ }
+ public override void processCallbackParameters() {
+ super.processCallbackParameters();
+ this.refId = callbackparameters.get('refId');
+ }
+
+}
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>23.0</apiVersion>
+ <packageVersions>
+ <majorNumber>2</majorNumber>
+ <minorNumber>2</minorNumber>
+ <namespace>Zuora</namespace>
+ </packageVersions>
+ <packageVersions>
+ <majorNumber>5</majorNumber>
+ <minorNumber>3</minorNumber>
+ <namespace>zqu</namespace>
+ </packageVersions>
+ <status>Active</status>
+</ApexClass>
Oops, something went wrong.

0 comments on commit 50ebbb2

Please sign in to comment.