Mollie Payments for WooCommerce - Version 3.0.2

Version Description

  • 07/05/2018 =

  • New - Add extra log message "Start process_payment for order ..."

  • Fix - Fix "Uncaught Error: Call to undefined function wcs_order_contains_renewal()" when users don't have WooCommerce Subscriptions installed

  • Fix - Improve condition(s) for disableMollieOnPaymentMethodChange, make sure not to disable payment methods on checkout (because of is_account_page() false positives, bug in WooCommerce)

  • Fix - Improve is_available() check for minimum/maximum amounts, better check renewal payment amounts

Download this release

Release Info

Developer davdebcom
Plugin Icon wp plugin Mollie Payments for WooCommerce
Version 3.0.2
Comparing to
See all releases

Code changes from version 3.0.1 to 3.0.2

includes/mollie/wc/gateway/abstract.php CHANGED
@@ -268,26 +268,48 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
268
  // Only in WooCommerce checkout, check min/max amounts
269
  if ( WC()->cart ) {
270
 
271
- // Get the regular order total for this order
272
  $order_total = $this->get_order_total();
273
 
274
- // If WooCommerce Subscriptions is installed, get the recurring order total
275
- if ( class_exists( 'WC_Subscriptions_Product' ) ) {
276
- $order_total = $this->get_recurring_total();
277
- }
 
 
 
 
 
278
 
279
- // If order total is more then zero, check min/max amounts
280
- if ( $order_total > 0 ) {
281
- // Validate min amount
282
- if ( 0 < $this->min_amount && $this->min_amount > $order_total ) {
283
- return false;
284
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
- // Validate max amount
287
- if ( 0 < $this->max_amount && $this->max_amount < $order_total ) {
288
- return false;
289
  }
 
290
  }
 
291
  }
292
 
293
  return true;
@@ -323,6 +345,12 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
323
  return array ( 'result' => 'failure' );
324
  }
325
 
 
 
 
 
 
 
326
  $initial_order_status = $this->getInitialOrderStatus();
327
 
328
  // Overwrite plugin-wide
@@ -1636,11 +1664,15 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1636
 
1637
  if ( isset( WC()->cart ) ) {
1638
 
1639
- foreach ( WC()->cart->cart_contents as $item_key => $item ) {
1640
- $item_quantity = $item['quantity'];
1641
- $item_price = WC_Subscriptions_Product::get_price( $item['product_id'] );
1642
- $item_recurring_total = $item_quantity * $item_price;
1643
- $this->recurring_total += $item_recurring_total;
 
 
 
 
1644
  }
1645
  }
1646
 
268
  // Only in WooCommerce checkout, check min/max amounts
269
  if ( WC()->cart ) {
270
 
271
+ // Check the current (normal) order total
272
  $order_total = $this->get_order_total();
273
 
274
+ // Don't check SEPA Direct Debit, as it's only available for recurring payments
275
+ if ( $this->id !== 'mollie_wc_gateway_directdebit' ) {
276
+
277
+ // If order total is more then zero, check min/max amounts
278
+ if ( $order_total > 0 ) {
279
+ // Validate min amount
280
+ if ( 0 < $this->min_amount && $this->min_amount > $order_total ) {
281
+ return false;
282
+ }
283
 
284
+ // Validate max amount
285
+ if ( 0 < $this->max_amount && $this->max_amount < $order_total ) {
286
+ return false;
287
+ }
 
288
  }
289
+ }
290
+
291
+ // If WooCommerce Subscriptions is installed, also check recurring order total
292
+ if ( class_exists( 'WC_Subscriptions' ) ) {
293
+
294
+ foreach ( $this->get_recurring_total() as $order_total ) {
295
+
296
+ // If order total is more then zero, check min/max amounts
297
+ if ( $order_total > 0 ) {
298
+ // Validate min amount
299
+ if ( 0 < $this->min_amount && $this->min_amount > $order_total ) {
300
+ return false;
301
+ }
302
+
303
+ // Validate max amount
304
+ if ( 0 < $this->max_amount && $this->max_amount < $order_total ) {
305
+ return false;
306
+ }
307
+ }
308
 
 
 
 
309
  }
310
+
311
  }
312
+
313
  }
314
 
315
  return true;
345
  return array ( 'result' => 'failure' );
346
  }
347
 
348
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
349
+ Mollie_WC_Plugin::debug( $this->id . ': Start process_payment for order ' . $order->id, true );
350
+ } else {
351
+ Mollie_WC_Plugin::debug( $this->id . ': Start process_payment for order ' . $order->get_id(), true );
352
+ }
353
+
354
  $initial_order_status = $this->getInitialOrderStatus();
355
 
356
  // Overwrite plugin-wide
1664
 
1665
  if ( isset( WC()->cart ) ) {
1666
 
1667
+ $this->recurring_total = array (); // Reset for cached carts
1668
+
1669
+ foreach ( WC()->cart->recurring_carts as $cart ) {
1670
+
1671
+ if ( ! $cart->prices_include_tax ) {
1672
+ $this->recurring_total[] = $cart->cart_contents_total;
1673
+ } else {
1674
+ $this->recurring_total[] = $cart->cart_contents_total + $cart->tax_total;
1675
+ }
1676
  }
1677
  }
1678
 
includes/mollie/wc/gateway/abstractsubscription.php CHANGED
@@ -709,7 +709,7 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
709
  // Add messages to log
710
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $order_id );
711
 
712
- if ( wcs_order_contains_renewal( $order_id ) ) {
713
 
714
  // New order status
715
  $new_order_status = self::STATUS_ON_HOLD;
@@ -735,7 +735,7 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
735
  $restore_stock = false
736
  );
