Skip to main content

FinDock Payment API (v1 [OLD])

NOTE: This reference describes an integration with the v1 of the API. Ongoing development on this version has stopped. Please use our new and improved API v2!

The FinDock Payment API is a REST API used to initiate online transactions and/or submit recurring payments to the FinDock application residing in a Salesforce Org. The API aims to abstract away both Salesforce and FinDock configuration details for specific payment processors and methods. The API instead provides several informational resources to retrieve environment-specific parameters of a particular Salesforce implementation.

Getting Started

If you are just starting to work with the API, please see our Getting started with the Payment API article!

Salesforce Objects, RecordTypes and Custom Fields

Since our API is created for Salesforce implementations, there are some Salesforce-specific things to take into account. Alongside the primitive datatypes such as String, the Payment API uses several datatypes that might be unknown to you if you are not familiar with Salesforce or the Force.com platform. The data types that are only applied in Salesforce contexts are Salesforce Objects (sObjects) and Record Types and custom fields.

sObjects

sObjects are objects that can be stored in the Force.com platform database, and they are representations of data that persists in the Salesforce database. Some API resources accept, or even require, sObjects. The Payer object, for example, requires sObjects such as Contact and Account. The API allows you to define these objects in requests, as shown below, where both a Contact and an Account sObject are defined. FinDock objects like PaymentProfile can be used in the same way, but require you to specify the fields as custom fields.

Example body of a request for creating a Contact and an Account sObject

{
    "SuccessURL":"http://success.com",
    "FailureURL":"http://failure.com",
    "Payer":{
        "Contact":{
            "FirstName":"Eric",
            "LastName":"Johnson",
            "Email":"eric@johnson.com",
            "MailingStreet":"Rocket Rd",
            "MailingCity":"Hawthorne0",
            "MailingPostalCode":"CA 90250",
            "MobilePhone":"98989898"
        },
        "Account":{
            "Name":"Johnson Family",
            "Website":"www.spacex.com",
            "BillingStreet":"Rocket Rd",
            "BillingCity":"Hawthorne",
            "BillingPostalCode":"CA 90250"
        },
        "AccountRecordTypeName":"Household",
        "AccountUpdate":"Replace",
        "ContactUpdate":"Replace",
        "AllowDeduplication":true,
        "PrimaryRelation":"Contact"
    }
}

Record Types

Record types let Salesforce administrators offer different business processes, picklist values, and page layouts to different users. Organizations can, for example, differentiate between Account objects in Salesforce by assigning them either to the Record Type of Organization or Household. This facilitates the application of different types of page layouts or possible field values based on what Record Type an Account is. Your Salesforce Administrator can tell you more about the Record Types used in the Salesforce org.

Custom Fields

Salesforce allows administrators to add custom fields to objects in Salesforce. These fields can be seen in the Salesforce Object Manager of the Salesforce org setup. The API allows you to send Salesforce custom fields, and their corresponding values, as attributes in requests to the API.

Custom fields for standard Salesforce objects like Contact and Account are passed with "__c" at the end. For illustration, we have added the field TwitterHandle to the Salesforce Contact object.

TwitterHandle | TwitterHandle__c | Text(50)

{
  "Payer":{
    "Contact":{
      "FirstName":"Eric",
      "LastName":"Johnson",
      "TwitterHandle__c": "@EricJohnsonSalesforce"
    }
  }
}

Custom fields for custom FinDock objects like Payment and Recurring are passed in a CustomFields object.

{
  "Payment":{
    "Amount": 10.0,
    "CustomFields": {
      "Sales_Invoice__c": "a506E0000009TfL"
    }
  }
}

Authentication

