Paid Memberships Pro - Version 1.9.4.3

Version Description

  • 2018-01-04 =
  • BUG FIX: Fixed issue where PMPro would attempt to cancel gateway subscriptions more than once in some cases.
Download this release

Release Info

Developer strangerstudios
Plugin Icon 128x128 Paid Memberships Pro
Version 1.9.4.3
Comparing to
See all releases

Code changes from version 1.9.4.2 to 1.9.4.3

CHANGELOG.txt CHANGED
@@ -1,13 +1,30 @@
1
  == Changelog ==
2
 
3
- = 1.9.4.1 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  * BUG FIX: Fixed serious bug where payment fields weren't showing up for the Braintree gateway.
5
  * BUG FIX: Fixed issue where Braintree webhook notifications were failing. We now allow the Braintree library to sanitize the incoming data since our sanitizing efforts were breaking the validation.
6
  * BUG FIX/ENHANCEMENT: The webhook URL given for Braintree now goes through admin-ajax.php instead of a direct link to a php file within our plugin.
7
  * BUG FIX/ENHANCEMENT: Updates to the Recaptcha library. (Thanks, Corin Simpson-Bryars)
8
  * ENHANCEMENT: Made the cancelation failed error email easier to read.
9
 
10
- = 1.9.4 =
11
  * BUG FIX: Fixed issue where PayPal was not working for amounts over $1000.
12
  * BUG FIX: Non-decimal currencies now handled correctly with Stripe.
13
  * BUG FIX: Fixed issue where updating a Stripe subscription from the edit user page could cancel the subscription once the webhook fired.
@@ -46,7 +63,7 @@ up the lines of text.
46
  * ENHANCEMENT: Added Portuguese language files. (Thanks, Secundino Correia)
47
  * ENHANCEMENT: Updated plugin admin pages with better links to documentation and support.
48
 
49
- = 1.9.3 =
50
  * SECURITY: Fixed sanitization of inputs and added nonces in several places to protect against XSS attacks.
51
  * BUG FIX: Showing correct error message when trying to update a PMPro Plus add on with a Core license installed.
52
  * BUG FIX: Fixed issue where subscription and payment transaction IDs were not being saved correctly when copying an order in the dashboard. (Thanks, Pippin Williamson)
@@ -55,15 +72,15 @@ up the lines of text.
55
  * ENHANCEMENT: Added a pmpro_sanitize_with_safelist() function that is used to sanitize inputs that have a limited number of exact options.
56
  * ENHANCEMENT: Updated the pmpro_setOption() and pmpro_getParam() functions to take a new last parameter $sanitize_function, which defaults to 'sanitize_text_field'.
57
 
58
- = 1.9.2.2 =
59
  * BUG FIX: Fixed warnings on the Network Dashboard's sites page.
60
  * BUG FIX: Skipping update scripts that require the Stripe library if the system doesn't support the minimum requirements for the Stripe API. This avoids warnings and errors during upgrade.
61
 
62
- = 1.9.2.1 =
63
  * BUG FIX: Fixed issues with activation on single sites.
64
  * BUG FIX: Starting PHP sessions earlier to fix issues with PayPal/PayPal Express checkouts.
65
 
66
- = 1.9.2 =
67
  * BUG FIX: Fixed issue where Braintree checkouts were failing with a CVV error when existing users checked out.
68
  * BUG FIX: Fixed issue loading the Stripe library in PHP 5.6.
69
  * BUG FIX: Member List CSV export was ignoring search parameter.
@@ -76,13 +93,13 @@ up the lines of text.
76
  * ENHANCEMENT: Improved performance via PHP $_SESSION management improvements. We now only open the session before we set session vars and close the session when we are finished with it.
77
  * ENHANCEMENT: Added to code to stop network activation of Paid Memberships Pro. (Thanks, Paul Barthmaier)
78
 
79
- = 1.9.1 =
80
  * BUG FIX: Fixed the code checking if the Stripe library is already loaded to compatability issues with other plugins bundling the Stripe API library.
81
  * BUG FIX: Cancel code now properly uses preg_replace when sanitizing the list of level ids to cancel.
82
  * FIX/ENHANCEMENT: Removed test/doc code from Stripe and Braintree libraries.
83
  * ENHANCEMENT: Now pausing the license nag for the first week of use and removed the "invalid" error if no key is being used.
84
 
85
- = 1.9 =
86
  * BUG: Fixed issue with cancelling 2Checkout recurring subscriptions. Now using the payment_transaction_id to find/cancel the sale's recurring subscription since no subscription_transaction_id is being saved.
87
  * BUG: Fixed issue where old membership levels were not listed correctly in the cancellation email. (Thanks, Mike from Migrating Eye)
88
  * BUG: Fixed issue where "custom trial" values were not saving for discount codes.
1
  == Changelog ==
2
 
3
+ = 1.9.4.3 - 2018-01-04 =
4
+ * BUG FIX: Fixed issue where PMPro would attempt to cancel gateway subscriptions more than once in some cases.
5
+
6
+ = 1.9.4.2 - 2017-12-07 =
7
+ * BUG FIX: Avoid double-encoding the API version in PayPal Standard gateway
8
+ * BUG FIX: The update billing page now checks the gateway of the user's last order instead of the default gateway settings in case multiple gateways are in use or the default gateway has changed.
9
+ * BUG FIX: Fixed bug where discount codes were not being applied properly if the pmpro_default_level custom field was set and used on a page.
10
+ * BUG FIX: Credit card expiration emails were being to sent to members with PayPal Express orders.
11
+ * BUG FIX: Now correctly unslashing instructions for the check gateway.
12
+ * BUG FIX: Fixed issue with creating pages from the page settings page.
13
+ * BUG FIX/ENHANCEMENT: Improved submit button and processing message position for default and RTL on checkout page.
14
+ * BUG FIX/ENHANCEMENT: Added invoice total and total billed breakdown back to confirmation and invoice single views.
15
+ * BUG FIX/ENHANCEMENT: Avoid double-encoding the PayPal API version number
16
+ * ENHANCEMENT: Improved submit button and processing message position for default and RTL on checkout page.
17
+ * ENHANCEMENT: Switched order of Publishable and Secret Key fields and added validation check.
18
+ * ENHANCEMENT: Conditionally update members list headings for expired, cancelled, or old members.
19
+
20
+ = 1.9.4.1 - 2017-10-31 =
21
  * BUG FIX: Fixed serious bug where payment fields weren't showing up for the Braintree gateway.
22
  * BUG FIX: Fixed issue where Braintree webhook notifications were failing. We now allow the Braintree library to sanitize the incoming data since our sanitizing efforts were breaking the validation.
23
  * BUG FIX/ENHANCEMENT: The webhook URL given for Braintree now goes through admin-ajax.php instead of a direct link to a php file within our plugin.
24
  * BUG FIX/ENHANCEMENT: Updates to the Recaptcha library. (Thanks, Corin Simpson-Bryars)
25
  * ENHANCEMENT: Made the cancelation failed error email easier to read.
26
 
27
+ = 1.9.4 - 2017-10-26 =
28
  * BUG FIX: Fixed issue where PayPal was not working for amounts over $1000.
29
  * BUG FIX: Non-decimal currencies now handled correctly with Stripe.
30
  * BUG FIX: Fixed issue where updating a Stripe subscription from the edit user page could cancel the subscription once the webhook fired.
63
  * ENHANCEMENT: Added Portuguese language files. (Thanks, Secundino Correia)
64
  * ENHANCEMENT: Updated plugin admin pages with better links to documentation and support.
65
 
66
+ = 1.9.3 - 2017-07-06 =
67
  * SECURITY: Fixed sanitization of inputs and added nonces in several places to protect against XSS attacks.
68
  * BUG FIX: Showing correct error message when trying to update a PMPro Plus add on with a Core license installed.
69
  * BUG FIX: Fixed issue where subscription and payment transaction IDs were not being saved correctly when copying an order in the dashboard. (Thanks, Pippin Williamson)
72
  * ENHANCEMENT: Added a pmpro_sanitize_with_safelist() function that is used to sanitize inputs that have a limited number of exact options.
73
  * ENHANCEMENT: Updated the pmpro_setOption() and pmpro_getParam() functions to take a new last parameter $sanitize_function, which defaults to 'sanitize_text_field'.
