{"action":"created","comment":{"url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/comments/43740997","id":43740997,"diff_hunk":"@@ -45,8 +29,10 @@ def authorize!\n       resource_params += [API_KEY, API_SECRET] if order_url.match(/^https/)\n \n       resource = RestClient::Resource.new(*resource_params)\n+\n       resource.post(order_params) do |response|\n-        Response.new(response)\n+        success = response.code.to_s =~ /^2/","path":"models/klarna/purchase.rb","position":39,"original_position":39,"commit_id":"cedb5fdd48e213efafc93012d342b312e0adfcea","original_commit_id":"cedb5fdd48e213efafc93012d342b312e0adfcea","user":{"login":"yuval-netanel","id":2931327,"avatar_url":"https://avatars.githubusercontent.com/u/2931327?v=3","gravatar_id":"","url":"https://api.github.com/users/yuval-netanel","html_url":"https://github.com/yuval-netanel","followers_url":"https://api.github.com/users/yuval-netanel/followers","following_url":"https://api.github.com/users/yuval-netanel/following{/other_user}","gists_url":"https://api.github.com/users/yuval-netanel/gists{/gist_id}","starred_url":"https://api.github.com/users/yuval-netanel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuval-netanel/subscriptions","organizations_url":"https://api.github.com/users/yuval-netanel/orgs","repos_url":"https://api.github.com/users/yuval-netanel/repos","events_url":"https://api.github.com/users/yuval-netanel/events{/privacy}","received_events_url":"https://api.github.com/users/yuval-netanel/received_events","type":"User","site_admin":false},"body":"I think that 'code == 201' is more readable  ","created_at":"2015-11-03T12:14:12Z","updated_at":"2015-11-03T12:14:12Z","html_url":"https://github.com/klarna/sample-digital-goods-backend/pull/11#discussion_r43740997","pull_request_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/comments/43740997"},"html":{"href":"https://github.com/klarna/sample-digital-goods-backend/pull/11#discussion_r43740997"},"pull_request":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11","id":49547685,"html_url":"https://github.com/klarna/sample-digital-goods-backend/pull/11","diff_url":"https://github.com/klarna/sample-digital-goods-backend/pull/11.diff","patch_url":"https://github.com/klarna/sample-digital-goods-backend/pull/11.patch","issue_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/11","number":11,"state":"open","locked":false,"title":"Handles error on POST","user":{"login":"hadartng","id":5713621,"avatar_url":"https://avatars.githubusercontent.com/u/5713621?v=3","gravatar_id":"","url":"https://api.github.com/users/hadartng","html_url":"https://github.com/hadartng","followers_url":"https://api.github.com/users/hadartng/followers","following_url":"https://api.github.com/users/hadartng/following{/other_user}","gists_url":"https://api.github.com/users/hadartng/gists{/gist_id}","starred_url":"https://api.github.com/users/hadartng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadartng/subscriptions","organizations_url":"https://api.github.com/users/hadartng/orgs","repos_url":"https://api.github.com/users/hadartng/repos","events_url":"https://api.github.com/users/hadartng/events{/privacy}","received_events_url":"https://api.github.com/users/hadartng/received_events","type":"User","site_admin":false},"body":"* Handles error responses from the SDK calls.\r\n* Return the actual error code (instead of always 500 as we had until today) and message from Klarna.\r\n* That way - if the error is 500 (server error) - we can show the error page. Otherwise - handle accordingly (in invoice purchase for example - we will show the purchase with card step).","created_at":"2015-11-03T12:07:14Z","updated_at":"2015-11-03T12:14:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15c8c03274299e7e5d5999c487f6afa3ec9627c5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11/commits","review_comments_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11/comments","review_comment_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/11/comments","statuses_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/statuses/cedb5fdd48e213efafc93012d342b312e0adfcea","head":{"label":"klarna:error-handling-on-purchase","ref":"error-handling-on-purchase","sha":"cedb5fdd48e213efafc93012d342b312e0adfcea","user":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"repo":{"id":36366322,"name":"sample-digital-goods-backend","full_name":"klarna/sample-digital-goods-backend","owner":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/klarna/sample-digital-goods-backend","description":"A sample integration of Klarna's Digital Goods","fork":false,"url":"https://api.github.com/repos/klarna/sample-digital-goods-backend","forks_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/forks","keys_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/teams","hooks_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/hooks","issue_events_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/events{/number}","events_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/events","assignees_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/assignees{/user}","branches_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/branches{/branch}","tags_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/tags","blobs_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/languages","stargazers_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/stargazers","contributors_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/contributors","subscribers_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/subscribers","subscription_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/subscription","commits_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/contents/{+path}","compare_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/merges","archive_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/downloads","issues_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues{/number}","pulls_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/labels{/name}","releases_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/releases{/id}","created_at":"2015-05-27T12:47:44Z","updated_at":"2015-10-08T14:44:19Z","pushed_at":"2015-11-03T12:07:14Z","git_url":"git://github.com/klarna/sample-digital-goods-backend.git","ssh_url":"git@github.com:klarna/sample-digital-goods-backend.git","clone_url":"https://github.com/klarna/sample-digital-goods-backend.git","svn_url":"https://github.com/klarna/sample-digital-goods-backend","homepage":"http://ondemand-dg-playground.herokuapp.com/","size":405,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"base":{"label":"klarna:master","ref":"master","sha":"e9a178fc9b58263c8a4822f6699c3a1cb9455030","user":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"repo":{"id":36366322,"name":"sample-digital-goods-backend","full_name":"klarna/sample-digital-goods-backend","owner":{"login":"klarna","id":394540,"avatar_url":"https://avatars.githubusercontent.com/u/394540?v=3","gravatar_id":"","url":"https://api.github.com/users/klarna","html_url":"https://github.com/klarna","followers_url":"https://api.github.com/users/klarna/followers","following_url":"https://api.github.com/users/klarna/following{/other_user}","gists_url":"https://api.github.com/users/klarna/gists{/gist_id}","starred_url":"https://api.github.com/users/klarna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klarna/subscriptions","organizations_url":"https://api.github.com/users/klarna/orgs","repos_url":"https://api.github.com/users/klarna/repos","events_url":"https://api.github.com/users/klarna/events{/privacy}","received_events_url":"https://api.github.com/users/klarna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/klarna/sample-digital-goods-backend","description":"A sample integration of Klarna's Digital Goods","fork":false,"url":"https://api.github.com/repos/klarna/sample-digital-goods-backend","forks_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/forks","keys_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/teams","hooks_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/hooks","issue_events_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/events{/number}","events_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/events","assignees_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/assignees{/user}","branches_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/branches{/branch}","tags_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/tags","blobs_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/languages","stargazers_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/stargazers","contributors_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/contributors","subscribers_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/subscribers","subscription_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/subscription","commits_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/contents/{+path}","compare_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/merges","archive_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/downloads","issues_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues{/number}","pulls_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/labels{/name}","releases_url":"https://api.github.com/repos/klarna/sample-digital-goods-backend/releases{/id}","created_at":"2015-05-27T12:47:44Z","updated_at":"2015-10-08T14:44:19Z","pushed_at":"2015-11-03T12:07:14Z","git_url":"git://github.com/klarna/sample-digital-goods-backend.git","ssh_url":"git@github.com:klarna/sample-digital-goods-backend.git","clone_url":"https://github.com/klarna/sample-digital-goods-backend.git","svn_url":"https://github.com/klarna/sample-digital-goods-backend","homepage":"http://ondemand-dg-playground.herokuapp.com/","size":405,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11"},"html":{"href":"https://github.com/klarna/sample-digital-goods-backend/pull/11"},"issue":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/11"},"comments":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/klarna/sample-digital-goods-backend/statuses/cedb5fdd48e213efafc93012d342b312e0adfcea"}}}}