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,8 +1,8 @@
<?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 {
}
}

View file

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