{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/comments/173754731","pull_request_review_id":102993378,"id":173754731,"diff_hunk":"@@ -0,0 +1,106 @@\n+package uk.gov.pay.directdebit.payments.model;\n+\n+import java.time.ZonedDateTime;\n+\n+public class GoCardlessEvent {\n+\n+    private Long id;\n+    private Long paymentRequestEventId;\n+    private String eventId;\n+    private String action;","path":"src/main/java/uk/gov/pay/directdebit/payments/model/GoCardlessEvent.java","position":10,"original_position":10,"commit_id":"b96f543778e6ab01c9f738b02e12d07d1278cf3c","original_commit_id":"b96f543778e6ab01c9f738b02e12d07d1278cf3c","user":{"login":"simad","id":5015118,"avatar_url":"https://avatars2.githubusercontent.com/u/5015118?v=4","gravatar_id":"","url":"https://api.github.com/users/simad","html_url":"https://github.com/simad","followers_url":"https://api.github.com/users/simad/followers","following_url":"https://api.github.com/users/simad/following{/other_user}","gists_url":"https://api.github.com/users/simad/gists{/gist_id}","starred_url":"https://api.github.com/users/simad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simad/subscriptions","organizations_url":"https://api.github.com/users/simad/orgs","repos_url":"https://api.github.com/users/simad/repos","events_url":"https://api.github.com/users/simad/events{/privacy}","received_events_url":"https://api.github.com/users/simad/received_events","type":"User","site_admin":false},"body":"because actions are specific to a resource type, and this probably will call for a slightly more complex design than just sticking an enum there. I figured we would tackle this when actually playing the stories to handle more actions, otherwise this story will be quite more complex than expected","created_at":"2018-03-12T10:48:31Z","updated_at":"2018-03-12T10:48:31Z","html_url":"https://github.com/alphagov/pay-direct-debit-connector/pull/68#discussion_r173754731","pull_request_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/comments/173754731"},"html":{"href":"https://github.com/alphagov/pay-direct-debit-connector/pull/68#discussion_r173754731"},"pull_request":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68"}},"in_reply_to_id":173459300},"pull_request":{"url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68","id":173155410,"html_url":"https://github.com/alphagov/pay-direct-debit-connector/pull/68","diff_url":"https://github.com/alphagov/pay-direct-debit-connector/pull/68.diff","patch_url":"https://github.com/alphagov/pay-direct-debit-connector/pull/68.patch","issue_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/68","number":68,"state":"open","locked":false,"title":"PP-2885 Support webhooks from GoCardless","user":{"login":"simad","id":5015118,"avatar_url":"https://avatars2.githubusercontent.com/u/5015118?v=4","gravatar_id":"","url":"https://api.github.com/users/simad","html_url":"https://github.com/simad","followers_url":"https://api.github.com/users/simad/followers","following_url":"https://api.github.com/users/simad/following{/other_user}","gists_url":"https://api.github.com/users/simad/gists{/gist_id}","starred_url":"https://api.github.com/users/simad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simad/subscriptions","organizations_url":"https://api.github.com/users/simad/orgs","repos_url":"https://api.github.com/users/simad/repos","events_url":"https://api.github.com/users/simad/events{/privacy}","received_events_url":"https://api.github.com/users/simad/received_events","type":"User","site_admin":false},"body":"## WHAT\r\nThis PR add supports for gocardless webhooks. For each webhook, we:\r\n- Verify its signature\r\n- Parse it and store the raw json in the database, so that we have a trail of everything we have received \r\n- Handle some events, log and ignore others\r\n\r\nParsing webhooks is pretty straightforward. A bit more troublesome is tracing\r\n  back to our transaction based on the id. GoCardless has something like:\r\n\r\n```\r\n\"links\": {\r\n        \"mandate\": \"MD123\"\r\n      }\r\n```\r\n  depending on the kind of resource we are dealing with.\r\n\r\nWe pick which events we want to handle, the others are ignored (but logged). Handling an event usually  mean logging + doing something with a charge, mostly updating its state.\r\n\r\n As a proof of concept, I picked the `CREATED` event for a mandate, and the `PAID_OUT` event\r\n  for a payment, and update the charge status accordingly. We will pick and handle more events in separate stories.\r\n\r\nI am not a fan of the overall design, I think the code is a bit too spaghetti for my liking -  it's the best I could do in a couple of days, and would gladly pair / get feedback and iterate on it.\r\n\r\nAlso, refactored a bit of stuff to use guice properly (we were mixing up guice / non guice and it was getting a bit of a mess)","created_at":"2018-03-06T13:19:08Z","updated_at":"2018-03-12T10:48:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aab5fa6860f461cab64b3383c920776d04245f20","assignee":{"login":"alexbishop1","id":24316348,"avatar_url":"https://avatars0.githubusercontent.com/u/24316348?v=4","gravatar_id":"","url":"https://api.github.com/users/alexbishop1","html_url":"https://github.com/alexbishop1","followers_url":"https://api.github.com/users/alexbishop1/followers","following_url":"https://api.github.com/users/alexbishop1/following{/other_user}","gists_url":"https://api.github.com/users/alexbishop1/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbishop1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbishop1/subscriptions","organizations_url":"https://api.github.com/users/alexbishop1/orgs","repos_url":"https://api.github.com/users/alexbishop1/repos","events_url":"https://api.github.com/users/alexbishop1/events{/privacy}","received_events_url":"https://api.github.com/users/alexbishop1/received_events","type":"User","site_admin":false},"assignees":[{"login":"alexbishop1","id":24316348,"avatar_url":"https://avatars0.githubusercontent.com/u/24316348?v=4","gravatar_id":"","url":"https://api.github.com/users/alexbishop1","html_url":"https://github.com/alexbishop1","followers_url":"https://api.github.com/users/alexbishop1/followers","following_url":"https://api.github.com/users/alexbishop1/following{/other_user}","gists_url":"https://api.github.com/users/alexbishop1/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbishop1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbishop1/subscriptions","organizations_url":"https://api.github.com/users/alexbishop1/orgs","repos_url":"https://api.github.com/users/alexbishop1/repos","events_url":"https://api.github.com/users/alexbishop1/events{/privacy}","received_events_url":"https://api.github.com/users/alexbishop1/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68/commits","review_comments_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68/comments","review_comment_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/68/comments","statuses_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/statuses/b96f543778e6ab01c9f738b02e12d07d1278cf3c","head":{"label":"alphagov:PP-2885_gocardless_events","ref":"PP-2885_gocardless_events","sha":"b96f543778e6ab01c9f738b02e12d07d1278cf3c","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":107574547,"name":"pay-direct-debit-connector","full_name":"alphagov/pay-direct-debit-connector","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/pay-direct-debit-connector","description":null,"fork":false,"url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector","forks_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/forks","keys_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/teams","hooks_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/hooks","issue_events_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/events","assignees_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/tags","blobs_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/languages","stargazers_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/stargazers","contributors_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/contributors","subscribers_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/subscribers","subscription_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/subscription","commits_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/merges","archive_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/downloads","issues_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/deployments","created_at":"2017-10-19T16:56:04Z","updated_at":"2017-10-30T11:34:49Z","pushed_at":"2018-03-08T16:51:38Z","git_url":"git://github.com/alphagov/pay-direct-debit-connector.git","ssh_url":"git@github.com:alphagov/pay-direct-debit-connector.git","clone_url":"https://github.com/alphagov/pay-direct-debit-connector.git","svn_url":"https://github.com/alphagov/pay-direct-debit-connector","homepage":null,"size":4312,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"ecbb2580e9f98a143768aa53f079b80133e20e3e","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":107574547,"name":"pay-direct-debit-connector","full_name":"alphagov/pay-direct-debit-connector","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars0.githubusercontent.com/u/596977?v=4","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/pay-direct-debit-connector","description":null,"fork":false,"url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector","forks_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/forks","keys_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/teams","hooks_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/hooks","issue_events_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/events","assignees_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/tags","blobs_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/languages","stargazers_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/stargazers","contributors_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/contributors","subscribers_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/subscribers","subscription_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/subscription","commits_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/merges","archive_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/downloads","issues_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/deployments","created_at":"2017-10-19T16:56:04Z","updated_at":"2017-10-30T11:34:49Z","pushed_at":"2018-03-08T16:51:38Z","git_url":"git://github.com/alphagov/pay-direct-debit-connector.git","ssh_url":"git@github.com:alphagov/pay-direct-debit-connector.git","clone_url":"https://github.com/alphagov/pay-direct-debit-connector.git","svn_url":"https://github.com/alphagov/pay-direct-debit-connector","homepage":null,"size":4312,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68"},"html":{"href":"https://github.com/alphagov/pay-direct-debit-connector/pull/68"},"issue":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/68"},"comments":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/issues/68/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/pulls/68/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/pay-direct-debit-connector/statuses/b96f543778e6ab01c9f738b02e12d07d1278cf3c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"simad"}}