Project60 / org.project60.sepa

SEPA direct debit integration with civicrm
19 stars 46 forks source link

Implement proper error message when no default creditor is set #643

Open tobiberlin opened 1 year ago

tobiberlin commented 1 year ago

Follow up ticket for #638

When a new SEPA mandate is created but there is no default creditor set for the project there is no proper message what causes the process to fail.

For example:

    $sepaMandateData = [
      'contact_id' => $contactId,
      'type' => 'OOFF',
      'iban' => $iban,
      'amount' => $amount,
      'financial_type_id' => $financialTypeId,
      'creation_date' => $date),
    ];

    $result = civicrm_api3('SepaMandate', 'createfull', $sepaMandateData);

leads under these circumstances to a PHP warning in logs:

Warning: Undefined array key "creditor_id" in civicrm_api3_sepa_mandate_createfull() (line 81 of sites\default\files\civicrm\ext\org.project60.sepa\api\v3\SepaMandate.php).

and to an exception message:

FRST mandate for creditor ID [] disabled, i.e. no valid payment instrument set.

What solves the problem is to define a default creditor but these errors/warnings give not a proper hint for that.

bjendres commented 1 year ago

@tobiberlin Could you confirm that https://github.com/Project60/org.project60.sepa/commit/523670d49270002f1e2f48f782da0c0514ed7b7f works for you?