737
 
738
- Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $order_id . ' and payment ' . $payment->id . ', renewal order payment failed, order set to On-Hold for shop-owner review. ' . $mollie_payment_id );
739
 
740
 
741
  // Send a "Failed order" email to notify the admin
709
  // Add messages to log
710
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $order_id );
711
 
712
+ if ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
713
 
714
  // New order status
715
  $new_order_status = self::STATUS_ON_HOLD;
735
  $restore_stock = false
736
  );
737
 
738
+ Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $order_id . ' and payment ' . $payment->id . ', renewal order payment failed, order set to On-Hold for shop-owner review.' );
739
 
740
 
741
  // Send a "Failed order" email to notify the admin
includes/mollie/wc/plugin.php CHANGED
@@ -7,7 +7,7 @@ class Mollie_WC_Plugin
7
  {
8
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
9
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
10
- const PLUGIN_VERSION = '3.0.1';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -524,13 +524,17 @@ class Mollie_WC_Plugin
524
  // because slugs/endpoints can be translated (with WPML) and other plugins.
525
  // So disabling on is_account_page and $_GET['change_payment_method'] for now.
526
 
527
- if ( is_account_page() || ! empty( $_GET['change_payment_method'] ) ) {
528
- foreach ( $available_gateways as $key => $value ) {
529
- if ( strpos( $key, 'mollie_' ) !== false ) {
530
- unset( $available_gateways[ $key ] );
 
 
 
 
 
531
  }
532
  }
533
-
534
  }
535
 
536
  return $available_gateways;
7
  {
8
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
9
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
10
+ const PLUGIN_VERSION = '3.0.2';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
524
  // because slugs/endpoints can be translated (with WPML) and other plugins.
525
  // So disabling on is_account_page and $_GET['change_payment_method'] for now.
526
 
527
+ // Only disable payment methods if WooCommerce Subscriptions is installed
528
+ if ( class_exists( 'WC_Subscription' ) ) {
529
+ // Do not disable is account page is also checkout, do disable on change payment method page (param)
530
+ if ( ( ! is_checkout() && is_account_page() ) || ! empty( $_GET['change_payment_method'] ) ) {
531
+ // Final check, disable on is_account_page and on Change payment method
532
+ foreach ( $available_gateways as $key => $value ) {
533
+ if ( strpos( $key, 'mollie_' ) !== false ) {
534
+ unset( $available_gateways[ $key ] );
535
+ }
536
  }
537
  }
 
538
  }
539
 
540
  return $available_gateways;
mollie-payments-for-woocommerce.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Mollie Payments for WooCommerce
4
  * Plugin URI: https://www.mollie.com
5
  * Description: Accept payments in WooCommerce with the official Mollie plugin
6
- * Version: 3.0.1
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
@@ -12,7 +12,7 @@
12
  * Domain Path: /i18n/languages/
13
  * License: GPLv2 or later
14
  * WC requires at least: 2.2.0
15
- * WC tested up to: 3.3
16
  */
17
 
18
  // Exit if accessed directly.
3
  * Plugin Name: Mollie Payments for WooCommerce
4
  * Plugin URI: https://www.mollie.com
5
  * Description: Accept payments in WooCommerce with the official Mollie plugin
6
+ * Version: 3.0.2
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
12
  * Domain Path: /i18n/languages/
13
  * License: GPLv2 or later
14
  * WC requires at least: 2.2.0
15
+ * WC tested up to: 3.4
16
  */
17
 
18
  // Exit if accessed directly.
readme.txt CHANGED
@@ -3,8 +3,7 @@ Contributors: daanvm, davdebcom, l.vangunst, ndijkstra, robin-mollie
3
  Tags: mollie, payments, woocommerce, payment gateway, e-commerce, credit card, ideal, sofort, bancontact, bitcoin, direct debit, subscriptions
4
  Requires at least: 3.8
5
  Tested up to: 4.9
6
- Requires PHP: 5.3
7
- Stable tag: 3.0.1
8
  Requires PHP: 5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -164,6 +163,13 @@ Automatic updates should work like a charm; as always though, ensure you backup
164
 
165
  == Changelog ==
166
 
 
 
 
 
 
 
 
167
  = 3.0.1 - 17/04/2018 =
168
 
169
  * [Fix/Revert, see issue 173](https://github.com/mollie/WooCommerce/issues/173) - Improve support for Polylang option "Hide URL language information for default language" in webhook and return URLs
3
  Tags: mollie, payments, woocommerce, payment gateway, e-commerce, credit card, ideal, sofort, bancontact, bitcoin, direct debit, subscriptions
4
  Requires at least: 3.8
5
  Tested up to: 4.9
6
+ Stable tag: 3.0.2
 
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
163
 
164
  == Changelog ==
165
 
166
+ = 3.0.2 - 07/05/2018 =
167
+
168
+ * New - Add extra log message "Start process_payment for order ..."
169
+ * Fix - Fix "Uncaught Error: Call to undefined function wcs_order_contains_renewal()" when users don't have WooCommerce Subscriptions installed
170
+ * Fix - Improve condition(s) for disableMollieOnPaymentMethodChange, make sure not to disable payment methods on checkout (because of is_account_page() false positives, bug in WooCommerce)
171
+ * Fix - Improve is_available() check for minimum/maximum amounts, better check renewal payment amounts
172
+
173
  = 3.0.1 - 17/04/2018 =
174
 
175
  * [Fix/Revert, see issue 173](https://github.com/mollie/WooCommerce/issues/173) - Improve support for Polylang option "Hide URL language information for default language" in webhook and return URLs