{"action":"created","issue":{"url":"https://api.github.com/repos/killbill/killbill/issues/334","labels_url":"https://api.github.com/repos/killbill/killbill/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/killbill/killbill/issues/334/comments","events_url":"https://api.github.com/repos/killbill/killbill/issues/334/events","html_url":"https://github.com/killbill/killbill/issues/334","id":88231442,"number":334,"title":"Payments with more refunded than captured","user":{"login":"kevinpostlewaite","id":1063461,"avatar_url":"https://avatars.githubusercontent.com/u/1063461?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinpostlewaite","html_url":"https://github.com/kevinpostlewaite","followers_url":"https://api.github.com/users/kevinpostlewaite/followers","following_url":"https://api.github.com/users/kevinpostlewaite/following{/other_user}","gists_url":"https://api.github.com/users/kevinpostlewaite/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinpostlewaite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinpostlewaite/subscriptions","organizations_url":"https://api.github.com/users/kevinpostlewaite/orgs","repos_url":"https://api.github.com/users/kevinpostlewaite/repos","events_url":"https://api.github.com/users/kevinpostlewaite/events{/privacy}","received_events_url":"https://api.github.com/users/kevinpostlewaite/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-14T18:56:52Z","updated_at":"2015-06-15T06:58:42Z","closed_at":null,"body":"I believe that the refund should have failed.\r\n\r\nselect\r\n    payment_id\r\n    ,case when incoming_funds > authorized_funds and outgoing_funds > incoming_funds then 'INCOMING>AUTH & OUTGOING>INCOMING'\r\n\t\t  when incoming_funds > authorized_funds then 'INCOMING>AUTH'\r\n          when outgoing_funds > incoming_funds then 'OUTGOING>INCOMING' \r\n     end as problem_reason\r\n    ,authorized_funds\r\n    ,incoming_funds\r\n    ,outgoing_funds\r\nfrom (\r\nselect \r\n    pt.payment_id\r\n    ,sum(case when pt.transaction_type in ('AUTHORIZE','PURCHASE') then pt.amount else 0 end) authorized_funds\r\n    ,sum(case when pt.transaction_type in ('PURCHASE','CAPTURE') then pt.amount else 0 end) incoming_funds\r\n    ,sum(case when pt.transaction_type in ('REFUND','CHARGEBACK','VOID') then pt.amount else 0 end) outgoing_funds\r\nfrom\r\n    payment_transactions pt\r\nwhere 1=1\r\n    and pt.transaction_status = 'SUCCESS'\r\ngroup by 1    \r\n) t1\r\nwhere 1!=1\r\n   or outgoing_funds > incoming_funds"},"comment":{"url":"https://api.github.com/repos/killbill/killbill/issues/comments/111955917","html_url":"https://github.com/killbill/killbill/issues/334#issuecomment-111955917","issue_url":"https://api.github.com/repos/killbill/killbill/issues/334","id":111955917,"user":{"login":"pierre","id":51940,"avatar_url":"https://avatars.githubusercontent.com/u/51940?v=3","gravatar_id":"","url":"https://api.github.com/users/pierre","html_url":"https://github.com/pierre","followers_url":"https://api.github.com/users/pierre/followers","following_url":"https://api.github.com/users/pierre/following{/other_user}","gists_url":"https://api.github.com/users/pierre/gists{/gist_id}","starred_url":"https://api.github.com/users/pierre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierre/subscriptions","organizations_url":"https://api.github.com/users/pierre/orgs","repos_url":"https://api.github.com/users/pierre/repos","events_url":"https://api.github.com/users/pierre/events{/privacy}","received_events_url":"https://api.github.com/users/pierre/received_events","type":"User","site_admin":false},"created_at":"2015-06-15T06:58:42Z","updated_at":"2015-06-15T06:58:42Z","body":"Same remarks as https://github.com/killbill/killbill/issues/333. For CyberSource specifically, see page 59 of  [Credit_Cards_SO_API.pdf](http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SO_API/Credit_Cards_SO_API.pdf)."}}