-
Notifications
You must be signed in to change notification settings - Fork 18
Recurring transactions not getting recorded in Civi #68
Comments
3 Dec 2019: Were you on 1.8 then, or 1.9beta2 - not sure when you upgraded to 1.9x? Note that a database upgrade was required by 1.9 (i.e. part of the extension upgrade process), but I don't think that's your problem. It's complaining that there's no The Payment Confirmed webhook sends a GoCardless subscription ID like SB0000000000001 This should match a Recurring Contribution record, and your logs suggest to me that this is found, since otherwise there would be an exception before the bit shown in your logs. The It then looks to see if there's a Pending Contribution for that Recurring Contribution (this is the case for the first contribution ever). This is not the case for the logged entry you've shared. So then we add some other data to the contribution template ( That API is finding a missing (I realise none of this is an answer to your problem, I'm just logging my investigation work.) |
You may want to join https://chat.civicrm.org/civicrm/channels/gocardless |
I assumed that this would be the case, as I see no other way for Civi to be able to match the Payment Confirmed webhook to any given recurring payment in Civi. However, looking at the content of the webhook sent by GC, I see no subscription ID mentioned. It seems to include only an event ID and payment ID, neither of which are of help to Civi. The Payment Created webhook includes the subscription ID (which would enable Civi to link it to an existing recurring contribution), and a payment ID (which would enable Civi to subsequently match a Payment Confirmed webhook to the payment. But from the GC extension log I can clearly see that the Payment Created webhook is ignored (as confirmed by the README). |
You're right. The payments.confirmed GC webhook provides a payment ID (like PM0000000001). This extension uses the GC API to look that up and obtain the subscription ID ( I can't account for this and I can't repeat it. I've checked three other sites and it's not happening on any of those. I can't immediately see that this would be related to the 1.9 - 1.91 gap, either, since that's an 12 day window max, and it's after the time things stopped working for you. More data would be needed. Do you have access to the command line cv program? Otherwise use the apiv3 explorer. Take one example where a payment was confirmed at GC but failed to be logged in Civi. Check if the payment exists in CiviCRM:
I'm assuming it does not. Look up the subscription ID using the GC website for that payment. Then look up the recurring contrib for that:
There should be one found. It should (must?!) have a Note the record ID for this contribution recur row (the
If there are none - I think this is a legit edge case that's perhaps not covered by the current release. |
OK. The first one I can find that failed and generated an error gives me no existing payment in Civi, and checking in the GC interface I can get a related subscription ID. Using that I find the recurring contribution record. |
Using:
I get the other contribution made by that contact using the same mandate (it's an annual payment). |
So for some reason the extension doesn't seem to be getting the subscription id from GC or if it is, it isn't then able to identify the contact id. |
Sorry, I think I accidentally put spaces around the
|
Yes, the other contribution that is linked to that subscription has
|
To sanity-check the API call...I'd add something like this (untested), resend the webhook, then remove this code again. (or comment it out). CRM_Core_Error::debug_log_message("Webhook $this->now Upperholme:\n" . json_encode(['gc_payment_id' => $payment->id, 'recur' => $recur, 'contribution' => $contribution], JSON_PRETTY_PRINT), FALSE, 'GoCardless', PEAR_LOG_INFO); Just before I'd also add CRM_Core_Error::debug_log_message("Webhook $this->now Upperholme2:\n" . json_encode(['recur' => $recur, 'contribution' => $contribution], JSON_PRETTY_PRINT), FALSE, 'GoCardless', PEAR_LOG_INFO); on the line before the repeattransaction call in Then in the dedicated GoCardless log file we can see exactly what's being picked up. From what you have said, we would expect to see the following in the bit tagged Upperholme
And in the bit tagged Upperholme2: you'd expect the recur to be the same as ↑ and the SuspicionsI suspect that the issue is to do with the new code around finding the "template contribution" to use in the repeattransaction call. The GoCardless extension uses the first Completed contribution related to the recurring contribution. The new core code does two: first it checks for a "template" contribution - I don't think these have been implemented yet ( This means there's possibly three sources of data for the new contribution. The new core code takes the |
That's brilliant. Thanks for taking the time to look at this. I'll check this out ASAP and feed back. |
Here's what got into the log file:
|
Hi @Upperholme clearly the extension is passing However, as of 1.9.2beta - which you can download from I'm using a different API call. Would you be OK to test this? Should you need to downgrade again, you can simply replace the codebase with the 1.9.1 version. |
Thanks. I'll give it a try and feed back with any news. |
1.9.2beta2 is giving me the same error when retrying the identical webhook as above. |
doh! |
Could you post your logs again? I want to see which (new) API call is made that triggers it - Payment.create or Contribution.create etc. |
Sure. I'll re-add the additional lines and post the log. |
I just meant the stack trace really |
|
Ug. So it's still the Contribution.repeattransaction call that's failing. I'm at a bit of a loss about what could be causing this. You might need to get some paid help in to look at exactly what's going on here. We need to hunt down each of the lines in the stack trace to see when |
It sounds like my case is not the norm? That makes me wonder about other extensions maybe getting in the way? I think I'll try maybe disabling other extensions to see if that might have an impact. The only things that have changed that I'm aware of is since early December - when it was all working - are updates to this extension and others, and updates to Civi and the CMS. |
So... like... pretty much everything! |
OK, fair point. But at least I've not been hacking away at core code. |
Update. After disabling and/or uninstalling various extensions I've now got my web hooks working properly again, thankfully. The culprit seems to be the Membership Extras extension - https://github.com/compucorp/uk.co.compucorp.membershipextras I had version 1.0b installed, and as far as I can see this had no negative impact on webhooks, but I'm guessing that it started causing issues after I updated CiviCRM. Disabling it seemed to make no difference, but after I uninstalled it everything started working. I see they've now released a stable version 2 of that extension which may have resolved the issue, although I'm not inclined to start experimenting with it right away, much preferring to have a system that actually works. Thanks again for taking the time to investigate. I'd be interested to hear of anyone using both extensions successfully. |
Glad you found a solution (and glad it wasn't a fault with this extension!). I'm closing this now. Suggest mattermost might be a place to ask about the two extensions together. |
Noting the problem with version 1.9 of the extension, I recently upgraded to 1.9.1, and have been checking my records against those in the GoCardless account, and I can see that no records of payments collected have been recorded in Civi since Dec 3 2019.
So I went into the list of webhooks that GC provides and began retrying from that date. The webhooks are sent and I can see that the extension is logging that fact. However, it is logging an error for the important webhooks (e.g. payment_confirmed. Here's an example of the log entry:
Any clues as to what might be happening here most welcome. I've since updated the Civi install from 5.21.1 to 5.21.2 in case that might help and will retry webhooks again.
The text was updated successfully, but these errors were encountered: