Payment failed and charge failed events cause a `Missing mandatory parameter: id` exception
Webhooks fail very often in certain installations with this error:
Missing mandatory parameter: id
The error is thrown by the MJWShared extension at this point:
// CRM_Core_Payment_MJWIPNTrait
private function updateContributionFailed($params) {
$this->checkRequiredParams('updateContributionFailed', ['id', 'trxn_date', 'order_reference'], $params);
/* ... */
}
Which is called with contribution_id
(instead of id
) from the charge.failed case:
$params = [
'contribution_id' => $this->contribution['id'],
'trxn_date' => $this->receive_date,
'cancel_reason' => $this->retrieve('failure_message', 'String'),
'trxn_id' => $this->charge_id,
'order_reference' => $this->invoice_id ?? $this->charge_id,
];
$this->updateContributionFailed($params);
and also from the invoice.payment_failed case:
$params = [
'contribution_id' => $this->contribution['id'],
'trxn_date' => $this->receive_date,
'cancel_reason' => $this->retrieve('failure_message', 'String'),
'trxn_id' => $this->charge_id,
'order_reference' => $this->invoice_id,
];
$this->updateContributionFailed($params);
Versions
- Stripe: 6.5
- MJWShared: 0.8.1
The issue has been observed in environments running on Drupal 7 but not in similar environments running on WordPress.