The instructions below will help you set up your GoCardless Account.

Step 1 - Create a Webhook Endpoint 

Before creating a Webhook endpoint, ensure that you have an account with GoCardless and can log in to the management area (https://manage.gocardless.com) and the sandbox area (https://manage-sandbox.gocardless.com/).
First create a test Webhook endpoint in your GoCardless sandbox. Once you have completed testing, create the live endpoint in your live GoCardless environment.

  1. Log in to GoCardless and then go to the Developers section.

  2. Under Create, select Webhook endpoint

  3. Type a name for the Webhook endpoint (e.g., Fonteva Sandbox Webhook).

  4. The URL needs to comprise two parts:

    1. Under Setup, select Communities to set up your Community. 

    2. This is immediately followed by the following: /services/apexrest/DDApi/directdebitepayment

  5. Click Create Webhook endpoint (without entering a secret - this will be generated for you) to create the Webhook in GoCardless and the Webhook Secret. 

  6. Save the Webhook Secret for creating the Configure GoCardless API Service Connection later. When you set up your live environment, add the Webhook endpoint that you create in your live environment in the same way. Before you go live, you will also need to arrange with GoCardless to migrate all your existing mandates onto their platform. To do this, you will need to export your current Direct Debit mandates with bank details into a spreadsheet template supplied by GoCardless. 

The Standard and Plus versions of GoCardless do not support paper-based mandates, whereas the Pro version does. If you are on the Standard or Plus version, all mandates will need to have an email address associated with them.

Step 2 - Install the UK Direct Debit App from Product Updates

In your Salesforce Org, go to Spark Framework.

  1. In the Spark Framework app, click Product Updates. This may force you to upgrade other packages as well. Speak to your support representative if you only want the links to support this package.

  2. Click Install for UK Direct DebitsYou will receive an email confirming that the application installed. 

  3. Run Field Level Security.

Use the Access Manager in Spark Framework to run Field Level Security (FLS) for your relevant profiles and all installed packages after installing a new app. This will ensure that all users receive the correct level of access to the relevant data fields in the system. The GoCardless integration runs under the Fonteva Guest User account, and it is important to grant this user edit access to the Scheduled_Payment and ePayment objects in order for GoCardless to be able to write back to Fonteva.

  1. In your Salesforce Org, go to Fonteva Framework. 

  2. On the Dashboard, select Access Manager.

  3. Deselect all packages except DDApi.

  4. Select Community Profile and Fonteva Customer Community Login User in the right column and then Fetch Profiles. If you are using custom profiles for the member portal, you will also need to grant these profiles permissions.

  5. Switch Object Permissions to on, and check all access levels up to Edit. Then Update Profiles


Step 3 - Configure the GoCardless API Service Connection. Configure the GoCardless API Service. 

  1. In your Salesforce Org, go to Fonteva Framework. 

  2. On the Dashboard, select API Services.

  3. Create a new API Service. The following are for sandbox connections only. Set up live connections separately when you have completed testing, with a different endpoint - https://api.gocardless.com).

    1. Client ID and Client Secret: Access your Client ID and Client Secret from your GoCardless account. Navigate to Developers > Partners, and select the App created. Copy the Client ID and Secret from there.

    2. API Service Key: GCApi 

    3. Display Name: GoCardless OAuth Only Connection

    4. Description: GoCardless Outbound connection OAuth Flow

    5. Endpointhttps://api-sandbox.gocardless.com (Note - this is different for live)

    6. Authentication Service: Framework.VendorAuthenticationService

    7. Auth TypeOAuth2



  4. Click Next to create the connection using the environment URLs below.

    1. Client ID: take from your GoCardless account.

    2. Client Secret: take from your GoCardless account.

    3. Scope: read_write

    4. Login Dialog URLhttps://connect-sandbox.gocardless.com/oauth/authorize

    5. Authorisation Code URLhttps://connect-sandbox.gocardless.com/oauth/access_token

    6. HTTP Method to Get Token: GET\

    7. Refresh Token URLhttps://connect-sandbox.gocardless.com/oauth/authorize

Live Environment Credentials:

The environment URLs above are only for sandbox environments. Contact your Fonteva support representative to get the Fonteva Client ID and Client Secret for your production environment, and use with the URLs below.

5. On the next tab, click Is Enabled and Save to finish the setup. This will create an API Service Connection as pictured below.

6. You can now link the API service connection to a Business Group. Note that once the API Service Connection is created, you can edit the connection Name to any meaningful name. In order to link a Business Group to a GoCardless API Service Connection, do the following:-

  • Open your Business Group record

  • Update the field, Direct Debit API Service Connection, to be the name of the API service connection that you created in the step above. (You may need to display this on the page layout.)

Multiple Business Groups:

If you have multiple business groups representing separate business entities, we recommend setting up separate GoCardless accounts for those Business Groups. Each GoCardless Account can then be linked back to the relevant business group using the name of the API Service Connection you crated in the step above.

You should follow the same steps to create a new API Service Connection for each new GoCardless Account (with its own bank account ) under the same API Services.

7. To further configure the API Service Connection, open the API Service Connection you created (click on the GCApi.Global link), the lower half of the screen should contain a number of pre-defined API Service Connection Configs.

You now need to add 4 values to these - click on New API Service Connection Config and create the outstanding configuration lines as per the table below. (Typically you will need to add values for OAuthState, RedirectURL, Secret_Webhook and HTTPMethodGetToken). The Secret_Webhook value will be the Secret that you created in Step 1 above and will be different for sandbox and live environments.

Name

Value

Is Masked

RedirectURL

https://login.salesforce.com/apex/DDApi__OAuthRedirect

(Note: sandbox is https://test.salesforce.com/apex/DDApi__OAuthRedirect)

false

HTTPMethodGetToken

POST

false

OAuthState

Your APIServiceConnection name (eg. GCApi.Global)

false

Secret_Webhook

'Webhook Endpoint Secret' (Created in GoCardless when you created the Webhook Endpoint - ensure it is masked and ensure that the webhook secret in GoCardless matches the Secret_Webhook in Fonteva)

true

Webhook_BatchSize

Create a new API Connection Configuration called "Webhook_BatchSize" with the custom batch size to process epayments on success.

If this value is not set or set to null/0, Default value is "200"

false

Step 4 - Log in and Authenticate to your own GoCardless Account

Go back to the new API Service Connection you created in your Salesforce org and click login from the dropdown for that connection using the arrow under ACTION. This is a one time login so that the system creates a permanent Access_Token which the system uses to make any future calls to GoCardless. 

Enter your own GoCardless username and password.

Troubleshooting connections (This step is not required for the set up - it is purely a debugging step if your connection is not working)

This is a one-time step required for Live and Sandbox connections. You should be redirected back to Spark after logging in.

To double-check that the authentication went through successfully and that a permanent token was created, you can view the access token.

In Salesforce, open the Developer Console and select Debug and Open Execute Anonymous Window.

Type the following into the text window and execute: 

Framework.Api.ServiceConnection serviceConnection; List<Framework.Api.ServiceConnection> conns = Framework.Api.getServiceConnections('GCApi'); for (Framework.Api.ServiceConnection conn : conns) {if (conn.configId == 'GCApi.Global') {serviceConnection = conn;}}if (serviceConnection != null) {System.debug(serviceConnection.accessToken);}

Replace GCApi.Global (or YourAPIServiceConnection) with your API name connection (as used in the business group).

On the Logs tab, select the Debug Only filter. The access token displays if one has been created.

Step 5 - Store Settings

To enable your store for Direct Debit purchases:

Navigate to your Store record.

Check the EnableDirect Debit checkbox.

The name of your Direct Debit API Service (e.g., GCApi.Global) should have been automatically populated in this field based on the store's business group.

You may need to add the EnableDirect Debit and Direct Debit API Service fields to your store page layout.

An Additional Custom Payment Type will have been automatically created once you select Enable Direct Debit on the store. In the related list for custom payment types, you should now see a Custom Payment type called Direct Debit.

Custom Payment Method Settings

You can change the options that will appear on the checkout for the user as to the day of the month when their Direct Debits will come out of their account.

To do this:

You can enforce the first payment to be via credit card by checking the Require Credit Card for First Payment checkbox.

Select Enable Start Date Options. This will allow you to open a day of the month multi-select window.

In the Direct Debit checkout process, the system will always take into consideration the earliest possible charge date for a mandate

The earliest charge date will always be 7 days from today.

If some of the configured days fall in a period which is sooner than the earliest charge date, then those configured days will be automatically displayed for the next month.

You may need to add these fields to the page layouts to view them.

Select the days of the month that you would like your members to be able to choose for their payments at checkout from the multiselect picklist. 

Save.

Step 6 - Site Settings

Override the Member Profile landing page (this is the member profile page that includes DD elements)

Navigate to Sites>yoursite

Override the Profile Page URL in Community Links section. Change the default value to .../DDApi__customprofile after xxx.force.com in the URL

Save.

Step 7 - Community Settings

Set up the default Community Home Page (this is the member profile page that includes DD elements)

Navigate to Setup>All Communities. Under your member community, select Workspaces>Administration.

Select Pages from the left hand navigation.

Set the Community Home > Visualforce Page  to customprofile. This will be an option in the search field and will have the DDApi namespace.

Save.

We are now ready to start Enabling Items for Direct Debit.