[#13] SEPA Code depedency (merged dev_13)
This commit is contained in:
commit
d6b90dcec2
5 changed files with 90 additions and 35 deletions
|
@ -627,20 +627,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
// enabled.
|
||||
if (
|
||||
CRM_Twingle_Submission::civiSepaEnabled()
|
||||
&& (
|
||||
(
|
||||
method_exists('CRM_Sepa_Logic_PaymentInstruments', 'isSDD')
|
||||
&& CRM_Sepa_Logic_PaymentInstruments::isSDD(array(
|
||||
'payment_instrument_id' => $payment_instrument['value'],
|
||||
))
|
||||
)
|
||||
|| (
|
||||
method_exists('CRM_Sepa_Logic_Settings', 'isSDD')
|
||||
&& CRM_Sepa_Logic_Settings::isSDD(array(
|
||||
'payment_instrument_id' => $payment_instrument['value'],
|
||||
))
|
||||
)
|
||||
)
|
||||
&& CRM_Twingle_Tools::isSDD($payment_instrument['value'])
|
||||
) {
|
||||
if (!isset(self::$_paymentInstruments['sepa'])) {
|
||||
self::$_paymentInstruments['sepa'] = E::ts('CiviSEPA');
|
||||
|
|
|
@ -55,7 +55,7 @@ class CRM_Twingle_Tools {
|
|||
'id' => $recurring_contribution_id]);
|
||||
|
||||
// check if this is a SEPA transaction
|
||||
//if (self::isSDD($recurring_contribution['payment_instrument_id'])) return;
|
||||
if (self::isSDD($recurring_contribution['payment_instrument_id'])) return;
|
||||
|
||||
// check if it's really a termination (i.e. current status is 2 or 5)
|
||||
if (!in_array($recurring_contribution['contribution_status_id'], [2,5])) return;
|
||||
|
@ -91,4 +91,41 @@ class CRM_Twingle_Tools {
|
|||
}
|
||||
return in_array($payment_instrument_id, $sepa_payment_instruments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a CiviSEPA mandate for the given contribution ID
|
||||
*
|
||||
* @param $contribution_id integer contribution ID *or* recurring contribution ID
|
||||
* @return integer mandate ID or null
|
||||
*/
|
||||
public static function getMandateFor($contribution_id) {
|
||||
$contribution_id = (int) $contribution_id;
|
||||
if ($contribution_id) {
|
||||
try {
|
||||
// try recurring mandate
|
||||
$rcur_mandate = civicrm_api3('SepaMandate', 'get', [
|
||||
'entity_id' => $contribution_id,
|
||||
'entity_table' => 'civicrm_contribution_recur',
|
||||
'type' => 'RCUR',
|
||||
]);
|
||||
if ($rcur_mandate['count'] == 1) {
|
||||
return reset($rcur_mandate['values']);
|
||||
}
|
||||
|
||||
// try OOFF mandate
|
||||
// try recurring mandate
|
||||
$ooff_mandate = civicrm_api3('SepaMandate', 'get', [
|
||||
'entity_id' => $contribution_id,
|
||||
'entity_table' => 'civicrm_contribution',
|
||||
'type' => 'OOFF',
|
||||
]);
|
||||
if ($ooff_mandate['count'] == 1) {
|
||||
return reset($ooff_mandate['values']);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
Civi::log()->debug("CRM_Twingle_Tools::getMandate failed for [{$contribution_id}]: " . $ex->getMessage());
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue