{"id":56,"date":"2016-02-04T19:54:04","date_gmt":"2016-02-04T19:54:04","guid":{"rendered":"https:\/\/easydigitaldownloads.com\/development\/?p=56"},"modified":"2021-12-15T15:32:26","modified_gmt":"2021-12-15T21:32:26","slug":"breaking-changes-and-deprecated-methods-in-recurring-payments-2-4","status":"publish","type":"post","link":"https:\/\/easydigitaldownloads.com\/development\/2016\/02\/04\/breaking-changes-and-deprecated-methods-in-recurring-payments-2-4\/","title":{"rendered":"Breaking changes and deprecated methods in Recurring Payments 2.4"},"content":{"rendered":"<p>Recurring Payments 2.4 is very, very close to being released. A few days ago we <a href=\"https:\/\/easydigitaldownloads.com\/blog\/recurring-payments-2-4-preview\/\" target=\"_blank\" rel=\"noopener\">showed a preview<\/a> of some of the improvements that have been added to this version. Due to the scale of this update, there are several significant changes that we have made that could result in adverse effects if not properly accounted for. To help developers prepare for the update, we will cover each of those\u00a0breaking changes here.<\/p>\n<p><!--more--><\/p>\n<h3>Deprecated classes and\u00a0methods<\/h3>\n<p>With the drastic changes and improvements being introduced with Recurring Payments 2.4, it has been necessary to deprecate some classes and methods.<\/p>\n<p><strong>EDD_Recurring_Customer<\/strong><\/p>\n<p>In Recurring Payments 2.4, we have introduced two\u00a0new classes for interacting with subscriptions and subscribers:<\/p>\n<ul>\n<li>EDD_Subscription<\/li>\n<li>EDD_Recurring_Subscriber<\/li>\n<\/ul>\n<p>These classes replace the now-deprecated\u00a0<em>EDD_Recurring_Customer\u00a0<\/em>class. All methods within\u00a0<em>EDD_Recurring_Customer\u00a0<\/em>are also now deprecated. These include:<\/p>\n<ul>\n<li>set_as_subscriber()<\/li>\n<li>set_customer_id()<\/li>\n<li>get_customer_id()<\/li>\n<li>get_user_id_by_customer_id()<\/li>\n<li>set_customer_payment_id()<\/li>\n<li>get_customer_payment_id()<\/li>\n<li>set_customer_status()<\/li>\n<li>get_customer_status()<\/li>\n<li>is_customer_active()<\/li>\n<li>set_customer_expiration()<\/li>\n<li>get_customer_expiration()<\/li>\n<li>is_customer_expired()<\/li>\n<li>calc_user_expiration()<\/li>\n<li>get_user_id_from_customer_id()<\/li>\n<\/ul>\n<p>If used, these\u00a0methods will now throw a deprecated notice if WP_DEBUG is enabled and the current user is a site administrator.<\/p>\n<p>All of these methods have a replacement of some form inside of the\u00a0<em>EDD_Recurring_Subscriber\u00a0<\/em>class. I say &#8220;in some form&#8221; because it is not a direct transfer from one method to the other.<\/p>\n<p>Prior to\u00a02.4, Recurring Payments stored subscriber information (status, expiration date, profile ID, etc) inside of the wp_usermeta table and customers were limited to a single subscription.\u00a0Now, however, with Recurring Payments 2.4, subscription data is stored in a custom table and customers can have multiple subscriptions. All of the methods in <em>EDD_Recurring_Customer<\/em> (the deprecated class), assume a single subscription. For this reason, they can no longer be reliably used.<\/p>\n<p>We have updated each method within\u00a0<em>EDD_Recurring_Customer <\/em>to still return a value. When used, the methods will retrieve the information from the first subscription found for the customer record. If the customer has only a single subscription on their account, the returned results should be as expected. If, however, there are multiple subscriptions on the account, the results could be unexpected.<\/p>\n<p>It is strongly recommended that you\u00a0cease using the\u00a0<em><em>EDD_Recurring_Customer\u00a0<\/em><\/em>immediately after updating to 2.4 to ensure proper behavior.<\/p>\n<p><strong>record_subscription_payment()<\/strong><\/p>\n<p>Inside of the main\u00a0<em>EDD_Recurring\u00a0<\/em>class is a method called\u00a0<em>record_subscription_payment().\u00a0<\/em>This method was previously used for inserting a renewal payment into the database anytime a renewal was processed. This method has been deprecated and should no longer be used.<\/p>\n<p>If you need to record renewal payments manually, please use the\u00a0<em>add_payment()\u00a0<\/em>method within the\u00a0<em>EDD_Subscription\u00a0<\/em>class.<\/p>\n<p><strong>payment_exists()<\/strong><\/p>\n<p>The\u00a0<em>payment_exists()\u00a0<\/em>method inside of\u00a0<em>EDD_Recurring\u00a0<\/em>has been deprecated. There is no replacement for it as it&#8217;s entirely unneeded as of Recurring Payments 2.4.<\/p>\n<h3>Payment statuses<\/h3>\n<p>In Recurring Payments 2.4\u00a0there are\u00a0some changes to payment statuses.<\/p>\n<p><strong>Cancelled status is no more<\/strong><\/p>\n<p>Prior to 2.4,\u00a0when a subscription was cancelled, the payment record that originated the subscription was\u00a0given a status of\u00a0<em>cancelled<\/em>. In 2.4, this is no longer the case. What happens, instead, is the payment record remains as\u00a0<em>complete\u00a0<\/em>and the subscription record is given a status of\u00a0<em>cancelled<\/em>. This makes reporting more accurate and more logical.<\/p>\n<p><strong>Subscription Payment renamed<\/strong><\/p>\n<p>In versions before 2.4, subscription renewal payments were given\u00a0a status of\u00a0<em>Subscription Payment<\/em>. The status itself is unchanged, but we have changed the label to just\u00a0<em>Renewal<\/em>.<\/p>\n<h3>Removed admin screens<\/h3>\n<p>The most apparent changes in Recurring Payments 2.4\u00a0are within the administration area. As should be apparent from the <a href=\"https:\/\/easydigitaldownloads.com\/blog\/recurring-payments-2-4-preview\/\" target=\"_blank\" rel=\"noopener\">preview post<\/a>,\u00a0the administration options in Recurring Payments 2.4 have been completely revamped. Along with the new\u00a0interface options, we have also removed some that were available in previous versions.<\/p>\n<p><strong>Downloads &gt; Reports &gt; Subscribers<\/strong><\/p>\n<p>This screen is no longer available. To view a list of subscribers, go to <em>Downloads &gt; Subscriptions<\/em>.<\/p>\n<p><strong>Subscription status on Downloads &gt; Customers<\/strong><\/p>\n<p>There used to be an expiration date and subscription status columns in the\u00a0<em>Downloads &gt; Customers\u00a0<\/em>table. These have been removed as customers are no longer limited to a single subscription. The subscription details for a customer can be viewed on the\u00a0customer&#8217;s individual details screen.<\/p>\n<h3>User roles<\/h3>\n<p>In all versions before Recurring Payments 2.4, subscribers were given a user role of\u00a0<em>EDD Subscriber<\/em>. This role could be used to control access and viewing capabilities of subscribers.<\/p>\n<p>In 2.4, we recommend not using this user role as a way to determine if a user account has a subscriber. While the user role is still present and will\u00a0continue to be set on subscriber accounts, it is not an accurate representation of a customer&#8217;s subscription (or\u00a0subscriptions) status.<\/p>\n<p>Please use the methods available in the\u00a0<em>EDD_Recurring_Subscriber\u00a0<\/em>class if you need to check a customer&#8217;s access programmatically.<\/p>\n<h3>User meta values<\/h3>\n<p>Before version 2.4, we stored\u00a0several pieces of information related to a customer&#8217;s subscription in the wp_usermeta table. As mentioned above, we now use a custom database table for storing subscription data. With the move to the custom table, several pieces of usermeta have been discontinued and\/or modified and should no longer be relied upon.<\/p>\n<p><strong>_edd_recurring_id<\/strong><\/p>\n<p>The\u00a0<em>_edd_recurring_id\u00a0<\/em>meta key was previously used to store the ID of the customer assigned from the merchant processor. For example,\u00a0for customers that purchased a subscription through Stripe, this would be set as something like\u00a0<em>cus_7qInEioCfgPA6b. <\/em>This meta key is still used and is used for the same purpose, but as customers can now have more than just one subscription, it was necessary to change the\u00a0<em>meta_value\u00a0<\/em>for this key from a single string to an array. It will now contain an array of key value pairs where the key is the ID of the payment gateway and the value is the customer&#8217;s recurring ID.<\/p>\n<p><strong>_edd_recurring_user_parent_payment_id<\/strong><\/p>\n<p>The\u00a0<em>_edd_recurring_user_parent_payment_id\u00a0<\/em>meta key was used to store the ID number of the payment record that originated the customer&#8217;s subscription. This meta key is no longer used in any way. Customers can now have multiple subscriptions and if you need to retrieve a list of the payment IDs, they may be accessed through the <em>EDD_Recurring_Subscriber<\/em> class<em>.<\/em><\/p>\n<p><strong>_edd_recurring_status<\/strong><\/p>\n<p>The\u00a0<em>_edd_recurring_status <\/em>meta key was used to store the status of the customer&#8217;s subscription. As\u00a0subscriptions are now stored in a custom database table, this meta key is no longer used nor updated. If you are checking against or setting this value, please use the <em>EDD_Subscription\u00a0<\/em>or <em>EDD_Recurring_Subscriber\u00a0<\/em>classes instead.<\/p>\n<p><strong>_edd_recurring_exp<\/strong><\/p>\n<p>The _edd_recurring_exp<em>\u00a0<\/em>meta key was used to store the expiration date\u00a0of the customer&#8217;s subscription. As\u00a0subscriptions are now stored in a custom database table, this meta key is no longer used nor updated. If you are checking against or setting this value, please use the <em>EDD_Subscription\u00a0<\/em>or <em>EDD_Recurring_Subscriber\u00a0<\/em>classes instead.<\/p>\n<h3>Shortcodes<\/h3>\n<p>In Recurring Payments 2.4, we are introducing a new shortcode,\u00a0<em>[edd_subscriptions],\u00a0<\/em>that provides customers with complete details and controls for all subscriptions on their account.<\/p>\n<p>Due to the nuances of adding support for multiple subscriptions, we have decided that the following \u00a0two shortcodes are no longer relevant nor can they be adequately used:<\/p>\n<ul>\n<li>[edd_recurring_update]<\/li>\n<li>[edd_recurring_cancel]<\/li>\n<\/ul>\n<p>These two shortcodes have been discontinued in Recurring Payments 2.4. Technically the shortcodes are still registered with WordPress, but they will not\u00a0display any content; they simply return an empty string.<\/p>\n<p>Please update your sites to use\u00a0<em>[<em>edd_subscriptions]\u00a0<\/em><\/em>instead.<\/p>\n<h3>Updating to 2.4<\/h3>\n<p>As should be apparent, Recurring Payments 2.4 is a\u00a0<strong>large\u00a0<\/strong>release. It is so large, in fact, that we considered for quite a long time the possibility of launching it as a brand new plugin. While we\u00a0did not break it off into a new plugin, we have decided that it is in the best interest of all customers that we <strong>not permit automatic updates from 2.3.x to 2.4.<\/strong><\/p>\n<p>Installing version 2.4 for sites that have been running 2.3.x, will require a manual update. One-click updates from within WordPress have been disabled between 2.3.x and 2.4. We decided that this was the best option so as to not adversely affect the front-end display of websites without the site owner being immediately aware of the changes about to be applied.<\/p>\n<p>We have built a complete migration routine that will allow site owners to migrate their 2.3.x data to the new 2.4 data schema. This upgrade routine has been tested successfully numerous times on sites with more than 20,000 subscription records.<\/p>\n<p>Once 2.4 is released, there will be a complete walkthrough guide to assist site owners with updating from earlier versions to 2.4.<\/p>\n<p>If you have any questions, comments, or concerns about the upcoming release, please let us know as soon as possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recurring Payments 2.4 is very, very close to being released. A few days ago we showed a preview of some of the improvements that have been added to this version. Due to the scale of&#8230;<\/p>\n<p class=\"continue-reading\"><a class=\"more-link\" href=\"https:\/\/easydigitaldownloads.com\/development\/2016\/02\/04\/breaking-changes-and-deprecated-methods-in-recurring-payments-2-4\/\">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":[3],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","hentry","category-extensions"],"_links":{"self":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/56","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=56"}],"version-history":[{"count":1,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":1124,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/56\/revisions\/1124"}],"wp:attachment":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}