Authentication is accomplished through an Oauth2.0 authorization flow. Each Salesforce environment requires its own token. A refresh token can be used to acquire a new access token if the current token has expired. Read more on how to authenticate to Salesforce in the Salesforce developer guide. Both client_secret and client_secret can be acquired from the Salesforce 'Setup' from a 'Connected App'.

  • The Authorization token can be passed as a Bearer token in the request Header.
  • To Acquire a new Authorization token with the returned Refresh token, please make sure to pass the right grant_type, client_id, client_secret and refresh_token as specified in the Salesforce documentation referenced above. To get up and running quickly, use the (unofficial-but-provided-by) Salesforce Postman Collection, as explained in this blog and look for the 'auth' folder.

Error and Response Codes

The API always returns the status 200, with a ResponseCode and an IsSuccess in the body. When IsSuccess = false, an Error object is returned.

Example of a successful request (to the SourceConnector Provisioning API):

{
    "ResponseCode": "001",
    "IsSuccess": true,
    "SourceConnectors": [
        {
            "Slug": "PaymentHub",
            "Name": "PaymentHub",
            "IsDefault": false
        }
    ]
}

Example of an error that is returned whenever an incorrect request is sent:

{
    "ResponseCode": "999",
    "IsSuccess": false,
    "Error": {
        "error_message": "Contact error: Required fields are missing: [LastName]",
        "error_code": "999"
    }
}

Full list of possible response codes:

ResponseCode Description
001 The request is processed successfully
010 Malformed request: missing one or more mandatory core parameter(s)
011 Malformed request: missing one or more mandatory Payment Processor parameters
012 Malformed request: missing one or more mandatory SourceConnector parameters
020 Invalid data: the supplied data is incorrect (e.g. an invalid e-mail address)
030 Deduplication error: the request failed because a deduplication rule prevented record creation and/or an update
040 Invalid API token provided
098 An object is missing and no default is specified
999 Error without specific category: consult the error_message for details

For more information on errors and response codes and debugging the API, please read our Troubleshooting the Payment API article.

Webhook on Payment Status

To receive updates on a created Payment with the /Payments endpoint, you can pass an endpoint URL in the WebhookURL parameter in the request body. If the status of the Payment (Installment record in Salesforce) changes, either by an update from a PSP or manually, you will receive a notification with the following body. The message contains the id, status, amount and other data of the original Payment request, as well as actual performed Payments related to the request.

To allow webhook notifications to be sent from FinDock, you need to add your URL to the Remote Site Setting of the Salesforce environment.

{
"Url": "/services/data/v36.0/sobjects/Installment__c/a083E00000AG04mQAD",
"Type": "Installment__c",
"Id": "a083E00000AG04mQAD",
"Target": "Target Name 1",
"Status": "Collected",
"Payments": [
    {
        "Url": "/services/data/v36.0/sobjects/Payment__c/a0R3E000008WvL9UAK",
        "Type": "Payment__c",
        "Id": "a0R3E000008WvL9UAK",
        "Target": "Target Name 1",
        "PaymentProcessor": "PaymentHub-Mollie",
        "PaymentMethod": "ideal",
        "CollectionDate": "2020-03-26",
        "Amount": 100
    }
],
"PaymentProcessor":"PaymentHub-Mollie",
"PaymentMethod": "ideal",
"Amount": 100
}

Payment Methods

Informational resource that returns a list of all available and active payment methods, and the active processors that have those payment methods enabled. Payment Methods range from Direct Debit, to Credit Card and various Online payments through Payment Service Providers (PSPs).

The Payment Methods object

Name
string

The name of the Payment Method, e.g. DirectDebit, CreditCard, Ideal.

Array of objects (Processor) [ items ]

Which Payment Processors can be used to perform payments with this Payment Method.

SupportsRecurring
boolean

Whether the Payment Method supports recurring payments.

Array of objects (Parameter) [ items ]

Additional parameters required to perform a payment with this Payment Method.

PaymentProfile
object (PaymentProfile)

