From ad8fb0eee76048775161fdb7a8389c4acf1e6de6 Mon Sep 17 00:00:00 2001 From: "B. Endres" Date: Sun, 24 May 2020 19:47:11 +0200 Subject: [PATCH] [#24] added option to drop twingle mandate reference --- CRM/Twingle/Form/Settings.php | 7 +++++++ api/v3/TwingleDonation/Submit.php | 6 ++++++ templates/CRM/Twingle/Form/Settings.hlp | 4 ++++ templates/CRM/Twingle/Form/Settings.tpl | 12 ++++++++++++ 4 files changed, 29 insertions(+) diff --git a/CRM/Twingle/Form/Settings.php b/CRM/Twingle/Form/Settings.php index b85fe5e..dba6a28 100644 --- a/CRM/Twingle/Form/Settings.php +++ b/CRM/Twingle/Form/Settings.php @@ -28,6 +28,7 @@ class CRM_Twingle_Form_Settings extends CRM_Core_Form { public static $SETTINGS_LIST = [ 'twingle_prefix', 'twingle_use_sepa', + 'twingle_dont_use_reference', 'twingle_protect_recurring', 'twingle_protect_recurring_activity_type', 'twingle_protect_recurring_activity_subject', @@ -54,6 +55,12 @@ class CRM_Twingle_Form_Settings extends CRM_Core_Form { E::ts("Use CiviSEPA") ); + $this->add( + 'checkbox', + 'twingle_dont_use_reference', + E::ts("Use CiviSEPA generated reference") + ); + $this->add( 'select', 'twingle_protect_recurring', diff --git a/api/v3/TwingleDonation/Submit.php b/api/v3/TwingleDonation/Submit.php index 57793d6..8828c82 100644 --- a/api/v3/TwingleDonation/Submit.php +++ b/api/v3/TwingleDonation/Submit.php @@ -604,6 +604,12 @@ function civicrm_api3_twingle_donation_Submit($params) { // mandate type. unset($mandate_data['payment_instrument_id']); + // If requested, let CiviSEPA generate the mandate reference + $use_own_mandate_reference = Civi::settings()->get('twingle_dont_use_reference'); + if (!empty($use_own_mandate_reference)) { + unset($mandate_data['reference']); + } + // Create the mandate. $mandate = civicrm_api3('SepaMandate', 'createfull', $mandate_data); diff --git a/templates/CRM/Twingle/Form/Settings.hlp b/templates/CRM/Twingle/Form/Settings.hlp index 8b5ef1b..7b82e7b 100644 --- a/templates/CRM/Twingle/Form/Settings.hlp +++ b/templates/CRM/Twingle/Form/Settings.hlp @@ -16,6 +16,10 @@ {ts domain="de.systopia.twingle" 1="CiviSEPA (org.project60.sepa) extension"}When the %1 is enabled and one of its payment instruments is assigned to a Twingle payment method (practically the debit_manual payment method), submitting a Twingle donation through the API will create a SEPA mandate with the given data.{/ts} {/htxt} +{htxt id='id-twingle_dont_use_reference'} + {ts domain="de.systopia.twingle" 1="CiviSEPA (org.project60.sepa) extension"}When the %1 is enabled, you can activate this to use your own references instead of the ones submitted by Twingle.{/ts} +{/htxt} + {htxt id='id-twingle_protect_recurring'} {ts domain="de.systopia.twingle"}Will protect all recurring contributions created by Twingle from termination, since this does NOT terminate the Twingle collection process{/ts} {/htxt} diff --git a/templates/CRM/Twingle/Form/Settings.tpl b/templates/CRM/Twingle/Form/Settings.tpl index 49d068e..e5fa54f 100644 --- a/templates/CRM/Twingle/Form/Settings.tpl +++ b/templates/CRM/Twingle/Form/Settings.tpl @@ -28,6 +28,18 @@ + + {$form.twingle_dont_use_reference.label}   + + {$form.twingle_dont_use_reference.html} +
+ + {$formElements.twingle_dont_use_reference.description} + + + + + {$form.twingle_prefix.label}