Commit eec39323 authored by mattwire's avatar mattwire

Return 200 OK and log instead of 400 bad request on webhooks when subscription...

Return 200 OK and log instead of 400 bad request on webhooks when subscription does not exist in CiviCRM so Authorize.net doesn't disable the webhook.
parent 5c8a9709
......@@ -98,7 +98,11 @@ class CRM_Core_Payment_AuthNetIPN {
// Set parameters required for IPN functions
if ($this->getParamFromResponse($response, 'is_recur')) {
$this->contribution_recur_id = $this->getRecurringContributionIDFromSubscriptionID($this->getParamFromResponse($response, 'subscription_id'));
$subscriptionID = $this->getParamFromResponse($response, 'subscription_id');
if (!$this->getRecurringContributionIDFromSubscriptionID($subscriptionID)) {
\Civi::log()->info($this->_paymentProcessor->getPaymentTypeLabel() . ": Could not find matching recurring contribution for invoice ID: {$subscriptionID}.");
return TRUE;
}
}
$this->event_date = $this->getParamFromResponse($response, 'trxn_date');
......@@ -305,9 +309,11 @@ class CRM_Core_Payment_AuthNetIPN {
}
/**
* @param $subscriptionID
* Map the subscription/invoiceID to the CiviCRM recurring contribution
*
* @return int
* @param string $subscriptionID
*
* @return FALSE|int
* @throws \CiviCRM_API3_Exception
*/
protected function getRecurringContributionIDFromSubscriptionID($subscriptionID) {
......@@ -315,9 +321,10 @@ class CRM_Core_Payment_AuthNetIPN {
'trxn_id' => $subscriptionID,
]);
if (empty($contributionRecur['id'])) {
$this->exception("Could not find matching contribution for invoice ID: {$subscriptionID}");
return FALSE;
}
return $contributionRecur['id'];
$this->contribution_recur_id = $contributionRecur['id'];
return $this->contribution_recur_id;
}
}
......@@ -3,6 +3,7 @@
## Configure Payment Processor
This extension provides two payment processors:
* Authorize.net (Credit Card).
* Authorize.net (eCheck.Net).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment