Project60 / org.project60.sepa

SEPA direct debit integration with civicrm
19 stars 46 forks source link

Alteration of recurring contributions from other payment processors #687

Open bastienho opened 1 year ago

bastienho commented 1 year ago

I figure a strange behavior, really hard to catch.

On an installation using many payment processors, the next_sched_contribution_date on contribution_recur is set with SEPA settings, even if it's not SEPA payments. This behavior is very annoying.

Its seems that sepa_civicrm_post considers every recurring contribution as "eligible" without verification of its payment processor.

/**
 * CiviCRM POST event: make sure the next collection date
 *   is adjusted according to the change
 */
function sepa_civicrm_post($op, $objectName, $objectId, &$objectRef) {
  if ($objectName == 'ContributionRecur' || $objectName == 'SepaMandate') {
    if ($op == 'create' || $op == 'edit') {
      if ($objectName == 'SepaMandate') {
        CRM_Sepa_Logic_NextCollectionDate::processMandatePostEdit($op, $objectName, $objectId, $objectRef);
      } else {
        CRM_Sepa_Logic_NextCollectionDate::processRecurPostEdit($op, $objectName, $objectId, $objectRef);
      }
    }
  }
}

Moreover, the mechanism updates the next_sched_contribution_date only if it is empty, but based on params sent to the civicrm_pre hook, which is not relevant in case of the update of partial data.

Is my assumption correct?

In that case, I suggest t:

bastienho commented 1 year ago

It seems related to #672