{"action":"created","comment":{"url":"https://api.github.com/repos/crdschurch/crds-angular/pulls/comments/84505531","pull_request_review_id":5282003,"id":84505531,"diff_hunk":"@@ -0,0 +1,72 @@\n+﻿using System;\n+using System.Linq;\n+using crds_angular.Exceptions;\n+using crds_angular.Models.Crossroads.Payment;\n+using crds_angular.Services.Interfaces;\n+using Crossroads.Utilities.Interfaces;\n+using MinistryPlatform.Translation.Models.Payments;\n+using MinistryPlatform.Translation.Repositories.Interfaces;\n+\n+namespace crds_angular.Services\n+{\n+    public class PaymentService : IPaymentService\n+    {\n+        private readonly IInvoiceRepository _invoiceRepository;\n+        private readonly IPaymentRepository _paymentRepository;\n+        private readonly IConfigurationWrapper _configurationWrapper;\n+\n+        public PaymentService(IInvoiceRepository invoiceRepository, IPaymentRepository paymentRepository, IConfigurationWrapper configurationWrapper)\n+        {\n+            _invoiceRepository = invoiceRepository;\n+            _paymentRepository = paymentRepository;\n+            _configurationWrapper = configurationWrapper;\n+        }\n+        public void PostPayment(PaymentDTO paymentDto)\n+        {\n+            //check if invoice exists\n+            if (!_invoiceRepository.InvoiceExists(paymentDto.InvoiceId))\n+            {\n+                throw new InvoiceNotFoundException(paymentDto.InvoiceId);\n+            }\n+\n+            //create payment -- send model\n+            var payment = new MpPayment\n+            {\n+                InvoiceNumber = paymentDto.InvoiceId.ToString(),\n+                ContactId = paymentDto.ContactId,\n+                TransactionCode = paymentDto.StripeTransactionId,\n+                PaymentDate = DateTime.Now,\n+                PaymentTotal = paymentDto.Amount,\n+                PaymentTypeId = paymentDto.PaymentTypeId\n+            };\n+            var paymentDetail = new MpPaymentDetail\n+            {\n+                Payment = payment,\n+                PaymentAmount = paymentDto.Amount,\n+                InvoiceDetailId = _invoiceRepository.GetInvoiceDetailForInvoice(paymentDto.InvoiceId).InvoiceDetailId\n+                \n+            };\n+\n+            //returns boolean\n+            _paymentRepository.CreatePaymentAndDetail(paymentDetail);\n+\n+            //update invoice payment status\n+            var invoice = _invoiceRepository.GetInvoice(paymentDto.InvoiceId);\n+            var payments = _paymentRepository.GetPaymentsForInvoice(paymentDto.InvoiceId);\n+            var paymentTotal = payments.Sum(p => p.PaymentTotal);\n+\n+            if (paymentTotal >= invoice.InvoiceTotal)\n+            {\n+                //paid in full\n+                var status = Convert.ToInt32(_configurationWrapper.GetConfigValue(\"PaidInFull\"));","path":"Gateway/crds-angular/Services/PaymentService.cs","position":61,"original_position":61,"commit_id":"58bed40ce300bedea5fc235275e932503f11d656","original_commit_id":"58bed40ce300bedea5fc235275e932503f11d656","user":{"login":"IngageKrizJ","id":11178122,"avatar_url":"https://avatars.githubusercontent.com/u/11178122?v=3","gravatar_id":"","url":"https://api.github.com/users/IngageKrizJ","html_url":"https://github.com/IngageKrizJ","followers_url":"https://api.github.com/users/IngageKrizJ/followers","following_url":"https://api.github.com/users/IngageKrizJ/following{/other_user}","gists_url":"https://api.github.com/users/IngageKrizJ/gists{/gist_id}","starred_url":"https://api.github.com/users/IngageKrizJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IngageKrizJ/subscriptions","organizations_url":"https://api.github.com/users/IngageKrizJ/orgs","repos_url":"https://api.github.com/users/IngageKrizJ/repos","events_url":"https://api.github.com/users/IngageKrizJ/events{/privacy}","received_events_url":"https://api.github.com/users/IngageKrizJ/received_events","type":"User","site_admin":false},"body":"There is a _configurationWrapper.GetConfigIntValue, so you don't have to do the Convert.ToInt32.  Also, I'm not sure if it is a performance issue or not, but we typically get these values in the constructor and set them on a class-level variable so we don't have to go back to _configurationWrapper each time they are needed.","created_at":"2016-10-21T15:44:27Z","updated_at":"2016-10-21T15:47:29Z","html_url":"https://github.com/crdschurch/crds-angular/pull/3013#discussion_r84505531","pull_request_url":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013","_links":{"self":{"href":"https://api.github.com/repos/crdschurch/crds-angular/pulls/comments/84505531"},"html":{"href":"https://github.com/crdschurch/crds-angular/pull/3013#discussion_r84505531"},"pull_request":{"href":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013"}}},"pull_request":{"url":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013","id":90245902,"html_url":"https://github.com/crdschurch/crds-angular/pull/3013","diff_url":"https://github.com/crdschurch/crds-angular/pull/3013.diff","patch_url":"https://github.com/crdschurch/crds-angular/pull/3013.patch","issue_url":"https://api.github.com/repos/crdschurch/crds-angular/issues/3013","number":3013,"state":"open","locked":false,"title":"US5114-PaymentAPI","user":{"login":"plachmann","id":16654047,"avatar_url":"https://avatars.githubusercontent.com/u/16654047?v=3","gravatar_id":"","url":"https://api.github.com/users/plachmann","html_url":"https://github.com/plachmann","followers_url":"https://api.github.com/users/plachmann/followers","following_url":"https://api.github.com/users/plachmann/following{/other_user}","gists_url":"https://api.github.com/users/plachmann/gists{/gist_id}","starred_url":"https://api.github.com/users/plachmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plachmann/subscriptions","organizations_url":"https://api.github.com/users/plachmann/orgs","repos_url":"https://api.github.com/users/plachmann/repos","events_url":"https://api.github.com/users/plachmann/events{/privacy}","received_events_url":"https://api.github.com/users/plachmann/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-20T17:31:01Z","updated_at":"2016-10-21T15:47:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9872154c1c94f4e14120805b26b3f3890a306076","assignee":{"login":"silbermm","id":42816,"avatar_url":"https://avatars.githubusercontent.com/u/42816?v=3","gravatar_id":"","url":"https://api.github.com/users/silbermm","html_url":"https://github.com/silbermm","followers_url":"https://api.github.com/users/silbermm/followers","following_url":"https://api.github.com/users/silbermm/following{/other_user}","gists_url":"https://api.github.com/users/silbermm/gists{/gist_id}","starred_url":"https://api.github.com/users/silbermm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silbermm/subscriptions","organizations_url":"https://api.github.com/users/silbermm/orgs","repos_url":"https://api.github.com/users/silbermm/repos","events_url":"https://api.github.com/users/silbermm/events{/privacy}","received_events_url":"https://api.github.com/users/silbermm/received_events","type":"User","site_admin":false},"assignees":[{"login":"silbermm","id":42816,"avatar_url":"https://avatars.githubusercontent.com/u/42816?v=3","gravatar_id":"","url":"https://api.github.com/users/silbermm","html_url":"https://github.com/silbermm","followers_url":"https://api.github.com/users/silbermm/followers","following_url":"https://api.github.com/users/silbermm/following{/other_user}","gists_url":"https://api.github.com/users/silbermm/gists{/gist_id}","starred_url":"https://api.github.com/users/silbermm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silbermm/subscriptions","organizations_url":"https://api.github.com/users/silbermm/orgs","repos_url":"https://api.github.com/users/silbermm/repos","events_url":"https://api.github.com/users/silbermm/events{/privacy}","received_events_url":"https://api.github.com/users/silbermm/received_events","type":"User","site_admin":false},{"login":"IngageKrizJ","id":11178122,"avatar_url":"https://avatars.githubusercontent.com/u/11178122?v=3","gravatar_id":"","url":"https://api.github.com/users/IngageKrizJ","html_url":"https://github.com/IngageKrizJ","followers_url":"https://api.github.com/users/IngageKrizJ/followers","following_url":"https://api.github.com/users/IngageKrizJ/following{/other_user}","gists_url":"https://api.github.com/users/IngageKrizJ/gists{/gist_id}","starred_url":"https://api.github.com/users/IngageKrizJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IngageKrizJ/subscriptions","organizations_url":"https://api.github.com/users/IngageKrizJ/orgs","repos_url":"https://api.github.com/users/IngageKrizJ/repos","events_url":"https://api.github.com/users/IngageKrizJ/events{/privacy}","received_events_url":"https://api.github.com/users/IngageKrizJ/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/crdschurch/crds-angular/milestones/24","html_url":"https://github.com/crdschurch/crds-angular/milestones/Summer%20Camp","labels_url":"https://api.github.com/repos/crdschurch/crds-angular/milestones/24/labels","id":2059113,"number":24,"title":"Summer Camp","description":"","creator":{"login":"plachmann","id":16654047,"avatar_url":"https://avatars.githubusercontent.com/u/16654047?v=3","gravatar_id":"","url":"https://api.github.com/users/plachmann","html_url":"https://github.com/plachmann","followers_url":"https://api.github.com/users/plachmann/followers","following_url":"https://api.github.com/users/plachmann/following{/other_user}","gists_url":"https://api.github.com/users/plachmann/gists{/gist_id}","starred_url":"https://api.github.com/users/plachmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plachmann/subscriptions","organizations_url":"https://api.github.com/users/plachmann/orgs","repos_url":"https://api.github.com/users/plachmann/repos","events_url":"https://api.github.com/users/plachmann/events{/privacy}","received_events_url":"https://api.github.com/users/plachmann/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":5,"state":"open","created_at":"2016-10-10T12:33:54Z","updated_at":"2016-10-20T17:36:10Z","due_on":"2016-12-15T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013/commits","review_comments_url":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013/comments","review_comment_url":"https://api.github.com/repos/crdschurch/crds-angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crdschurch/crds-angular/issues/3013/comments","statuses_url":"https://api.github.com/repos/crdschurch/crds-angular/statuses/58bed40ce300bedea5fc235275e932503f11d656","head":{"label":"crdschurch:feature/US5114-PaymentAPI","ref":"feature/US5114-PaymentAPI","sha":"58bed40ce300bedea5fc235275e932503f11d656","user":{"login":"crdschurch","id":1843144,"avatar_url":"https://avatars.githubusercontent.com/u/1843144?v=3","gravatar_id":"","url":"https://api.github.com/users/crdschurch","html_url":"https://github.com/crdschurch","followers_url":"https://api.github.com/users/crdschurch/followers","following_url":"https://api.github.com/users/crdschurch/following{/other_user}","gists_url":"https://api.github.com/users/crdschurch/gists{/gist_id}","starred_url":"https://api.github.com/users/crdschurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crdschurch/subscriptions","organizations_url":"https://api.github.com/users/crdschurch/orgs","repos_url":"https://api.github.com/users/crdschurch/repos","events_url":"https://api.github.com/users/crdschurch/events{/privacy}","received_events_url":"https://api.github.com/users/crdschurch/received_events","type":"Organization","site_admin":false},"repo":{"id":26870034,"name":"crds-angular","full_name":"crdschurch/crds-angular","owner":{"login":"crdschurch","id":1843144,"avatar_url":"https://avatars.githubusercontent.com/u/1843144?v=3","gravatar_id":"","url":"https://api.github.com/users/crdschurch","html_url":"https://github.com/crdschurch","followers_url":"https://api.github.com/users/crdschurch/followers","following_url":"https://api.github.com/users/crdschurch/following{/other_user}","gists_url":"https://api.github.com/users/crdschurch/gists{/gist_id}","starred_url":"https://api.github.com/users/crdschurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crdschurch/subscriptions","organizations_url":"https://api.github.com/users/crdschurch/orgs","repos_url":"https://api.github.com/users/crdschurch/repos","events_url":"https://api.github.com/users/crdschurch/events{/privacy}","received_events_url":"https://api.github.com/users/crdschurch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crdschurch/crds-angular","description":"Starting point for angular development at crossroads","fork":false,"url":"https://api.github.com/repos/crdschurch/crds-angular","forks_url":"https://api.github.com/repos/crdschurch/crds-angular/forks","keys_url":"https://api.github.com/repos/crdschurch/crds-angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crdschurch/crds-angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crdschurch/crds-angular/teams","hooks_url":"https://api.github.com/repos/crdschurch/crds-angular/hooks","issue_events_url":"https://api.github.com/repos/crdschurch/crds-angular/issues/events{/number}","events_url":"https://api.github.com/repos/crdschurch/crds-angular/events","assignees_url":"https://api.github.com/repos/crdschurch/crds-angular/assignees{/user}","branches_url":"https://api.github.com/repos/crdschurch/crds-angular/branches{/branch}","tags_url":"https://api.github.com/repos/crdschurch/crds-angular/tags","blobs_url":"https://api.github.com/repos/crdschurch/crds-angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crdschurch/crds-angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crdschurch/crds-angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/crdschurch/crds-angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crdschurch/crds-angular/statuses/{sha}","languages_url":"https://api.github.com/repos/crdschurch/crds-angular/languages","stargazers_url":"https://api.github.com/repos/crdschurch/crds-angular/stargazers","contributors_url":"https://api.github.com/repos/crdschurch/crds-angular/contributors","subscribers_url":"https://api.github.com/repos/crdschurch/crds-angular/subscribers","subscription_url":"https://api.github.com/repos/crdschurch/crds-angular/subscription","commits_url":"https://api.github.com/repos/crdschurch/crds-angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/crdschurch/crds-angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/crdschurch/crds-angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/crdschurch/crds-angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/crdschurch/crds-angular/contents/{+path}","compare_url":"https://api.github.com/repos/crdschurch/crds-angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crdschurch/crds-angular/merges","archive_url":"https://api.github.com/repos/crdschurch/crds-angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crdschurch/crds-angular/downloads","issues_url":"https://api.github.com/repos/crdschurch/crds-angular/issues{/number}","pulls_url":"https://api.github.com/repos/crdschurch/crds-angular/pulls{/number}","milestones_url":"https://api.github.com/repos/crdschurch/crds-angular/milestones{/number}","notifications_url":"https://api.github.com/repos/crdschurch/crds-angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crdschurch/crds-angular/labels{/name}","releases_url":"https://api.github.com/repos/crdschurch/crds-angular/releases{/id}","deployments_url":"https://api.github.com/repos/crdschurch/crds-angular/deployments","created_at":"2014-11-19T16:21:09Z","updated_at":"2016-08-25T00:55:26Z","pushed_at":"2016-10-21T15:23:11Z","git_url":"git://github.com/crdschurch/crds-angular.git","ssh_url":"git@github.com:crdschurch/crds-angular.git","clone_url":"https://github.com/crdschurch/crds-angular.git","svn_url":"https://github.com/crdschurch/crds-angular","homepage":null,"size":48917,"stargazers_count":4,"watchers_count":4,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":4,"default_branch":"development"}},"base":{"label":"crdschurch:development","ref":"development","sha":"90c574528fd7ba9fdf298860db506bcb49e52d26","user":{"login":"crdschurch","id":1843144,"avatar_url":"https://avatars.githubusercontent.com/u/1843144?v=3","gravatar_id":"","url":"https://api.github.com/users/crdschurch","html_url":"https://github.com/crdschurch","followers_url":"https://api.github.com/users/crdschurch/followers","following_url":"https://api.github.com/users/crdschurch/following{/other_user}","gists_url":"https://api.github.com/users/crdschurch/gists{/gist_id}","starred_url":"https://api.github.com/users/crdschurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crdschurch/subscriptions","organizations_url":"https://api.github.com/users/crdschurch/orgs","repos_url":"https://api.github.com/users/crdschurch/repos","events_url":"https://api.github.com/users/crdschurch/events{/privacy}","received_events_url":"https://api.github.com/users/crdschurch/received_events","type":"Organization","site_admin":false},"repo":{"id":26870034,"name":"crds-angular","full_name":"crdschurch/crds-angular","owner":{"login":"crdschurch","id":1843144,"avatar_url":"https://avatars.githubusercontent.com/u/1843144?v=3","gravatar_id":"","url":"https://api.github.com/users/crdschurch","html_url":"https://github.com/crdschurch","followers_url":"https://api.github.com/users/crdschurch/followers","following_url":"https://api.github.com/users/crdschurch/following{/other_user}","gists_url":"https://api.github.com/users/crdschurch/gists{/gist_id}","starred_url":"https://api.github.com/users/crdschurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crdschurch/subscriptions","organizations_url":"https://api.github.com/users/crdschurch/orgs","repos_url":"https://api.github.com/users/crdschurch/repos","events_url":"https://api.github.com/users/crdschurch/events{/privacy}","received_events_url":"https://api.github.com/users/crdschurch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crdschurch/crds-angular","description":"Starting point for angular development at crossroads","fork":false,"url":"https://api.github.com/repos/crdschurch/crds-angular","forks_url":"https://api.github.com/repos/crdschurch/crds-angular/forks","keys_url":"https://api.github.com/repos/crdschurch/crds-angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crdschurch/crds-angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crdschurch/crds-angular/teams","hooks_url":"https://api.github.com/repos/crdschurch/crds-angular/hooks","issue_events_url":"https://api.github.com/repos/crdschurch/crds-angular/issues/events{/number}","events_url":"https://api.github.com/repos/crdschurch/crds-angular/events","assignees_url":"https://api.github.com/repos/crdschurch/crds-angular/assignees{/user}","branches_url":"https://api.github.com/repos/crdschurch/crds-angular/branches{/branch}","tags_url":"https://api.github.com/repos/crdschurch/crds-angular/tags","blobs_url":"https://api.github.com/repos/crdschurch/crds-angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crdschurch/crds-angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crdschurch/crds-angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/crdschurch/crds-angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crdschurch/crds-angular/statuses/{sha}","languages_url":"https://api.github.com/repos/crdschurch/crds-angular/languages","stargazers_url":"https://api.github.com/repos/crdschurch/crds-angular/stargazers","contributors_url":"https://api.github.com/repos/crdschurch/crds-angular/contributors","subscribers_url":"https://api.github.com/repos/crdschurch/crds-angular/subscribers","subscription_url":"https://api.github.com/repos/crdschurch/crds-angular/subscription","commits_url":"https://api.github.com/repos/crdschurch/crds-angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/crdschurch/crds-angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/crdschurch/crds-angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/crdschurch/crds-angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/crdschurch/crds-angular/contents/{+path}","compare_url":"https://api.github.com/repos/crdschurch/crds-angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crdschurch/crds-angular/merges","archive_url":"https://api.github.com/repos/crdschurch/crds-angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crdschurch/crds-angular/downloads","issues_url":"https://api.github.com/repos/crdschurch/crds-angular/issues{/number}","pulls_url":"https://api.github.com/repos/crdschurch/crds-angular/pulls{/number}","milestones_url":"https://api.github.com/repos/crdschurch/crds-angular/milestones{/number}","notifications_url":"https://api.github.com/repos/crdschurch/crds-angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crdschurch/crds-angular/labels{/name}","releases_url":"https://api.github.com/repos/crdschurch/crds-angular/releases{/id}","deployments_url":"https://api.github.com/repos/crdschurch/crds-angular/deployments","created_at":"2014-11-19T16:21:09Z","updated_at":"2016-08-25T00:55:26Z","pushed_at":"2016-10-21T15:23:11Z","git_url":"git://github.com/crdschurch/crds-angular.git","ssh_url":"git@github.com:crdschurch/crds-angular.git","clone_url":"https://github.com/crdschurch/crds-angular.git","svn_url":"https://github.com/crdschurch/crds-angular","homepage":null,"size":48917,"stargazers_count":4,"watchers_count":4,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":4,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013"},"html":{"href":"https://github.com/crdschurch/crds-angular/pull/3013"},"issue":{"href":"https://api.github.com/repos/crdschurch/crds-angular/issues/3013"},"comments":{"href":"https://api.github.com/repos/crdschurch/crds-angular/issues/3013/comments"},"review_comments":{"href":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013/comments"},"review_comment":{"href":"https://api.github.com/repos/crdschurch/crds-angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crdschurch/crds-angular/pulls/3013/commits"},"statuses":{"href":"https://api.github.com/repos/crdschurch/crds-angular/statuses/58bed40ce300bedea5fc235275e932503f11d656"}}}}
{"actor":{"display_login":"IngageKrizJ"}}