From 4d22095e8666e9824f7ae1f48cdfc450f7ad9c16 Mon Sep 17 00:00:00 2001 From: Martin Correll Date: Tue, 12 Nov 2024 10:33:42 +0100 Subject: [PATCH] NG Processor: Throws error for event payment #17 - The api wrapper for contribution completetransaction does not work so we use hook_postSave_civicrm_contribution() instead. --- CRM/Core/Payment/SDDNG.php | 5 +++++ sepapp.php | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CRM/Core/Payment/SDDNG.php b/CRM/Core/Payment/SDDNG.php index 582a540..9e645ea 100644 --- a/CRM/Core/Payment/SDDNG.php +++ b/CRM/Core/Payment/SDDNG.php @@ -220,6 +220,11 @@ public static function getPendingContributionID() return null; } + public static function setPendingContributionID(int $contribution_id) { + self::$_pending_mandate['contribution_id'] = $contribution_id; + self::$_pending_mandate['contributionID'] = $contribution_id; + } + public static function releasePendingMandateData($contribution_id) { if (!self::$_pending_mandate) { diff --git a/sepapp.php b/sepapp.php index b88c2ee..342248d 100644 --- a/sepapp.php +++ b/sepapp.php @@ -265,15 +265,25 @@ function sepapp_civicrm_postProcess($formName, &$form) throw new Exception("Couldn't find PaymentProcessorType [{$pp_id}]"); } } - } elseif ('CRM_Contribute_Form_Contribution_Confirm' == $formName) { - // post process the contributions created - CRM_Core_Payment_SDD::processPartialMandates(); - } elseif ('CRM_Event_Form_Registration_Confirm' == $formName) { + } elseif ('CRM_Contribute_Form_Contribution_Confirm' == $formName || 'CRM_Event_Form_Registration_Confirm' == $formName) { + // SDD: make sure mandate is created: + CRM_Core_Payment_SDDNGPostProcessor::createPendingMandate(); + // post process the contributions created CRM_Core_Payment_SDD::processPartialMandates(); } } +/** + * Implements hook_civicrm_postSave_[table_name]. + * + * We have to use this because comletetransaction apiWrapper does not work. + */ +function sepapp_civicrm_postSave_civicrm_contribution($dao) { + $contribution_id = $dao->id; + CRM_Core_Payment_SDDNG::setPendingContributionID($contribution_id); +} + /** * Will install the SEPA payment processor */