The Payment Profile contains the financial details of the Contact or Account, that are required to perform a certain payment through the API, e.g. the Bank Account or a BACS Sort code. Whether a Payment Profile is required and what parameters should be passed can be found in our Payment Extension documentation.

{
  • "Name": "DirectDebit",
  • "Processors": [
    ],
  • "SupportsRecurring": true,
  • "Parameters": [
    ],
  • "PaymentProfile": {
    }
}

Retrieve Payment Methods

Return a list of payment methods configured in the Salesforce environment and related Payment Processors.

Responses

Response samples

Content type
application/json
Example
{
  • "ResponseCode": "001",
  • "IsSuccess": true,
  • "PaymentMethods": {
    }
}

Payment Processors

Informational resource that returns a list of all available and active payment processors that can be used to perform a payment, and the active payment methods which they support. A payment processor 'processes' the payment. Some Payment Processors require additional parameters to be passed. The API returns these with instructions in the 'Parameters' block in the response.

The Payment Processor object

Name
string

The name of the Payment Processor.

Array of objects (PaymentMethod) [ items ]

Which Payment Methods the Payment Processor supports.

IsDefault
boolean

Whether this is the default Payment Processor. If no Payment Processor is passed in the request, this Processor will be used to process the payment.

Array of objects (Target) [ items ]

All Targets that have been configured for this specific Payment Processor.

Array of objects (Parameter) [ items ]

Additional parameters that are required to perform a payment through this Payment Processor.

SupportsRecurring
boolean

Whether the Payment Processor supports recurring payments.

RequiresAuthorization
boolean

Whether this Payment Processor requires an initial transaction (Payment object) in a recurring payment request.

{
  • "Name": "PaymentHub-SEPA",
  • "PaymentMethods": "DirectDebit",
  • "IsDefault": true,
  • "Targets": [
    ],
  • "Parameters": [
    ],
  • "SupportsRecurring": false,
  • "RequiresAuthorization": true
}

Retrieve Payment Processors.

Return a list of payment processors configured in the Salesforce environment and related Payment Methods.

Responses

Response samples

Content type
application/json
Example
{
  • "ResponseCode": "001",
  • "IsSuccess": true,
  • "Processors": [
    ]
}

Source Connectors

Informational resource that returns the source connector used in a specific Salesforce environement. A source connector represents an application in Salesforce that will be used to ultimately store the transaction that is being initiated through the Payment API.

The Source Connector object

Name
string

The name of the Source Connector that will be used to register recurring payments and amounts receivable in Installments. e.g. 'PaymentHub', 'NPSP'. For a full list of available Source Connectors, visit the Source Connectors documentation.

Slug
string

The shortname of the source package.

IsDefault
boolean

Whether this is the default Source Connector. If no Source Connector is passed in the request, this Source Connector is used.

{
  • "Name": "PaymentHub",
  • "Slug": "PaymentHub",
  • "IsDefault": "true"
}

Retrieve Source Connectors.

Return a list of Source Connectors configured in the Salesforce environment.

Responses

Response samples

Content type
application/json
Example
{
  • "ResponseCode": "001",
  • "IsSuccess": true,
  • "SourceConnectors": [
    ]
}

Package Actions

Informational resource that returns the package actions possible and/or required for a certain Salesforce environment. Package actions are additional actions that can be performed for a specific FinDock Extension, like a payment extension or source connector. Package Actions can be used to perform additional actions in Salesforce through FinDock while making a Payment Request, like creating a record.

If a Payment Methods or Source Connector has a Package Action, these can be found in the specific Extension or Source Connector extension is an example of such a package.

The Package Actions object

PackageName
string

The name of the SourceConnector/Package for which the action is to be performed.

object

List of actions that can be performed.

{
  • "PackageName": "PaymentHub-GiftAid",
  • "actions": {
    }
}

Retrieve Package Actions.

Return a list of possible Package Actions for a specific Salesforce environment.

Responses

Response samples

