[#10] protect against SEPA double termination
This commit is contained in:
commit
c6cb61905a
1 changed files with 10 additions and 0 deletions
|
@ -87,6 +87,16 @@ function civicrm_api3_twingle_donation_endrecurring($params) {
|
||||||
time(),
|
time(),
|
||||||
date_create_from_format('Ymd', $params['cancelled_at'])->getTimestamp()
|
date_create_from_format('Ymd', $params['cancelled_at'])->getTimestamp()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// verify that the mandate has not been terminated in the past
|
||||||
|
$mandate_status = civicrm_api3('SepaMandate', 'getvalue', ['return' => 'status', 'id' => $mandate_id]);
|
||||||
|
if ($mandate_status != 'FRST' && $mandate_status != 'RCUR') {
|
||||||
|
throw new CiviCRM_API3_Exception(
|
||||||
|
E::ts("SEPA Mandate [%1] already terminated.", [1 => $mandate_id]),
|
||||||
|
'api_error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!CRM_Sepa_BAO_SEPAMandate::terminateMandate(
|
if (!CRM_Sepa_BAO_SEPAMandate::terminateMandate(
|
||||||
$mandate_id,
|
$mandate_id,
|
||||||
$end_date,
|
$end_date,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue