{"id":57,"date":"2016-02-16T18:25:29","date_gmt":"2016-02-16T18:25:29","guid":{"rendered":"https:\/\/easydigitaldownloads.com\/development\/?p=57"},"modified":"2021-12-15T15:31:19","modified_gmt":"2021-12-15T21:31:19","slug":"new-refund-method-in-edd_payment","status":"publish","type":"post","link":"https:\/\/easydigitaldownloads.com\/development\/2016\/02\/16\/new-refund-method-in-edd_payment\/","title":{"rendered":"New refund method in EDD_Payment"},"content":{"rendered":"<p>Last week we released version 2.5.7 of Easy Digital Downloads. In case you missed it, it was a pretty significant bug fix release with 24 fixes, a few tweaks, and 3 new enhancements. One of the major enhancements was the addition of a <code>refund()<\/code> method within the <code>EDD_Payment<\/code> class added in version 2.5. Today I want to give you a detailed look at using this method and what happens when running it for a payment.<\/p>\n<h3>General Usage<\/h3>\n<p>At the end of the day, the purpose of <code>EDD_Payment<\/code> is abstracting all the work of interacting with payments, to make it as easy as possible for developers to integrate with EDD as a platform. With that in mind, refunding a payment is as simple as:<\/p>\n<pre>\r\n$payment = new EDD_Payment( 123 );\r\n$payment->refund();\r\n<\/pre>\n<p>And that&#8217;s all there is to it. The supplied method handles all the status updates and runs all the necessary changes to earnings and sales stats. Which is what leads us to why this becomes more powerful for developers.<\/p>\n<p class=\"edd-alert edd-alert-info\"\"><strong>Note:<\/strong> When processing a refund in EDD the refund request <em>may not<\/em> be sent to the payment gateway. This is gateway dependent and needs to be supported by the gateway extension.<\/p>\n<h3>Filtering the refund process<\/h3>\n<p>In previous versions of Easy Digital Downloads, the task of refunding a payment was reserved only for payments moving from Completed or Revoked. Outside of those two statuses, EDD would not process the necessary actions other than updating the status. We&#8217;ve added some filters in place to allow developers to allow their custom payment statuses to also run as refunds, and handle earnings and sales stats accordingly.<\/p>\n<p>https:\/\/gist.github.com\/cklosowski\/a36607655301c2af9b64<\/p>\n<h3>Still Final<\/h3>\n<p>Since we&#8217;re still finalizing all of the details of using <code>EDD_Payment<\/code>, we&#8217;re going to be keeping the <code>Final<\/code> keyword on the class for a little longer. The addition of these types of methods allows us to get closer to having a fully abstracted interaction with payments. As always if you have feedback leave it in the comments or hop on over to <a href=\"https:\/\/github.com\/easydigitaldownloads\/Easy-Digital-Downloads\" target=\"_blank\" rel=\"noopener\">GitHub<\/a> and let us know how we can improve this development feature.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week we released version 2.5.7 of Easy Digital Downloads. In case you missed it, it was a pretty significant bug fix release with 24 fixes, a few tweaks, and 3 new enhancements. One of&#8230;<\/p>\n<p class=\"continue-reading\"><a class=\"more-link\" href=\"https:\/\/easydigitaldownloads.com\/development\/2016\/02\/16\/new-refund-method-in-edd_payment\/\">Continue reading &rarr;<\/a><\/p>\n","protected":false},"author":650,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-core"],"_links":{"self":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/users\/650"}],"replies":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":1,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":1123,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/57\/revisions\/1123"}],"wp:attachment":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}