{"action":"created","comment":{"url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/comments/50776861","id":50776861,"diff_hunk":"@@ -237,106 +271,78 @@ def billing_name\n       name\n     end\n \n-    # :validate => false, :email => false\n-    def purchase!(payment_details = nil, opts = {})\n-      opts = {validate: true, email: true, skip_buyer_validations: false}.merge(opts)\n-\n+    # Effective::Order.new(Product.first, user: User.first).purchase!(details: 'manual purchase')\n+    # order.purchase!(details: {key: value})\n+    def purchase!(details: 'none', provider: 'admin', card: 'none', validate: true, email: true, skip_buyer_validations: false)\n       return false if purchased?\n \n-      unless opts[:skip_buyer_validations] # An admin can mark purchased a declind order\n-        raise EffectiveOrders::AlreadyDeclinedException.new('order already declined') if (declined? && opts[:validate])\n+      unless skip_buyer_validations # An admin can mark purchased a declined order\n+        raise EffectiveOrders::AlreadyDeclinedException.new('order already declined') if (declined? && validate)\n       end\n \n       success = false\n \n-      Order.transaction do\n+      Effective::Order.transaction do\n         begin\n           self.purchase_state = EffectiveOrders::PURCHASED\n           self.purchased_at ||= Time.zone.now\n-          self.payment = payment_details.kind_of?(Hash) ? payment_details : {:details => (payment_details || 'none').to_s}\n \n-          save!(validate: opts[:validate])\n+          self.payment = details.kind_of?(Hash) ? details : { details: details.to_s }\n+          self.payment_provider = provider.to_s\n+          self.payment_card = card.to_s.presence || 'none'","path":"app/models/effective/order.rb","position":305,"original_position":305,"commit_id":"d98bfeca4c681839a60ff09ca3c406de18aa7994","original_commit_id":"d98bfeca4c681839a60ff09ca3c406de18aa7994","user":{"login":"matt-riemer","id":954468,"avatar_url":"https://avatars.githubusercontent.com/u/954468?v=3","gravatar_id":"","url":"https://api.github.com/users/matt-riemer","html_url":"https://github.com/matt-riemer","followers_url":"https://api.github.com/users/matt-riemer/followers","following_url":"https://api.github.com/users/matt-riemer/following{/other_user}","gists_url":"https://api.github.com/users/matt-riemer/gists{/gist_id}","starred_url":"https://api.github.com/users/matt-riemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matt-riemer/subscriptions","organizations_url":"https://api.github.com/users/matt-riemer/orgs","repos_url":"https://api.github.com/users/matt-riemer/repos","events_url":"https://api.github.com/users/matt-riemer/events{/privacy}","received_events_url":"https://api.github.com/users/matt-riemer/received_events","type":"User","site_admin":false},"body":"Future work:  Add `def normalize_card()` to normalize all the different payment processor return value into one consistent collection.","created_at":"2016-01-25T23:58:25Z","updated_at":"2016-01-25T23:58:25Z","html_url":"https://github.com/code-and-effect/effective_orders/pull/36#discussion_r50776861","pull_request_url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/comments/50776861"},"html":{"href":"https://github.com/code-and-effect/effective_orders/pull/36#discussion_r50776861"},"pull_request":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36","id":57150323,"html_url":"https://github.com/code-and-effect/effective_orders/pull/36","diff_url":"https://github.com/code-and-effect/effective_orders/pull/36.diff","patch_url":"https://github.com/code-and-effect/effective_orders/pull/36.patch","issue_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues/36","number":36,"state":"open","locked":false,"title":"Denormalize database","user":{"login":"matt-riemer","id":954468,"avatar_url":"https://avatars.githubusercontent.com/u/954468?v=3","gravatar_id":"","url":"https://api.github.com/users/matt-riemer","html_url":"https://github.com/matt-riemer","followers_url":"https://api.github.com/users/matt-riemer/followers","following_url":"https://api.github.com/users/matt-riemer/following{/other_user}","gists_url":"https://api.github.com/users/matt-riemer/gists{/gist_id}","starred_url":"https://api.github.com/users/matt-riemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matt-riemer/subscriptions","organizations_url":"https://api.github.com/users/matt-riemer/orgs","repos_url":"https://api.github.com/users/matt-riemer/repos","events_url":"https://api.github.com/users/matt-riemer/events{/privacy}","received_events_url":"https://api.github.com/users/matt-riemer/received_events","type":"User","site_admin":false},"body":"So this PR is a fairly big change:\r\n\r\nI have added the following database columns to Effective::Order model:   tax, subtotal, total, payment_provider, payment_card\r\n\r\nI have moved the following methods over to use keyword arguments:\r\n\r\nIn Effective::Order:  .new(), .add(), .purchase!(), .decline!()\r\nIn Effective::Cart:   .add(),\r\nIn EffectiveOrdersController:   order_purchased(),  order_declined()\r\n\r\nI have also changed some of the behavior with payment providers.  A payment provider is now responsible for passing `provider: 'moneris'` and `card: 'V'` to the `order_purchased` method.\r\n\r\nI have removed all the migrant validations in Effective::Order and turned them into rails3 style validations.\r\n\r\nI have added to the 'upgrade to rails 2.0' migration to upgrade any existing 1.0 app.\r\n\r\nI have re-written the Orders effective_datatable.  (There's currently a bug with the order_items column that will need to be squashed in effective_datatables itself).\r\n\r\n@andie-chernysh , I hope this doesn't mess you up TOO much on VTN.  I kind of feel bad about rewriting the datatable, as thats what I think will affect you most.  You're welcome to push back at me on these changes.\r\n\r\nI know these changes are a bit large in scope, but I feel that they clean up a lot of the mistakes made in effective_orders 1.0\r\n\r\nBefore 2.0 is launched, I'd still like to:  \r\n\r\n1.) remove the hard dependency on effective_obfuscation.  \r\n2.) remove the hard dependency on migrant\r\n3.) improve the README.md\r\n\r\nPlease give me your feedback on this PR!\r\n\r\n","created_at":"2016-01-25T23:55:24Z","updated_at":"2016-01-25T23:58:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fb279d6aea04e233ca760b0a34118436be2b713","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36/commits","review_comments_url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36/comments","review_comment_url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/comments{/number}","comments_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues/36/comments","statuses_url":"https://api.github.com/repos/code-and-effect/effective_orders/statuses/d98bfeca4c681839a60ff09ca3c406de18aa7994","head":{"label":"code-and-effect:denormalize-database","ref":"denormalize-database","sha":"d98bfeca4c681839a60ff09ca3c406de18aa7994","user":{"login":"code-and-effect","id":4742831,"avatar_url":"https://avatars.githubusercontent.com/u/4742831?v=3","gravatar_id":"","url":"https://api.github.com/users/code-and-effect","html_url":"https://github.com/code-and-effect","followers_url":"https://api.github.com/users/code-and-effect/followers","following_url":"https://api.github.com/users/code-and-effect/following{/other_user}","gists_url":"https://api.github.com/users/code-and-effect/gists{/gist_id}","starred_url":"https://api.github.com/users/code-and-effect/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-and-effect/subscriptions","organizations_url":"https://api.github.com/users/code-and-effect/orgs","repos_url":"https://api.github.com/users/code-and-effect/repos","events_url":"https://api.github.com/users/code-and-effect/events{/privacy}","received_events_url":"https://api.github.com/users/code-and-effect/received_events","type":"Organization","site_admin":false},"repo":{"id":14698633,"name":"effective_orders","full_name":"code-and-effect/effective_orders","owner":{"login":"code-and-effect","id":4742831,"avatar_url":"https://avatars.githubusercontent.com/u/4742831?v=3","gravatar_id":"","url":"https://api.github.com/users/code-and-effect","html_url":"https://github.com/code-and-effect","followers_url":"https://api.github.com/users/code-and-effect/followers","following_url":"https://api.github.com/users/code-and-effect/following{/other_user}","gists_url":"https://api.github.com/users/code-and-effect/gists{/gist_id}","starred_url":"https://api.github.com/users/code-and-effect/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-and-effect/subscriptions","organizations_url":"https://api.github.com/users/code-and-effect/orgs","repos_url":"https://api.github.com/users/code-and-effect/repos","events_url":"https://api.github.com/users/code-and-effect/events{/privacy}","received_events_url":"https://api.github.com/users/code-and-effect/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-and-effect/effective_orders","description":"Quickly build an online store with carts, orders, automatic email receipts and payment collection via Stripe, StripeConnect, PayPal and Moneris.","fork":false,"url":"https://api.github.com/repos/code-and-effect/effective_orders","forks_url":"https://api.github.com/repos/code-and-effect/effective_orders/forks","keys_url":"https://api.github.com/repos/code-and-effect/effective_orders/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-and-effect/effective_orders/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-and-effect/effective_orders/teams","hooks_url":"https://api.github.com/repos/code-and-effect/effective_orders/hooks","issue_events_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues/events{/number}","events_url":"https://api.github.com/repos/code-and-effect/effective_orders/events","assignees_url":"https://api.github.com/repos/code-and-effect/effective_orders/assignees{/user}","branches_url":"https://api.github.com/repos/code-and-effect/effective_orders/branches{/branch}","tags_url":"https://api.github.com/repos/code-and-effect/effective_orders/tags","blobs_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-and-effect/effective_orders/statuses/{sha}","languages_url":"https://api.github.com/repos/code-and-effect/effective_orders/languages","stargazers_url":"https://api.github.com/repos/code-and-effect/effective_orders/stargazers","contributors_url":"https://api.github.com/repos/code-and-effect/effective_orders/contributors","subscribers_url":"https://api.github.com/repos/code-and-effect/effective_orders/subscribers","subscription_url":"https://api.github.com/repos/code-and-effect/effective_orders/subscription","commits_url":"https://api.github.com/repos/code-and-effect/effective_orders/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-and-effect/effective_orders/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-and-effect/effective_orders/contents/{+path}","compare_url":"https://api.github.com/repos/code-and-effect/effective_orders/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-and-effect/effective_orders/merges","archive_url":"https://api.github.com/repos/code-and-effect/effective_orders/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-and-effect/effective_orders/downloads","issues_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues{/number}","pulls_url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls{/number}","milestones_url":"https://api.github.com/repos/code-and-effect/effective_orders/milestones{/number}","notifications_url":"https://api.github.com/repos/code-and-effect/effective_orders/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-and-effect/effective_orders/labels{/name}","releases_url":"https://api.github.com/repos/code-and-effect/effective_orders/releases{/id}","deployments_url":"https://api.github.com/repos/code-and-effect/effective_orders/deployments","created_at":"2013-11-25T21:12:19Z","updated_at":"2016-01-19T22:10:39Z","pushed_at":"2016-01-25T23:55:24Z","git_url":"git://github.com/code-and-effect/effective_orders.git","ssh_url":"git@github.com:code-and-effect/effective_orders.git","clone_url":"https://github.com/code-and-effect/effective_orders.git","svn_url":"https://github.com/code-and-effect/effective_orders","homepage":"","size":890,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":14,"default_branch":"master"}},"base":{"label":"code-and-effect:2.0","ref":"2.0","sha":"8d8c6ef7a184951b5a1b077561c615b976fb1350","user":{"login":"code-and-effect","id":4742831,"avatar_url":"https://avatars.githubusercontent.com/u/4742831?v=3","gravatar_id":"","url":"https://api.github.com/users/code-and-effect","html_url":"https://github.com/code-and-effect","followers_url":"https://api.github.com/users/code-and-effect/followers","following_url":"https://api.github.com/users/code-and-effect/following{/other_user}","gists_url":"https://api.github.com/users/code-and-effect/gists{/gist_id}","starred_url":"https://api.github.com/users/code-and-effect/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-and-effect/subscriptions","organizations_url":"https://api.github.com/users/code-and-effect/orgs","repos_url":"https://api.github.com/users/code-and-effect/repos","events_url":"https://api.github.com/users/code-and-effect/events{/privacy}","received_events_url":"https://api.github.com/users/code-and-effect/received_events","type":"Organization","site_admin":false},"repo":{"id":14698633,"name":"effective_orders","full_name":"code-and-effect/effective_orders","owner":{"login":"code-and-effect","id":4742831,"avatar_url":"https://avatars.githubusercontent.com/u/4742831?v=3","gravatar_id":"","url":"https://api.github.com/users/code-and-effect","html_url":"https://github.com/code-and-effect","followers_url":"https://api.github.com/users/code-and-effect/followers","following_url":"https://api.github.com/users/code-and-effect/following{/other_user}","gists_url":"https://api.github.com/users/code-and-effect/gists{/gist_id}","starred_url":"https://api.github.com/users/code-and-effect/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-and-effect/subscriptions","organizations_url":"https://api.github.com/users/code-and-effect/orgs","repos_url":"https://api.github.com/users/code-and-effect/repos","events_url":"https://api.github.com/users/code-and-effect/events{/privacy}","received_events_url":"https://api.github.com/users/code-and-effect/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-and-effect/effective_orders","description":"Quickly build an online store with carts, orders, automatic email receipts and payment collection via Stripe, StripeConnect, PayPal and Moneris.","fork":false,"url":"https://api.github.com/repos/code-and-effect/effective_orders","forks_url":"https://api.github.com/repos/code-and-effect/effective_orders/forks","keys_url":"https://api.github.com/repos/code-and-effect/effective_orders/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-and-effect/effective_orders/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-and-effect/effective_orders/teams","hooks_url":"https://api.github.com/repos/code-and-effect/effective_orders/hooks","issue_events_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues/events{/number}","events_url":"https://api.github.com/repos/code-and-effect/effective_orders/events","assignees_url":"https://api.github.com/repos/code-and-effect/effective_orders/assignees{/user}","branches_url":"https://api.github.com/repos/code-and-effect/effective_orders/branches{/branch}","tags_url":"https://api.github.com/repos/code-and-effect/effective_orders/tags","blobs_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-and-effect/effective_orders/statuses/{sha}","languages_url":"https://api.github.com/repos/code-and-effect/effective_orders/languages","stargazers_url":"https://api.github.com/repos/code-and-effect/effective_orders/stargazers","contributors_url":"https://api.github.com/repos/code-and-effect/effective_orders/contributors","subscribers_url":"https://api.github.com/repos/code-and-effect/effective_orders/subscribers","subscription_url":"https://api.github.com/repos/code-and-effect/effective_orders/subscription","commits_url":"https://api.github.com/repos/code-and-effect/effective_orders/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-and-effect/effective_orders/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-and-effect/effective_orders/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-and-effect/effective_orders/contents/{+path}","compare_url":"https://api.github.com/repos/code-and-effect/effective_orders/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-and-effect/effective_orders/merges","archive_url":"https://api.github.com/repos/code-and-effect/effective_orders/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-and-effect/effective_orders/downloads","issues_url":"https://api.github.com/repos/code-and-effect/effective_orders/issues{/number}","pulls_url":"https://api.github.com/repos/code-and-effect/effective_orders/pulls{/number}","milestones_url":"https://api.github.com/repos/code-and-effect/effective_orders/milestones{/number}","notifications_url":"https://api.github.com/repos/code-and-effect/effective_orders/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-and-effect/effective_orders/labels{/name}","releases_url":"https://api.github.com/repos/code-and-effect/effective_orders/releases{/id}","deployments_url":"https://api.github.com/repos/code-and-effect/effective_orders/deployments","created_at":"2013-11-25T21:12:19Z","updated_at":"2016-01-19T22:10:39Z","pushed_at":"2016-01-25T23:55:24Z","git_url":"git://github.com/code-and-effect/effective_orders.git","ssh_url":"git@github.com:code-and-effect/effective_orders.git","clone_url":"https://github.com/code-and-effect/effective_orders.git","svn_url":"https://github.com/code-and-effect/effective_orders","homepage":"","size":890,"stargazers_count":14,"watchers_count":14,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36"},"html":{"href":"https://github.com/code-and-effect/effective_orders/pull/36"},"issue":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/issues/36"},"comments":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/code-and-effect/effective_orders/statuses/d98bfeca4c681839a60ff09ca3c406de18aa7994"}}}}