{"action":"created","issue":{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/issues/2667","labels_url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/issues/2667/labels{/name}","comments_url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/issues/2667/comments","events_url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/issues/2667/events","html_url":"https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/2667","id":44346172,"number":2667,"title":"Introduce EDD_Payment class","user":{"login":"pippinsplugins","id":1034109,"avatar_url":"https://avatars.githubusercontent.com/u/1034109?v=3","gravatar_id":"","url":"https://api.github.com/users/pippinsplugins","html_url":"https://github.com/pippinsplugins","followers_url":"https://api.github.com/users/pippinsplugins/followers","following_url":"https://api.github.com/users/pippinsplugins/following{/other_user}","gists_url":"https://api.github.com/users/pippinsplugins/gists{/gist_id}","starred_url":"https://api.github.com/users/pippinsplugins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pippinsplugins/subscriptions","organizations_url":"https://api.github.com/users/pippinsplugins/orgs","repos_url":"https://api.github.com/users/pippinsplugins/repos","events_url":"https://api.github.com/users/pippinsplugins/events{/privacy}","received_events_url":"https://api.github.com/users/pippinsplugins/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/labels/Enhancement","name":"Enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/labels/High%20Priority","name":"High Priority","color":"207005"},{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/labels/Needs%20Testing","name":"Needs Testing","color":"bfe5bf"},{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/labels/Payments","name":"Payments","color":"7F8C8D"}],"state":"open","locked":false,"assignee":{"login":"cklosowski","id":1390124,"avatar_url":"https://avatars.githubusercontent.com/u/1390124?v=3","gravatar_id":"","url":"https://api.github.com/users/cklosowski","html_url":"https://github.com/cklosowski","followers_url":"https://api.github.com/users/cklosowski/followers","following_url":"https://api.github.com/users/cklosowski/following{/other_user}","gists_url":"https://api.github.com/users/cklosowski/gists{/gist_id}","starred_url":"https://api.github.com/users/cklosowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cklosowski/subscriptions","organizations_url":"https://api.github.com/users/cklosowski/orgs","repos_url":"https://api.github.com/users/cklosowski/repos","events_url":"https://api.github.com/users/cklosowski/events{/privacy}","received_events_url":"https://api.github.com/users/cklosowski/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/milestones/93","html_url":"https://github.com/easydigitaldownloads/Easy-Digital-Downloads/milestones/2.5","labels_url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/milestones/93/labels","id":979858,"number":93,"title":"2.5","description":"Reporting","creator":{"login":"chriscct7","id":1324637,"avatar_url":"https://avatars.githubusercontent.com/u/1324637?v=3","gravatar_id":"","url":"https://api.github.com/users/chriscct7","html_url":"https://github.com/chriscct7","followers_url":"https://api.github.com/users/chriscct7/followers","following_url":"https://api.github.com/users/chriscct7/following{/other_user}","gists_url":"https://api.github.com/users/chriscct7/gists{/gist_id}","starred_url":"https://api.github.com/users/chriscct7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriscct7/subscriptions","organizations_url":"https://api.github.com/users/chriscct7/orgs","repos_url":"https://api.github.com/users/chriscct7/repos","events_url":"https://api.github.com/users/chriscct7/events{/privacy}","received_events_url":"https://api.github.com/users/chriscct7/received_events","type":"User","site_admin":false},"open_issues":37,"closed_issues":53,"state":"open","created_at":"2015-02-15T05:10:01Z","updated_at":"2015-11-10T15:54:29Z","due_on":"2015-11-26T06:00:00Z","closed_at":null},"comments":36,"created_at":"2014-09-29T19:44:44Z","updated_at":"2015-11-10T23:28:40Z","closed_at":null,"body":"Creating payments and retrieving payment data can be obtusely difficult, especially creating payments like the Manual Purchases extension does.\r\n\r\nWe should really introduce an `EDD_Payment` class that takes care of this.\r\n\r\nFor example, to create a new payment, it might look like this:\r\n```php\r\n$payment = new EDD_Payment;\r\n$payment->add_download( $id, $price_id );\r\n$payment->add_fee( $label, $amount );\r\n$payment->add_discount( $code );\r\n$payment->set_total( $amount );\r\n$payment->set_tax( $amount );\r\n$payment->complete();\r\n```\r\nAll meta data should be able to be set in this way.\r\n\r\nRetrieving an existing payment would be as simple as:\r\n```php\r\n$payment = new EDD_Payment( $id );\r\n$total = $payment->total;\r\n$downloads = $payment->downloads;\r\n$tax = $payment->tax;\r\n```\r\nUpdating an existing payment:\r\n```php\r\n$payment = new EDD_Payment( $id );\r\n$payment->set_total( $new_total );\r\n$payment->add_note( 'Total manually changed because why not?' );\r\n```"},"comment":{"url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/issues/comments/155601089","html_url":"https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/2667#issuecomment-155601089","issue_url":"https://api.github.com/repos/easydigitaldownloads/Easy-Digital-Downloads/issues/2667","id":155601089,"user":{"login":"cklosowski","id":1390124,"avatar_url":"https://avatars.githubusercontent.com/u/1390124?v=3","gravatar_id":"","url":"https://api.github.com/users/cklosowski","html_url":"https://github.com/cklosowski","followers_url":"https://api.github.com/users/cklosowski/followers","following_url":"https://api.github.com/users/cklosowski/following{/other_user}","gists_url":"https://api.github.com/users/cklosowski/gists{/gist_id}","starred_url":"https://api.github.com/users/cklosowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cklosowski/subscriptions","organizations_url":"https://api.github.com/users/cklosowski/orgs","repos_url":"https://api.github.com/users/cklosowski/repos","events_url":"https://api.github.com/users/cklosowski/events{/privacy}","received_events_url":"https://api.github.com/users/cklosowski/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T23:28:40Z","updated_at":"2015-11-10T23:28:40Z","body":"@pippinsplugins Ok, we've hit a headway. At this point we can move forward with discounts being part of the payment class, or not, but our current method of discounts doesn't apply cleanly to a new `EDD_Payment` class.\r\n\r\nDo you mind jumping in and seeing how you feel about this, and working with it to see how you might add discount management to it?"}}