Ga naar inhoud

Salesforce and FinDock hooks

Deze inhoud is nog niet vertaald.

The Salesforce client sends entries and payments to Salesforce through FinDock. Before sending an entry, it builds a payload from the Salesforce settings, and the filters below let you change nearly every part of it.

All cs_salesforce_findock_* filters receive the current value first, followed by the same context:

Parameter Type Description
$entry Entry|Payment The entry that is being sent.
$source string|null The source of the entry.
$type string The entry type: entry or payment.

The filters that only apply to payments (marked below) get extra parameters after these three. A payment has a $payment_type of one-time or recurring.

For the data that Salesforce objects receive, a “field list” is an associative array of Salesforce field API names and values, for example ['FirstName' => 'Jane', 'LastName' => 'Doe'].

Filter · includes/clients/class-salesforce.php

Filters the fields of the Salesforce settings page (cs-salesforce). Use it to add your own fields to that page. See Settings and admin hooks for the field options.

Parameter Type Description
$fields array The fields of the page, keyed by field key.

Returns: array — the fields.

add_filter('cs_salesforce_settings', function ($fields) {
$fields['MY_DEFAULT_CAMPAIGN'] = [
'title' => __('Default campaign', 'my-addon'),
'type' => 'text',
];
return $fields;
});

Filter · includes/clients/class-salesforce.php

Filters the origin that is sent with the entry, which tells FinDock where the entry came from.

Parameter Type Description
$origin string The origin. Default: CampaignSuite.
$entry Entry|Payment The entry.
$source string|null The source of the entry.
$type string The entry type.

Returns: string — the origin.

add_filter('cs_salesforce_findock_origin', function ($origin, $entry, $source, $type) {
return 'My Website';
}, 10, 4);

Filter · includes/clients/class-salesforce.php

Filters the FinDock processing type of the entry.

Parameter Type Description
$processing_type string The processing type. Default: an empty string, which sends none.
$entry Entry|Payment The entry.
$source string|null The source of the entry.
$type string The entry type.

Returns: string — the processing type.

add_filter('cs_salesforce_findock_processing_type', function ($processing_type, $entry, $source, $type) {
return 'Manual';
}, 10, 4);

Filter · includes/clients/class-salesforce.php

Filters the idempotency key of the entry. FinDock uses it to recognise a request it has already processed, so sending the same entry twice doesn’t create it twice.

Parameter Type Description
$key string The idempotency key. Default: an empty string, which sends none.
$entry Entry|Payment The entry.
$source string|null The source of the entry.
$type string The entry type.

Returns: string — the idempotency key.

add_filter('cs_salesforce_findock_idempotency_key', function ($key, $entry, $source, $type) {
return 'my-addon-' . $entry->get_id();
}, 10, 4);

cs_salesforce_findock_custom_inbound_report

Section titled “cs_salesforce_findock_custom_inbound_report”

Filter · includes/clients/class-salesforce.php

Provides the field list of the inbound report record (cpm__Inbound_Report__c) that FinDock creates for the entry. The result also passes through cs_salesforce_sobject_cpm__inbound_report__c.

Parameter Type Description
$fields array The field list. Default: an empty array.
$entry Entry|Payment The entry.
$source string|null The source of the entry.
$type string The entry type.

Returns: array — the field list.

add_filter('cs_salesforce_findock_custom_inbound_report', function ($fields, $entry, $source, $type) {
$fields['My_Source__c'] = $source;
return $fields;
}, 10, 4);

Filter · includes/clients/class-salesforce.php

Provides the field list of the Salesforce Contact that belongs to the entry. The result also passes through cs_salesforce_sobject_contact.

Parameter Type Description
$fields array The field list. Default: an empty array.
$entry Entry|Payment The entry.
$source string|null The source of the entry.
$type string The entry type.

Returns: array — the field list.

add_filter('cs_salesforce_findock_contact', function ($fields, $entry, $source, $type) {
return [
'FirstName' => $entry->get_meta_item('first_name'),
'LastName' => $entry->get_meta_item('last_name'),
'Email' => $entry->get_meta_item('email'),
];
}, 10, 4);

Filter · includes/clients/class-salesforce.php

Provides the field list of the Salesforce Account that belongs to the entry. The result also passes through cs_salesforce_sobject_account.

Parameter Type Description
$fields array The field list. Default: an empty array.
$entry Entry|Payment The entry.
$source string|null The source of the entry.
$type string The entry type.

Returns: array — the field list.

add_filter('cs_salesforce_findock_account', function ($fields, $entry, $source, $type) {
$fields['Name'] = $entry->get_meta_item('organisation');
return $fields;
}, 10, 4);

Filter · includes/clients/class-salesforce.php

Filters the record type name of the Contact.

Parameter Type Description
$record_type string The record type name. Default: an empty string, which sends none.
$entry Entry|Payment The entry.
$contact array The final Contact field list, after cs_salesforce_sobject_contact.
$source string|null The source of the entry.
$type string The entry type.

Returns: string — the record type name.

add_filter('cs_salesforce_findock_contact_record_type', function ($record_type, $entry, $contact, $source, $type) {
return 'Donor';
}, 10, 5);

Filter · includes/clients/class-salesforce.php

Filters the record type name of the Account.

Parameter Type Description
$record_type string The record type name. Default: an empty string, which sends none.
$entry Entry|Payment The entry.
$account array The final Account field list, after cs_salesforce_sobject_account.
$source string|null The source of the entry.
$type string The entry type.

Returns: string — the record type name.

add_filter('cs_salesforce_findock_account_record_type', function ($record_type, $entry, $account, $source, $type) {
return 'Organization';
}, 10, 5);

The filters in this section only run for entries of type payment.

Filter · includes/clients/class-salesforce.php

Filters the payment processor that FinDock uses for the payment. An empty value or default uses the default processor of the payment method.

Parameter Type Description
$processor string The processor name. Default: an empty string.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$payment_type string one-time or recurring.
$payment_method string The payment method of the payment.

Returns: string — the processor name.

add_filter('cs_salesforce_findock_payment_processor', function ($processor, $entry, $source, $type, $payment_type, $payment_method) {
return $payment_type === 'recurring' ? 'Adyen' : $processor;
}, 10, 6);

cs_salesforce_findock_payment_method_params_{payment_method}

Section titled “cs_salesforce_findock_payment_method_params_{payment_method}”

Filter · includes/clients/class-salesforce.php

Provides the parameters that are sent with the payment method. The dynamic part {payment_method} is the payment method of the payment. The result is the starting value of cs_salesforce_findock_payment_method_params.

Parameter Type Description
$params array The method parameters. Default: an empty array.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$processor string The payment processor from cs_salesforce_findock_payment_processor.

Returns: array — the method parameters.

add_filter('cs_salesforce_findock_payment_method_params_SEPA', function ($params, $entry, $source, $type, $processor) {
$params['iban'] = $entry->get_meta_item('iban');
return $params;
}, 10, 5);

cs_salesforce_findock_payment_method_params

Section titled “cs_salesforce_findock_payment_method_params”

Filter · includes/clients/class-salesforce.php

Filters the parameters that are sent with the payment method, for every payment method. It receives the result of cs_salesforce_findock_payment_method_params_{payment_method}.

Parameter Type Description
$params array The method parameters.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$processor string The payment processor.
$payment_method string The payment method.

Returns: array — the method parameters.

add_filter('cs_salesforce_findock_payment_method_params', function ($params, $entry, $source, $type, $processor, $payment_method) {
return $params;
}, 10, 6);

cs_salesforce_findock_payment_needs_initial

Section titled “cs_salesforce_findock_payment_needs_initial”

Filter · includes/clients/class-salesforce.php

Filters whether a recurring payment needs an initial payment. The default follows the configuration of the processor in FinDock. It only runs for recurring payments. If an initial payment is needed, the payment status stays at waiting until that is paid.

Parameter Type Description
$needs_initial bool Whether an initial payment is needed.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$payment_type string Always recurring here.
$payment_method string The payment method.
$processor string The payment processor.

Returns: bool — true when an initial payment is needed.

add_filter('cs_salesforce_findock_payment_needs_initial', function ($needs_initial, $entry, $source, $type, $payment_type, $payment_method, $processor) {
return $payment_method === 'Credit card' ? true : $needs_initial;
}, 10, 7);

cs_salesforce_findock_payment_immediately_paid

Section titled “cs_salesforce_findock_payment_immediately_paid”

Filter · includes/clients/class-salesforce.php

Filters whether the payment counts as paid the moment it is sent. By default this is true when the payment method is selected in the “Immediate collected payment methods” setting and no initial payment is needed. The result is stored on the entry.

Parameter Type Description
$immediately_paid bool Whether the payment counts as paid immediately.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$payment_type string one-time or recurring.
$payment_method string The payment method.
$processor string The payment processor.