74
 
75
+ = 1.9.2.2 - 2017-06-13 =
76
  * BUG FIX: Fixed warnings on the Network Dashboard's sites page.
77
  * BUG FIX: Skipping update scripts that require the Stripe library if the system doesn't support the minimum requirements for the Stripe API. This avoids warnings and errors during upgrade.
78
 
79
+ = 1.9.2.1 - 2017-06-05 =
80
  * BUG FIX: Fixed issues with activation on single sites.
81
  * BUG FIX: Starting PHP sessions earlier to fix issues with PayPal/PayPal Express checkouts.
82
 
83
+ = 1.9.2 - 2017-06-03 =
84
  * BUG FIX: Fixed issue where Braintree checkouts were failing with a CVV error when existing users checked out.
85
  * BUG FIX: Fixed issue loading the Stripe library in PHP 5.6.
86
  * BUG FIX: Member List CSV export was ignoring search parameter.
93
  * ENHANCEMENT: Improved performance via PHP $_SESSION management improvements. We now only open the session before we set session vars and close the session when we are finished with it.
94
  * ENHANCEMENT: Added to code to stop network activation of Paid Memberships Pro. (Thanks, Paul Barthmaier)
95
 
96
+ = 1.9.1 - 2017-05-11 =
97
  * BUG FIX: Fixed the code checking if the Stripe library is already loaded to compatability issues with other plugins bundling the Stripe API library.
98
  * BUG FIX: Cancel code now properly uses preg_replace when sanitizing the list of level ids to cancel.
99
  * FIX/ENHANCEMENT: Removed test/doc code from Stripe and Braintree libraries.
100
  * ENHANCEMENT: Now pausing the license nag for the first week of use and removed the "invalid" error if no key is being used.
101
 
102
+ = 1.9 - 2017-04-26 =
103
  * BUG: Fixed issue with cancelling 2Checkout recurring subscriptions. Now using the payment_transaction_id to find/cancel the sale's recurring subscription since no subscription_transaction_id is being saved.
104
  * BUG: Fixed issue where old membership levels were not listed correctly in the cancellation email. (Thanks, Mike from Migrating Eye)
105
  * BUG: Fixed issue where "custom trial" values were not saving for discount codes.
classes/class.memberorder.php CHANGED
@@ -711,17 +711,15 @@
711
  /**
712
  * Cancel an order and call the cancel step of the gateway class if needed.
713
  */
714
- function cancel()
715
- {
 
716
  //only need to cancel on the gateway if there is a subscription id
717
- if(empty($this->subscription_transaction_id))
718
- {
719
  //just mark as cancelled
720
  $this->updateStatus("cancelled");
721
  return true;
722
- }
723
- else
724
- {
725
  //get some data
726
  $order_user = get_userdata($this->user_id);
727
 
@@ -732,8 +730,7 @@
732
  $result = false;
733
  }
734
 
735
- if($result == false)
736
- {
737
  //there was an error, but cancel the order no matter what
738
  $this->updateStatus("cancelled");
739
 
@@ -747,20 +744,33 @@
747
  $pmproemail->data["body"] .= '<p>' . __('Gateway', 'paid-memberships-pro') . ': ' . $this->gateway . '</p>';
748
  $pmproemail->data["body"] .= '<p>' . __('Subscription Transaction ID', 'paid-memberships-pro') . ': ' . $this->subscription_transaction_id . '</p>';
749
  $pmproemail->sendEmail(get_bloginfo("admin_email"));
750
-
751
- return false;
752
- }
753
- else
754
- {
755
  //Note: status would have been set to cancelled by the gateway class. So we don't have to update it here.
756
 
757
- //remove billing numbers in pmpro_memberships_users if the membership is still active
758
- global $wpdb;
759
  $sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET initial_payment = 0, billing_amount = 0, cycle_number = 0 WHERE user_id = '" . $this->user_id . "' AND membership_id = '" . $this->membership_id . "' AND status = 'active'";
760
  $wpdb->query($sqlQuery);
761
-
762
- return $result;
763
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
  }
765
  }
766
 
711
  /**
712
  * Cancel an order and call the cancel step of the gateway class if needed.
713
  */
