take into account the latest changes to the Twingle API

This commit is contained in:
Marc Michalsky 2024-06-15 11:36:12 +02:00
parent 65c7e668b3
commit beb9d8f170
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
2 changed files with 8 additions and 8 deletions

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* A simple custom exception that indicates a problem with the TwingleCampaign class * A simple custom exception that indicates a problem within the TwingleCampaign class
*/ */
class CRM_TwingleCampaign_Exceptions_TwingleCampaignException extends Exception { class CRM_TwingleCampaign_Exceptions_TwingleCampaignException extends Exception {

View file

@ -40,8 +40,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
$response_copy = $response; $response_copy = $response;
// Create soft credit for contribution // Create soft credit for contribution
if (array_key_exists('contribution', $response['values'])) { if (array_key_exists('contribution', $response)) {
$contribution = array_shift($response_copy['values']['contribution']); $contribution = array_shift($response_copy['contribution']);
if (array_key_exists('campaign_id', $contribution)) { if (array_key_exists('campaign_id', $contribution)) {
try { try {
$twingle_event = civicrm_api3( $twingle_event = civicrm_api3(
@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle', 'getsingle',
['id' => $contribution['campaign_id']] ['id' => $contribution['campaign_id']]
); );
$response['values']['soft_credit'] = $response['soft_credit'] =
self::createSoftCredit($contribution, $twingle_event)['values']; self::createSoftCredit($contribution, $twingle_event)['values'];
$event->setResponse($response); $event->setResponse($response);
} catch (CiviCRM_API3_Exception $e) { } catch (CiviCRM_API3_Exception $e) {
@ -58,8 +58,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
} }
} }
// Create soft credit for sepa mandate // Create soft credit for sepa mandate
elseif (array_key_exists('sepa_mandate', $response['values'])) { elseif (array_key_exists('sepa_mandate', $response)) {
$sepa_mandate = array_pop($response_copy['values']['sepa_mandate']); $sepa_mandate = array_pop($response_copy['sepa_mandate']);
try { try {
$contribution = civicrm_api3( $contribution = civicrm_api3(
@ -84,7 +84,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle', 'getsingle',
['id' => $contribution['contribution_campaign_id']] ['id' => $contribution['contribution_campaign_id']]
); );
$response['values']['soft_credit'] = $response['soft_credit'] =
self::createSoftCredit($contribution, $twingle_event)['values']; self::createSoftCredit($contribution, $twingle_event)['values'];
$event->setResponse($response); $event->setResponse($response);
} catch (CiviCRM_API3_Exception $e) { } catch (CiviCRM_API3_Exception $e) {