Returns: bool — true when the payment counts as paid immediately.

add_filter('cs_salesforce_findock_payment_immediately_paid', function ($immediately_paid, $entry, $source, $type, $payment_type, $payment_method, $processor) {
return $immediately_paid;
}, 10, 7);

cs_salesforce_findock_custom_payment_initial

Section titled “cs_salesforce_findock_custom_payment_initial”

Filter · includes/clients/class-salesforce.php

Provides the field list of the initial payment record (a one-time payment object) of a recurring payment that needs an initial payment. When the list stays empty, an initial payment is requested without extra fields. The result also passes through cs_salesforce_sobject_{object} for the one-time payment object.

Parameter Type Description
$fields array The field list. Default: an empty array.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$payment_type string Always recurring here.
$processor string The payment processor.

Returns: array — the field list.

add_filter('cs_salesforce_findock_custom_payment_initial', function ($fields, $entry, $source, $type, $payment_type, $processor) {
$fields['My_Note__c'] = 'First payment of a donation';
return $fields;
}, 10, 6);

Filter · includes/clients/class-salesforce.php

Provides the field list of the payment record itself, which is the one-time or recurring payment object depending on the payment type. The result also passes through cs_salesforce_sobject_{object} for that object. If you leave the object’s campaign field empty, Core fills it with the entry’s campaign.

Parameter Type Description
$fields array The field list. Default: an empty array.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$payment_type string one-time or recurring.
$object_name string|null The API name of the payment object, from cs_salesforce_findock_payment_objects.

Returns: array — the field list.

add_filter('cs_salesforce_findock_custom_payment', function ($fields, $entry, $source, $type, $payment_type, $object_name) {
$fields['Appeal__c'] = $entry->get_meta_item('appeal');
return $fields;
}, 10, 6);

Filter · includes/clients/class-salesforce.php

Filters the ID of the destination (for example a fund or general accounting unit) of the payment. It runs when the payment object of the selected source connector has a destination field and the custom payment fields do not already fill it.

Parameter Type Description
$destination_id mixed The destination ID. Default: the destination ID that is stored on the entry, if any.
$entry Payment The payment.
$source string|null The source of the entry.
$type string The entry type, always payment.
$payment_type string one-time or recurring.

Returns: mixed — the ID of the destination record.

add_filter('cs_salesforce_findock_destination_id', function ($destination_id, $entry, $source, $type, $payment_type) {
return $destination_id ?: 'a0X000000000001AAA';
}, 10, 5);

Filter · includes/clients/class-salesforce.php

Filters the Salesforce object configuration for each FinDock source connector. The configuration that matches the selected source connector is used, and an unknown connector falls back to Default.

Parameter Type Description
$objects array The configurations keyed by connector. Built in: Converse-PayLink, PaymentHub, PaymentHub-for-NPSP, FinDock-for-Fundraising and Default. Each has one-time and recurring (with object, campaign_field and destination_field), default_objects (with destination) and record_types (Contact and Account, each with a default).
$source_connector string The selected source connector.

Returns: array — the configurations keyed by connector.

add_filter('cs_salesforce_findock_payment_objects', function ($objects, $source_connector) {
$objects['Default']['recurring']['object'] = 'My_Recurring__c';
return $objects;
}, 10, 2);

Filter · includes/clients/class-salesforce.php

Filters the field list of a Salesforce object just before it is sent. The dynamic part {object} is the API name of the object in lower case. It runs for every object that the cs_salesforce_findock_* filters provide. Known values:

  • cs_salesforce_sobject_contact and cs_salesforce_sobject_account for the Contact and the Account.
  • cs_salesforce_sobject_cpm__inbound_report__c for the inbound report.
  • The payment object of the selected source connector, for example cs_salesforce_sobject_cpm__installment__c, cs_salesforce_sobject_cpm__recurring_payment__c, cs_salesforce_sobject_soco__agreement__c, cs_salesforce_sobject_npe03__recurring_donation__c or cs_salesforce_sobject_giftcommitmentschedule.
Parameter Type Description
$fields array The field list.
$extra_data array entry (the entry) and, for payment objects, payment (the payment data that is built so far).

Returns: array — the field list.

add_filter('cs_salesforce_sobject_contact', function ($fields, $extra_data) {
$entry = $extra_data['entry'];
$fields['LeadSource'] = 'Website';
return $fields;
}, 10, 2);