714
+ function cancel() {
715
+ global $wpdb;
716
+
717
  //only need to cancel on the gateway if there is a subscription id
718
+ if(empty($this->subscription_transaction_id)) {
 
719
  //just mark as cancelled
720
  $this->updateStatus("cancelled");
721
  return true;
722
+ } else {
 
 
723
  //get some data
724
  $order_user = get_userdata($this->user_id);
725
 
730
  $result = false;
731
  }
732
 
733
+ if($result == false) {
 
734
  //there was an error, but cancel the order no matter what
735
  $this->updateStatus("cancelled");
736
 
744
  $pmproemail->data["body"] .= '<p>' . __('Gateway', 'paid-memberships-pro') . ': ' . $this->gateway . '</p>';
745
  $pmproemail->data["body"] .= '<p>' . __('Subscription Transaction ID', 'paid-memberships-pro') . ': ' . $this->subscription_transaction_id . '</p>';
746
  $pmproemail->sendEmail(get_bloginfo("admin_email"));
747
+ } else {
 
 
 
 
748
  //Note: status would have been set to cancelled by the gateway class. So we don't have to update it here.
749
 
750
+ //remove billing numbers in pmpro_memberships_users if the membership is still active
 
751
  $sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET initial_payment = 0, billing_amount = 0, cycle_number = 0 WHERE user_id = '" . $this->user_id . "' AND membership_id = '" . $this->membership_id . "' AND status = 'active'";
752
  $wpdb->query($sqlQuery);
 
 
753
  }
754
+
755
+ //cancel orders for the same subscription
756
+ $sqlQuery = $wpdb->prepare(
757
+ "UPDATE $wpdb->pmpro_membership_orders
758
+ SET `status` = 'cancelled'
759
+ WHERE user_id = %d
760
+ AND membership_id = %d
761
+ AND gateway = %s
762
+ AND gateway_environment = %s
763
+ AND subscription_transaction_id = %s
764
+ AND `status` IN('success', '') ",
765
+ $this->user_id,
766
+ $this->membership_id,
767
+ $this->gateway,
768
+ $this->gateway_environment,
769
+ $this->subscription_transaction_id
770
+ );
771
+ $wpdb->query($sqlQuery);
772
+
773
+ return $result;
774
  }
775
  }
776
 
includes/functions.php CHANGED
@@ -1054,24 +1054,29 @@ function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status
1054
  if(!empty($cancel_level)) {
1055
  $pmpro_cancel_previous_subscriptions = true; //don't filter cause we're doing just the one
1056
 
1057
- $other_order_ids = $wpdb->get_col("SELECT id FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' AND status = 'success' AND membership_id = '" . esc_sql($cancel_level) . "' ORDER BY id DESC");
1058
  } else {
1059
  $pmpro_cancel_previous_subscriptions = true;
1060
  if(isset($_REQUEST['cancel_membership']) && $_REQUEST['cancel_membership'] == false)
1061
  $pmpro_cancel_previous_subscriptions = false;
1062
  $pmpro_cancel_previous_subscriptions = apply_filters("pmpro_cancel_previous_subscriptions", $pmpro_cancel_previous_subscriptions);
1063
 
1064
- $other_order_ids = $wpdb->get_col("SELECT id FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' AND status = 'success' ORDER BY id DESC");
 
 
 
 
 
1065
  }
1066
 
1067
  $other_order_ids = apply_filters("pmpro_other_order_ids_to_cancel", $other_order_ids);
1068
-
1069
  //cancel any other subscriptions they have (updates pmpro_membership_orders table)
1070
  if($pmpro_cancel_previous_subscriptions && !empty($other_order_ids))
1071
  {
1072
  foreach($other_order_ids as $order_id)
1073
  {
1074
- $c_order = new MemberOrder($order_id);
1075
  $c_order->cancel();
1076
 
1077
  if(!empty($c_order->error))
1054
  if(!empty($cancel_level)) {
1055
  $pmpro_cancel_previous_subscriptions = true; //don't filter cause we're doing just the one
1056
 
1057
+ $other_order_ids = $wpdb->get_col("SELECT id FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' AND status = 'success' AND membership_id = '" . esc_sql($cancel_level) . "' ORDER BY id DESC LIMIT 1");
1058
  } else {
1059
  $pmpro_cancel_previous_subscriptions = true;
1060
  if(isset($_REQUEST['cancel_membership']) && $_REQUEST['cancel_membership'] == false)
1061
  $pmpro_cancel_previous_subscriptions = false;
1062
  $pmpro_cancel_previous_subscriptions = apply_filters("pmpro_cancel_previous_subscriptions", $pmpro_cancel_previous_subscriptions);
1063
 
1064
+ $other_order_ids = $wpdb->get_col("SELECT id, IF(subscription_transaction_id = '', CONCAT('UNIQUE_SUB_ID_', id), subscription_transaction_id) as unique_sub_id
1065
+ FROM $wpdb->pmpro_membership_orders
1066
+ WHERE user_id = '" . $user_id . "'
1067
+ AND status = 'success'
1068
+ GROUP BY unique_sub_id
1069
+ ORDER BY id DESC");
1070
  }
1071
 
1072
  $other_order_ids = apply_filters("pmpro_other_order_ids_to_cancel", $other_order_ids);
1073
+
1074
  //cancel any other subscriptions they have (updates pmpro_membership_orders table)
1075
  if($pmpro_cancel_previous_subscriptions && !empty($other_order_ids))
1076
  {
1077
  foreach($other_order_ids as $order_id)
1078
  {
1079
+ $c_order = new MemberOrder($order_id);
1080
  $c_order->cancel();
1081
 
1082
  if(!empty($c_order->error))
paid-memberships-pro.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Paid Memberships Pro
4
  Plugin URI: http://www.paidmembershipspro.com
5
  Description: Plugin to Handle Memberships
6
- Version: 1.9.4.2
7
  Author: Stranger Studios
8
  Author URI: http://www.strangerstudios.com
9
  Text Domain: paid-memberships-pro
@@ -15,7 +15,7 @@ Domain Path: /languages
15
  */
16
 
17
  // version constant
18
- define( 'PMPRO_VERSION', '1.9.4.2' );
19
  define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
20
  define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
21
 
3
  Plugin Name: Paid Memberships Pro
4
  Plugin URI: http://www.paidmembershipspro.com
5
  Description: Plugin to Handle Memberships
6
+ Version: 1.9.4.3
7
  Author: Stranger Studios
8
  Author URI: http://www.strangerstudios.com
9
  Text Domain: paid-memberships-pro
15
  */
16
 
17
  // version constant
18
+ define( 'PMPRO_VERSION', '1.9.4.3' );
19
  define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
20
  define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
21
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: strangerstudios
3
  Tags: membership, memberships, member, members, ecommerce, e-commerce, paypal, stripe, braintree, authorize.net, payflow, restrict access, restrict content, directory
4
  Requires at least: 4
5
  Tested up to: 4.9.1
6
- Stable tag: 1.9.4.2
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
@@ -129,6 +129,9 @@ Not sure? You can find out by doing a bit a research.
129
 
130
  == Changelog ==
131
 
 
 
 
132
  = 1.9.4.2 - 2017-12-07 =
133
  * BUG FIX: Avoid double-encoding the API version in PayPal Standard gateway
134
  * BUG FIX: The update billing page now checks the gateway of the user's last order instead of the default gateway settings in case multiple gateways are in use or the default gateway has changed.
3
  Tags: membership, memberships, member, members, ecommerce, e-commerce, paypal, stripe, braintree, authorize.net, payflow, restrict access, restrict content, directory
4
  Requires at least: 4
5
  Tested up to: 4.9.1
6
+ Stable tag: 1.9.4.3
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
129
 
130
  == Changelog ==
131
 
132
+ = 1.9.4.3 - 2018-01-04 =
133
+ * BUG FIX: Fixed issue where PMPro would attempt to cancel gateway subscriptions more than once in some cases.
134
+
135
  = 1.9.4.2 - 2017-12-07 =
136
  * BUG FIX: Avoid double-encoding the API version in PayPal Standard gateway
137
  * BUG FIX: The update billing page now checks the gateway of the user's last order instead of the default gateway settings in case multiple gateways are in use or the default gateway has changed.