{"action":"created","comment":{"url":"https://api.github.com/repos/codelandev/tribo-viva/pulls/comments/34520069","id":34520069,"diff_hunk":"@@ -0,0 +1,95 @@\n+class CheckoutsController < ApplicationController\n+  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized, except: :update\n+  protect_from_forgery except: :update\n+  before_action :store_location\n+\n+  def checkout\n+    authorize :checkout\n+  end\n+\n+  def process_payment\n+    authorize :checkout\n+\n+    # get payment method, if blank, it's credit card, if not, it's bank_slip\n+    param          = (params[:token].empty? ? \"method\" : \"token\").to_sym\n+    payment_method = params[:method] == '' ? 'credit_card' : 'bank_slip'\n+\n+    # initialize the purchase object\n+    purchase = current_user.purchases.create\n+    # Add all current items from cart to orders and purchase\n+    session[:shopping_cart].each do |item|\n+      offer = Offer.find(item['id'])\n+      order = Order.create(offer: offer,\n+                           purchase: purchase,\n+                           offer_value: offer.value,\n+                           quantity: item['quantity'])\n+    end\n+\n+    charge = Iugu::Charge.create({\n+      # here is where the method is determined, :token for CC or :method bank_slip\n+      param => params[param],\n+      email: current_user.email,","path":"app/controllers/checkouts_controller.rb","position":31,"original_position":31,"commit_id":"4beda504a5d637bd569900a300a373a9ad5c7e35","original_commit_id":"4beda504a5d637bd569900a300a373a9ad5c7e35","user":{"login":"ssjr","id":803887,"avatar_url":"https://avatars.githubusercontent.com/u/803887?v=3","gravatar_id":"","url":"https://api.github.com/users/ssjr","html_url":"https://github.com/ssjr","followers_url":"https://api.github.com/users/ssjr/followers","following_url":"https://api.github.com/users/ssjr/following{/other_user}","gists_url":"https://api.github.com/users/ssjr/gists{/gist_id}","starred_url":"https://api.github.com/users/ssjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssjr/subscriptions","organizations_url":"https://api.github.com/users/ssjr/orgs","repos_url":"https://api.github.com/users/ssjr/repos","events_url":"https://api.github.com/users/ssjr/events{/privacy}","received_events_url":"https://api.github.com/users/ssjr/received_events","type":"User","site_admin":false},"body":"ainda acho que devia dar opção pro usuário escolher esses campos (email e os do `payer`) no formulário de compra, pode ser outra pessoa a dona do cartão (poderia vir pré-preenchido, mas com opção do cara botar outros valores)","created_at":"2015-07-13T22:37:09Z","updated_at":"2015-07-13T22:37:09Z","html_url":"https://github.com/codelandev/tribo-viva/pull/15#discussion_r34520069","pull_request_url":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/codelandev/tribo-viva/pulls/comments/34520069"},"html":{"href":"https://github.com/codelandev/tribo-viva/pull/15#discussion_r34520069"},"pull_request":{"href":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15","id":39855934,"html_url":"https://github.com/codelandev/tribo-viva/pull/15","diff_url":"https://github.com/codelandev/tribo-viva/pull/15.diff","patch_url":"https://github.com/codelandev/tribo-viva/pull/15.patch","issue_url":"https://api.github.com/repos/codelandev/tribo-viva/issues/15","number":15,"state":"open","locked":false,"title":"Shopping Cart, Iugu Payment & more...","user":{"login":"patrickemuller","id":1644530,"avatar_url":"https://avatars.githubusercontent.com/u/1644530?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickemuller","html_url":"https://github.com/patrickemuller","followers_url":"https://api.github.com/users/patrickemuller/followers","following_url":"https://api.github.com/users/patrickemuller/following{/other_user}","gists_url":"https://api.github.com/users/patrickemuller/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickemuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickemuller/subscriptions","organizations_url":"https://api.github.com/users/patrickemuller/orgs","repos_url":"https://api.github.com/users/patrickemuller/repos","events_url":"https://api.github.com/users/patrickemuller/events{/privacy}","received_events_url":"https://api.github.com/users/patrickemuller/received_events","type":"User","site_admin":false},"body":"- Shopping cart\r\n- Iugu payment with credit card & bank slip\r\n- Purchase Mailers\r\n- Purchase updates from Iugu (webhooks)\r\n- Validations for credit card form\r\n...and more","created_at":"2015-07-13T21:00:31Z","updated_at":"2015-07-13T22:37:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dad969833b99ef5a65d583fd23f6e256d2843aa7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15/commits","review_comments_url":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15/comments","review_comment_url":"https://api.github.com/repos/codelandev/tribo-viva/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codelandev/tribo-viva/issues/15/comments","statuses_url":"https://api.github.com/repos/codelandev/tribo-viva/statuses/4beda504a5d637bd569900a300a373a9ad5c7e35","head":{"label":"codelandev:pm-payment-gateway-and-shopping-cart","ref":"pm-payment-gateway-and-shopping-cart","sha":"4beda504a5d637bd569900a300a373a9ad5c7e35","user":{"login":"codelandev","id":3528968,"avatar_url":"https://avatars.githubusercontent.com/u/3528968?v=3","gravatar_id":"","url":"https://api.github.com/users/codelandev","html_url":"https://github.com/codelandev","followers_url":"https://api.github.com/users/codelandev/followers","following_url":"https://api.github.com/users/codelandev/following{/other_user}","gists_url":"https://api.github.com/users/codelandev/gists{/gist_id}","starred_url":"https://api.github.com/users/codelandev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codelandev/subscriptions","organizations_url":"https://api.github.com/users/codelandev/orgs","repos_url":"https://api.github.com/users/codelandev/repos","events_url":"https://api.github.com/users/codelandev/events{/privacy}","received_events_url":"https://api.github.com/users/codelandev/received_events","type":"Organization","site_admin":false},"repo":{"id":35692178,"name":"tribo-viva","full_name":"codelandev/tribo-viva","owner":{"login":"codelandev","id":3528968,"avatar_url":"https://avatars.githubusercontent.com/u/3528968?v=3","gravatar_id":"","url":"https://api.github.com/users/codelandev","html_url":"https://github.com/codelandev","followers_url":"https://api.github.com/users/codelandev/followers","following_url":"https://api.github.com/users/codelandev/following{/other_user}","gists_url":"https://api.github.com/users/codelandev/gists{/gist_id}","starred_url":"https://api.github.com/users/codelandev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codelandev/subscriptions","organizations_url":"https://api.github.com/users/codelandev/orgs","repos_url":"https://api.github.com/users/codelandev/repos","events_url":"https://api.github.com/users/codelandev/events{/privacy}","received_events_url":"https://api.github.com/users/codelandev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codelandev/tribo-viva","description":"Plataforma de consumo colaborativo","fork":false,"url":"https://api.github.com/repos/codelandev/tribo-viva","forks_url":"https://api.github.com/repos/codelandev/tribo-viva/forks","keys_url":"https://api.github.com/repos/codelandev/tribo-viva/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codelandev/tribo-viva/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codelandev/tribo-viva/teams","hooks_url":"https://api.github.com/repos/codelandev/tribo-viva/hooks","issue_events_url":"https://api.github.com/repos/codelandev/tribo-viva/issues/events{/number}","events_url":"https://api.github.com/repos/codelandev/tribo-viva/events","assignees_url":"https://api.github.com/repos/codelandev/tribo-viva/assignees{/user}","branches_url":"https://api.github.com/repos/codelandev/tribo-viva/branches{/branch}","tags_url":"https://api.github.com/repos/codelandev/tribo-viva/tags","blobs_url":"https://api.github.com/repos/codelandev/tribo-viva/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codelandev/tribo-viva/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codelandev/tribo-viva/git/refs{/sha}","trees_url":"https://api.github.com/repos/codelandev/tribo-viva/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codelandev/tribo-viva/statuses/{sha}","languages_url":"https://api.github.com/repos/codelandev/tribo-viva/languages","stargazers_url":"https://api.github.com/repos/codelandev/tribo-viva/stargazers","contributors_url":"https://api.github.com/repos/codelandev/tribo-viva/contributors","subscribers_url":"https://api.github.com/repos/codelandev/tribo-viva/subscribers","subscription_url":"https://api.github.com/repos/codelandev/tribo-viva/subscription","commits_url":"https://api.github.com/repos/codelandev/tribo-viva/commits{/sha}","git_commits_url":"https://api.github.com/repos/codelandev/tribo-viva/git/commits{/sha}","comments_url":"https://api.github.com/repos/codelandev/tribo-viva/comments{/number}","issue_comment_url":"https://api.github.com/repos/codelandev/tribo-viva/issues/comments{/number}","contents_url":"https://api.github.com/repos/codelandev/tribo-viva/contents/{+path}","compare_url":"https://api.github.com/repos/codelandev/tribo-viva/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codelandev/tribo-viva/merges","archive_url":"https://api.github.com/repos/codelandev/tribo-viva/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codelandev/tribo-viva/downloads","issues_url":"https://api.github.com/repos/codelandev/tribo-viva/issues{/number}","pulls_url":"https://api.github.com/repos/codelandev/tribo-viva/pulls{/number}","milestones_url":"https://api.github.com/repos/codelandev/tribo-viva/milestones{/number}","notifications_url":"https://api.github.com/repos/codelandev/tribo-viva/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codelandev/tribo-viva/labels{/name}","releases_url":"https://api.github.com/repos/codelandev/tribo-viva/releases{/id}","created_at":"2015-05-15T19:18:57Z","updated_at":"2015-06-27T17:55:48Z","pushed_at":"2015-07-13T21:22:42Z","git_url":"git://github.com/codelandev/tribo-viva.git","ssh_url":"git@github.com:codelandev/tribo-viva.git","clone_url":"https://github.com/codelandev/tribo-viva.git","svn_url":"https://github.com/codelandev/tribo-viva","homepage":"http://triboviva.com.br","size":2260,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"codelandev:staging","ref":"staging","sha":"730341f0f877cd2ede99f28589e5b0f5cd9acaed","user":{"login":"codelandev","id":3528968,"avatar_url":"https://avatars.githubusercontent.com/u/3528968?v=3","gravatar_id":"","url":"https://api.github.com/users/codelandev","html_url":"https://github.com/codelandev","followers_url":"https://api.github.com/users/codelandev/followers","following_url":"https://api.github.com/users/codelandev/following{/other_user}","gists_url":"https://api.github.com/users/codelandev/gists{/gist_id}","starred_url":"https://api.github.com/users/codelandev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codelandev/subscriptions","organizations_url":"https://api.github.com/users/codelandev/orgs","repos_url":"https://api.github.com/users/codelandev/repos","events_url":"https://api.github.com/users/codelandev/events{/privacy}","received_events_url":"https://api.github.com/users/codelandev/received_events","type":"Organization","site_admin":false},"repo":{"id":35692178,"name":"tribo-viva","full_name":"codelandev/tribo-viva","owner":{"login":"codelandev","id":3528968,"avatar_url":"https://avatars.githubusercontent.com/u/3528968?v=3","gravatar_id":"","url":"https://api.github.com/users/codelandev","html_url":"https://github.com/codelandev","followers_url":"https://api.github.com/users/codelandev/followers","following_url":"https://api.github.com/users/codelandev/following{/other_user}","gists_url":"https://api.github.com/users/codelandev/gists{/gist_id}","starred_url":"https://api.github.com/users/codelandev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codelandev/subscriptions","organizations_url":"https://api.github.com/users/codelandev/orgs","repos_url":"https://api.github.com/users/codelandev/repos","events_url":"https://api.github.com/users/codelandev/events{/privacy}","received_events_url":"https://api.github.com/users/codelandev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codelandev/tribo-viva","description":"Plataforma de consumo colaborativo","fork":false,"url":"https://api.github.com/repos/codelandev/tribo-viva","forks_url":"https://api.github.com/repos/codelandev/tribo-viva/forks","keys_url":"https://api.github.com/repos/codelandev/tribo-viva/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codelandev/tribo-viva/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codelandev/tribo-viva/teams","hooks_url":"https://api.github.com/repos/codelandev/tribo-viva/hooks","issue_events_url":"https://api.github.com/repos/codelandev/tribo-viva/issues/events{/number}","events_url":"https://api.github.com/repos/codelandev/tribo-viva/events","assignees_url":"https://api.github.com/repos/codelandev/tribo-viva/assignees{/user}","branches_url":"https://api.github.com/repos/codelandev/tribo-viva/branches{/branch}","tags_url":"https://api.github.com/repos/codelandev/tribo-viva/tags","blobs_url":"https://api.github.com/repos/codelandev/tribo-viva/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codelandev/tribo-viva/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codelandev/tribo-viva/git/refs{/sha}","trees_url":"https://api.github.com/repos/codelandev/tribo-viva/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codelandev/tribo-viva/statuses/{sha}","languages_url":"https://api.github.com/repos/codelandev/tribo-viva/languages","stargazers_url":"https://api.github.com/repos/codelandev/tribo-viva/stargazers","contributors_url":"https://api.github.com/repos/codelandev/tribo-viva/contributors","subscribers_url":"https://api.github.com/repos/codelandev/tribo-viva/subscribers","subscription_url":"https://api.github.com/repos/codelandev/tribo-viva/subscription","commits_url":"https://api.github.com/repos/codelandev/tribo-viva/commits{/sha}","git_commits_url":"https://api.github.com/repos/codelandev/tribo-viva/git/commits{/sha}","comments_url":"https://api.github.com/repos/codelandev/tribo-viva/comments{/number}","issue_comment_url":"https://api.github.com/repos/codelandev/tribo-viva/issues/comments{/number}","contents_url":"https://api.github.com/repos/codelandev/tribo-viva/contents/{+path}","compare_url":"https://api.github.com/repos/codelandev/tribo-viva/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codelandev/tribo-viva/merges","archive_url":"https://api.github.com/repos/codelandev/tribo-viva/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codelandev/tribo-viva/downloads","issues_url":"https://api.github.com/repos/codelandev/tribo-viva/issues{/number}","pulls_url":"https://api.github.com/repos/codelandev/tribo-viva/pulls{/number}","milestones_url":"https://api.github.com/repos/codelandev/tribo-viva/milestones{/number}","notifications_url":"https://api.github.com/repos/codelandev/tribo-viva/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codelandev/tribo-viva/labels{/name}","releases_url":"https://api.github.com/repos/codelandev/tribo-viva/releases{/id}","created_at":"2015-05-15T19:18:57Z","updated_at":"2015-06-27T17:55:48Z","pushed_at":"2015-07-13T21:22:42Z","git_url":"git://github.com/codelandev/tribo-viva.git","ssh_url":"git@github.com:codelandev/tribo-viva.git","clone_url":"https://github.com/codelandev/tribo-viva.git","svn_url":"https://github.com/codelandev/tribo-viva","homepage":"http://triboviva.com.br","size":2260,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15"},"html":{"href":"https://github.com/codelandev/tribo-viva/pull/15"},"issue":{"href":"https://api.github.com/repos/codelandev/tribo-viva/issues/15"},"comments":{"href":"https://api.github.com/repos/codelandev/tribo-viva/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/codelandev/tribo-viva/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codelandev/tribo-viva/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/codelandev/tribo-viva/statuses/4beda504a5d637bd569900a300a373a9ad5c7e35"}}}}