Content type
application/json
Example
{
  • "ResponseCode": "001",
  • "IsSuccess": true,
  • "PackageActions": [
    ]
}

Payments

The /Payments endpoint allows for Payments to be made through a configured Salesforce environment and updates Salesforce data accordingly. The Payment API requires a 'Payment Method', 'Payment Processor' and 'Source Connector' to perform a successful request. The available Payment Method, Processors and Source Connectors for a specific Salesforce environment can be queried through their specific endpoints. Some Payment Methods enable or require further Package Actions. Be sure to include these in the request. It is also possible to perform Payments on existing Installments.

The Payments object

object (Payer)

Data on the paying party. Can be an existing or new Account and/or Contact.

object (Payment)

Data on new or existing Single Payment.

object (Recurring)

Data on new Recurring Payment.

object (PaymentMethod)

Data on how the Payment will be performed. Includes a.o. the Payment Method, Payment Processor, Target and additional Parameters required to perform the Payment.

object (SourceConnector)

Source Connector to be used to process the data in Salesforce.

Array of objects (PackageAction) [ items ]

A list of additional actions to be performed when making this request. More information about Package Actions can - if available - be found in our Extension and Source Connector documentation.

{
  • "Payer": {
    },
  • "Payment": {
    },
  • "Recurring": {
    },
  • "PaymentMethod": {
    },
  • "SourceConnector": {
    },
  • "PackageActions": [
    ]
}

Retrieve Payment Status

Returns the status of a specific payment. This can only be used to request the status of a one-off transaction. Recurring transactions are not supported.

path Parameters
ID
required
string

The unique GUID or Salesforce ID of the 'Installment' to retrieve.

Responses

Response samples

Content type
application/json
Example
{
  • "ResponseCode": "001",
  • "IsSuccess": true,
  • "Payment": {
    }
}

Create or update a single or recurring payment

The FinDock Payment API supports both one-time and recurring payments. To perform recurring payments, a 'Recurring' block replaces the 'Payment' block in the request. Some Payment Service Providers (PSPs) require an initial payment AND recurring payment in the same request for authorization of the transaction. You can find out whether this is the case for a specific Payment Processor through the GET /PaymentMethod and GET /PaymentProcessors endpoints. Please see the specific Payment Extension documentation on the details of performing a one-time and/or recurring payment. To perform payments on an existing Installment, simply remove the Payer block and add the InstallmentId to the Payment block.

Request Body schema: application/json
One of
SuccessURL
required
string <url> (SuccessURL)

The URL the user will be redirected to when a transaction has been completed successfully.

FailureURL
required
string <url> (FailureURL)

The URL the user will be redirected to when a transaction has failed or has been cancelled.

WebhookURL
string <url> (WebhookURL)

URL where you want to receive notifications on the status of the Payment request on. More information on the Webhook can be found here.

Origin
string (Origin)

Originating source of the API call. This can be used to add for instance a channel or an id.

required
object (PayerRequest)

Data on new or existing Single Payment. If an InstallmentId of an existing Salesforce record is provided in the Payment object, this object is no longer required in the request.

object (NewPaymentRequest)

Data on NEW Payment.

object (PaymentMethodRequest)

Data on how the Payment will be performed.

object (SourceConnectorRequest)

Source Connector to be used to process the data in Salesforce.

object (PackageActionRequest)

PackageAction object that specifies which additional actions need to be performed in Salesforce. PackageName, actions and Parameters need to be included.

Responses

Request samples

Content type
application/json
Example
{
  • "SuccessURL": "www.success.nl",
  • "FailureURL": "www.failure.nl",
  • "WebhookURL": "www.findock.com/api/endpoint",
  • "Origin": "Webform",
  • "Payer": {
    },
  • "Payment": {
    },
  • "PaymentMethod": {
    },
  • "SourceConnector": {
    },
  • "PackageActions": {
    }
}

Response samples

Content type
application/json
Example
{}