Logging IPNs to `civicrm_system_log`
I spent a chunk of today looking to support logging IPNs to civicrm_system_log
for Stripe. Partway through, Matt told me that Jamie had already done this. I found the Stripe.populatelog
API, but it works differently than my approach, which more closely mirrors the existing workflows.
There's something to like about both approaches, and I'm thinking between the three of us we'll come up with the best approach.
My approach uses core's built-in IPN logging to log IPNs before passing to the extension. Jamie's approach is manual, and queries the Stripe API to populate the log.
The advantages to my approach are a) it's automatic, b) it's more shared code with core. I use nz.co.fuzion.notificationlog
to replay the IPNs, which is the practice for PayPal/Auth.net. However, logging before processing means you're generating an entry for EVERY event that hits the IPN endpoint.
The advantages of Jamie's approach are that you're only recording invoice.payment_succeeded
events, which is much less noise.
Do folks have thoughts about how to arrive at a best approach? I'm not experienced with Stripe, so I don't know if there's value in the other events that are published. It seems like automatic logging is feasible if we recommend a limited set of events for the webhook, but I'm not sure which events are relevant. Or perhaps we could have a scheduled job? It could either a) call Stripe.populatelog
, or b) we could log automatically, and the API call clears out unwanted events.