EndRecurring and Cancel API actions for recurring contributions and SEPA mandates.
This commit is contained in:
parent
e1fe2c23d3
commit
1dce43047b
2 changed files with 59 additions and 11 deletions
|
@ -82,7 +82,16 @@ function civicrm_api3_twingle_donation_EndRecurring($params) {
|
|||
&& CRM_Sepa_Logic_Settings::isSDD($contribution)
|
||||
) {
|
||||
$mandate_id = CRM_Sepa_Logic_Settings::getMandateFor($contribution['id']);
|
||||
if (!CRM_Sepa_BAO_SEPAMandate::terminateMandate($mandate_id, $params['ended_at'])) {
|
||||
// Mandates can not be terminated in the past.
|
||||
$end_date = date('Ymd', max(
|
||||
time(),
|
||||
date_create_from_format('Ymd', $params['cancelled_at'])->getTimestamp()
|
||||
));
|
||||
if (!CRM_Sepa_BAO_SEPAMandate::terminateMandate(
|
||||
$mandate_id,
|
||||
$end_date,
|
||||
E::ts('Mandate closed by TwingleDonation.EndRecurring API call')
|
||||
)) {
|
||||
throw new CiviCRM_API3_Exception(
|
||||
E::ts('Could not terminate SEPA mandate'),
|
||||
'api_error'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue