Problem/Motivation
The RecurlyPushListenerController code calls \Recurly_Account::get but doesn't pass the client object 2nd argument to the get method. And, because in this code path the client hasn't been initialized globally, the get call fails and the code throws an Recurly_UnauthorizedError error because there's no API key. And no valid client object.
Proposed resolution
Change the call from \Recurly_Account::get($notification->account->account_code);
to \Recurly_Account::get($notification->account->account_code, $this->recurlyClient);
Remaining tasks
This needs tests. Probably a Kernel test that makes an HTTP POST with the XML payload the recurly would normally send to the recurly webhook listener URL, which routes to RecurlyPushListenerController. Or something like that ... Given the way this reads from file_get_content('php://input') I'm not sure how to mock the payload from recurly otherwise.
Issue fork recurly-3346810
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
eojthebraveComment #4
eojthebraveI added a commit to the 4.x branch that fixes the bug so that push notifications can actually be processed now. However, I also noticed there are no tests for push notifications so it would be good to add some tests too.
Comment #5
eojthebraveComment #7
eojthebraveHere's an MR that adds tests for the push notification controller. I had to make one change to the code in the controller, switching from `file_get_contents('php://input')` to `$request->getContent()` to make it easier to mock the request. And, this is probably a more appropriate use of the Drupal request API anyway. This doesn't change anything about how this works for anyone's current implementations. Just adds tests.
Comment #9
eojthebrave