Mollie Payments for WooCommerce - Version 3.0.3

Version Description

  • 14/05/2018 =

  • Note - If you use Polylang or another multilanguage plugin, read this FAQ item!

  • Fix - Polylang: Received all versions of Polylang from Frederic, made sure our integration works with all combinations

  • Fix - Order confirmation/Thank you page (issue #206):

    • Show pending payment message for open and pending payments, not just open
    • Show payment instructions and pending payment message in WooCommerce notice style, so shop-customers notice it better
    • Make sure pending payment message is also shown for creditcard, PayPal and Sofort payments
  • Fix - Redirect to checkout payment URL (retry payment) more often, also for failed payments

Download this release

Release Info

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

Code changes from version 3.0.2 to 3.0.3

includes/mollie/wc/gateway/abstract.php CHANGED
@@ -291,23 +291,26 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
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
  }
@@ -1051,10 +1054,25 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1051
  /*
1052
  * Return to cart
1053
  */
 
 
 
 
 
 
 
 
 
 
 
 
1054
 
1055
- return WC()->cart->get_checkout_url();
 
1056
 
 
1057
  }
 
1058
  }
1059
 
1060
  /*
@@ -1203,8 +1221,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1203
  }
1204
  else
1205
  {
1206
- echo '<section class="woocommerce-order-details mollie-instructions abc">';
1207
- echo '<h2 class="woocommerce-order-details__title">' . __('Payment', 'mollie-payments-for-woocommerce') . '</h2>';
1208
  echo wpautop($instructions) . PHP_EOL;
1209
  echo '</section>';
1210
  }
@@ -1221,7 +1238,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1221
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
1222
  {
1223
  // No definite payment status
1224
- if ($payment->isOpen())
1225
  {
1226
  if ($admin_instructions)
1227
  {
@@ -1505,38 +1522,46 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1505
  return $url;
1506
  }
1507
 
1508
- /**
1509
- * Check if any multi language plugins are enabled and return the correct site url.
1510
- *
1511
- * @return string
1512
- */
1513
- protected function getSiteUrlWithLanguage()
1514
- {
1515
- /**
1516
- * function is_plugin_active() is not available. Lets include it to use it.
1517
- */
1518
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1519
 
1520
- $site_url = get_site_url();
1521
- $slug = ''; // default is NO slug/language
1522
 
1523
- if (is_plugin_active('polylang/polylang.php')
1524
- || is_plugin_active('polylang-pro/polylang-pro.php')
1525
- || is_plugin_active('mlang/mlang.php')
1526
- || is_plugin_active('mlanguage/mlanguage.php')
1527
- )
1528
- {
1529
- // we probably have a multilang site. Retrieve current language.
1530
- $slug = get_bloginfo('language');
1531
- $pos = strpos($slug, '-');
1532
- if ($pos !== false)
1533
- $slug = substr($slug, 0, $pos);
1534
-
1535
- $slug = '/' . $slug;
1536
- }
1537
 
1538
- return str_replace($site_url, $site_url . $slug, $site_url);
1539
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1540
 
1541
  /**
1542
  * @return string|NULL
@@ -1664,15 +1689,20 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
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
 
291
  // If WooCommerce Subscriptions is installed, also check recurring order total
292
  if ( class_exists( 'WC_Subscriptions' ) ) {
293
 
294
+ $recurring_total = $this->get_recurring_total();
295
+
296
+ if ( $recurring_total != false ) {
297
+ foreach ( $recurring_total as $order_total ) {
298
+
299
+ // If order total is more then zero, check min/max amounts
300
+ if ( $order_total > 0 ) {
301
+ // Validate min amount
302
+ if ( 0 < $this->min_amount && $this->min_amount > $order_total ) {
303
+ return false;
304
+ }
305
+
306
+ // Validate max amount
307
+ if ( 0 < $this->max_amount && $this->max_amount < $order_total ) {
308
+ return false;
309
+ }
310
  }
311
 
 
 
 
 
312
  }
 
313
  }
 
314
  }
315
 
316
  }
1054
  /*
1055
  * Return to cart
1056
  */
1057
+ if ( version_compare( WC_VERSION, '2.5', '<' ) ) {
1058
+ return WC()->cart->get_checkout_url();
1059
+ } else {
1060
+ return $order->get_checkout_payment_url( false );
1061
+ }
1062
+ }
1063
+
1064
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
1065
+ $payment = Mollie_WC_Plugin::getDataHelper()->getActiveMolliePayment($order->id);
1066
+ } else {
1067
+ $payment = Mollie_WC_Plugin::getDataHelper()->getActiveMolliePayment($order->get_id());
1068
+ }
1069
 
1070
+ if ( ! $payment->isOpen() && ! $payment->isPending() ) {
1071
+ Mollie_WC_Plugin::addNotice( __( 'Your payment was not successful. Please complete your order with a different payment method.', 'mollie-payments-for-woocommerce' ) );
1072
 
1073
+ return $order->get_checkout_payment_url( false );
1074
  }
1075
+
1076
  }
1077
 
1078
  /*
1221
  }
1222
  else
1223
  {
1224
+ echo '<section class="woocommerce-order-details woocommerce-info mollie-instructions" >';
 
1225
  echo wpautop($instructions) . PHP_EOL;
1226
  echo '</section>';
1227
  }
1238
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
1239
  {
1240
  // No definite payment status
1241
+ if ($payment->isOpen() || $payment->isPending())
1242
  {
1243
  if ($admin_instructions)
1244
  {
1522
  return $url;
1523
  }
1524
 
1525
+ /**
1526
+ * Check if any multi language plugins are enabled and return the correct site url.
1527
+ *
1528
+ * @return string
1529
+ */
1530
+ protected function getSiteUrlWithLanguage() {
1531
+ /**
1532
+ * function is_plugin_active() is not available. Lets include it to use it.
1533
+ */
1534
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 
1535
 
1536
+ $site_url = get_site_url();
1537
+ $polylang_fallback = false;
1538
 
1539
+ if ( is_plugin_active( 'polylang/polylang.php' ) || is_plugin_active( 'polylang-pro/polylang.php' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
1540
 
1541
+ $lang = PLL()->model->get_language( pll_current_language() );
1542
+
1543
+ if ( empty ( $lang->search_url ) ) {
1544
+ $polylang_fallback = true;
1545
+ } else {
1546
+ $polylang_url = $lang->search_url;
1547
+ $site_url = str_replace( $site_url, $polylang_url, $site_url );
1548
+ }
1549
+ }
1550
+
1551
+ if ( $polylang_fallback == true || is_plugin_active( 'mlang/mlang.php' ) || is_plugin_active( 'mlanguage/mlanguage.php' ) ) {
1552
+
1553
+ $slug = get_bloginfo( 'language' );
1554
+ $pos = strpos( $slug, '-' );
1555
+ if ( $pos !== false ) {
1556
+ $slug = substr( $slug, 0, $pos );
1557
+ }
1558
+ $slug = '/' . $slug;
1559
+ $site_url = str_replace( $site_url, $site_url . $slug, $site_url );
1560
+
1561
+ }
1562
+
1563
+ return $site_url;
1564
+ }
1565
 
1566
  /**
1567
  * @return string|NULL
1689
 
1690
  if ( isset( WC()->cart ) ) {
1691
 
1692
+ if ( ! empty( WC()->cart->recurring_carts ) ) {
1693
 
1694
+ $this->recurring_total = array (); // Reset for cached carts
1695
 
1696
+ foreach ( WC()->cart->recurring_carts as $cart ) {
1697
+
1698
+ if ( ! $cart->prices_include_tax ) {
1699
+ $this->recurring_total[] = $cart->cart_contents_total;
1700
+ } else {
1701
+ $this->recurring_total[] = $cart->cart_contents_total + $cart->tax_total;
1702
+ }
1703
  }
1704
+ } else {
1705
+ return false;
1706
  }
1707
  }
1708
 
includes/mollie/wc/gateway/creditcard.php CHANGED
@@ -56,17 +56,16 @@ class Mollie_WC_Gateway_Creditcard extends Mollie_WC_Gateway_AbstractSubscriptio
56
  */
57
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
58
  {
59
- $instructions = '';
60
-
61
  if ($payment->isPaid() && $payment->details)
62
  {
63
- $instructions .= sprintf(
64
  /* translators: Placeholder 1: card holder */
65
  __('Payment completed by <strong>%s</strong>', 'mollie-payments-for-woocommerce'),
66
  $payment->details->cardHolder
67
  );
68
  }
69
 
70
- return $instructions;
 
71
  }
72
  }
56
  */
57
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
58
  {
 
 
59
  if ($payment->isPaid() && $payment->details)
60
  {
61
+ return sprintf(
62
  /* translators: Placeholder 1: card holder */
63
  __('Payment completed by <strong>%s</strong>', 'mollie-payments-for-woocommerce'),
64
  $payment->details->cardHolder
65
  );
66
  }
67
 
68
+ return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
69
+
70
  }
71
  }
includes/mollie/wc/gateway/paypal.php CHANGED
@@ -54,11 +54,9 @@ class Mollie_WC_Gateway_PayPal extends Mollie_WC_Gateway_Abstract
54
  */
55
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
56
  {
57
- $instructions = '';
58
-
59
  if ($payment->isPaid() && $payment->details)
60
  {
61
- $instructions .= sprintf(
62
  /* translators: Placeholder 1: PayPal consumer name, placeholder 2: PayPal email, placeholder 3: PayPal transaction ID */
63
  __("Payment completed by <strong>%s</strong> - %s (PayPal transaction ID: %s)", 'mollie-payments-for-woocommerce'),
64
  $payment->details->consumerName,
@@ -67,6 +65,7 @@ class Mollie_WC_Gateway_PayPal extends Mollie_WC_Gateway_Abstract
67
  );
68
  }
69
 
70
- return $instructions;
 
71
  }
72
  }
54
  */
55
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
56
  {
 
 
57
  if ($payment->isPaid() && $payment->details)
58
  {
59
+ return sprintf(
60
  /* translators: Placeholder 1: PayPal consumer name, placeholder 2: PayPal email, placeholder 3: PayPal transaction ID */
61
  __("Payment completed by <strong>%s</strong> - %s (PayPal transaction ID: %s)", 'mollie-payments-for-woocommerce'),
62
  $payment->details->consumerName,
65
  );
66
  }
67
 
68
+ return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
69
+
70
  }
71
  }
includes/mollie/wc/gateway/sofort.php CHANGED
@@ -54,11 +54,9 @@ class Mollie_WC_Gateway_Sofort extends Mollie_WC_Gateway_AbstractSepaRecurring
54
  */
55
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
56
  {
57
- $instructions = '';
58
-
59
  if ($payment->isPaid() && $payment->details)
60
  {
61
- $instructions .= sprintf(
62
  /* translators: Placeholder 1: consumer name, placeholder 2: consumer IBAN, placeholder 3: consumer BIC */
63
  __('Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)', 'mollie-payments-for-woocommerce'),
64
  $payment->details->consumerName,
@@ -67,6 +65,6 @@ class Mollie_WC_Gateway_Sofort extends Mollie_WC_Gateway_AbstractSepaRecurring
67
  );
68
  }
69
 
70
- return $instructions;
71
  }
72
  }
54
  */
55
  protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
56
  {
 
 
57
  if ($payment->isPaid() && $payment->details)
58
  {
59
+ return sprintf(
60
  /* translators: Placeholder 1: consumer name, placeholder 2: consumer IBAN, placeholder 3: consumer BIC */
61
  __('Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)', 'mollie-payments-for-woocommerce'),
62
  $payment->details->consumerName,
65
  );
66
  }
67
 
68
+ return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
69
  }
70
  }
includes/mollie/wc/helper/settings.php CHANGED
@@ -409,7 +409,7 @@ class Mollie_WC_Helper_Settings
409
  'id' => $this->getSettingId('customer_details'),
410
  'title' => __('Store customer details at Mollie', 'mollie-payments-for-woocommerce'),
411
  /* translators: Placeholder 1: enabled or disabled */
412
- 'desc' => sprintf(__('Should Mollie store customers name and email address for Single Click Payments? Default <code>%s</code>', 'mollie-payments-for-woocommerce'), strtolower(__('Enabled', 'mollie-payments-for-woocommerce'))),
413
  'type' => 'checkbox',
414
  'default' => 'yes',
415
 
409
  'id' => $this->getSettingId('customer_details'),
410
  'title' => __('Store customer details at Mollie', 'mollie-payments-for-woocommerce'),
411
  /* translators: Placeholder 1: enabled or disabled */
412
+ 'desc' => sprintf(__('Should Mollie store customers name and email address for Single Click Payments? Default <code>%s</code>. Required if WooCommerce Subscriptions is being used!', 'mollie-payments-for-woocommerce'), strtolower(__('Enabled', 'mollie-payments-for-woocommerce'))),
413
  'type' => 'checkbox',
414
  'default' => 'yes',
415
 
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.2';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -321,37 +321,33 @@ class Mollie_WC_Plugin
321
  return array_merge($gateways, self::$GATEWAYS);
322
  }
323
 
324
- /**
325
- * Add a WooCommerce notification message
326
- *
327
- * @param string $message Notification message
328
- * @param string $type One of notice, error or success (default notice)
329
- * @return $this
330
- */
331
- public static function addNotice ($message, $type = 'notice')
332
- {
333
- $type = in_array($type, array('notice','error','success')) ? $type : 'notice';
334
-
335
- // Check for existence of new notification api (WooCommerce >= 2.1)
336
- if (function_exists('wc_add_notice'))
337
- {
338
- wc_add_notice($message, $type);
339
- }
340
- else
341
- {
342
- $woocommerce = WooCommerce::instance();
343
 
344
- switch ($type)
345
- {
346
- case 'error' :
347
- $woocommerce->add_error($message);
348
- break;
349
- default :
350
- $woocommerce->add_message($message);
351
- break;
352
- }
353
- }
354
- }
 
 
 
 
 
355
 
356
  /**
357
  * Log messages to WooCommerce log
@@ -522,13 +518,12 @@ class Mollie_WC_Plugin
522
 
523
  // Can't use $wp->request or is_wc_endpoint_url() to check if this code only runs on /subscriptions and /view-subscriptions,
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 ] );
7
  {
8
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
9
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
10
+ const PLUGIN_VERSION = '3.0.3';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
321
  return array_merge($gateways, self::$GATEWAYS);
322
  }
323
 
324
+ /**
325
+ * Add a WooCommerce notification message
326
+ *
327
+ * @param string $message Notification message
328
+ * @param string $type One of notice, error or success (default notice)
329
+ *
330
+ * @return $this
331
+ */
332
+ public static function addNotice( $message, $type = 'notice' ) {
333
+ $type = in_array( $type, array ( 'notice', 'error', 'success' ) ) ? $type : 'notice';
 
 
 
 
 
 
 
 
 
334
 
335
+ // Check for existence of new notification api (WooCommerce >= 2.1)
336
+ if ( function_exists( 'wc_add_notice' ) ) {
337
+ wc_add_notice( $message, $type );
338
+ } else {
339
+ $woocommerce = WooCommerce::instance();
340
+
341
+ switch ( $type ) {
342
+ case 'error' :
343
+ $woocommerce->add_error( $message );
344
+ break;
345
+ default :
346
+ $woocommerce->add_message( $message );
347
+ break;
348
+ }
349
+ }
350
+ }
351
 
352
  /**
353
  * Log messages to WooCommerce log
518
 
519
  // Can't use $wp->request or is_wc_endpoint_url() to check if this code only runs on /subscriptions and /view-subscriptions,
520
  // because slugs/endpoints can be translated (with WPML) and other plugins.
521
+ // So disabling on is_account_page (if not checkout, bug in WC) and $_GET['change_payment_method'] for now.
522
 
523
  // Only disable payment methods if WooCommerce Subscriptions is installed
524
  if ( class_exists( 'WC_Subscription' ) ) {
525
+ // Do not disable if account page is also checkout (workaround for bug in WC), do disable on change payment method page (param)
526
  if ( ( ! is_checkout() && is_account_page() ) || ! empty( $_GET['change_payment_method'] ) ) {
 
527
  foreach ( $available_gateways as $key => $value ) {
528
  if ( strpos( $key, 'mollie_' ) !== false ) {
529
  unset( $available_gateways[ $key ] );
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.2
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
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.3
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
readme.txt CHANGED
@@ -3,7 +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
- 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,6 +163,17 @@ Automatic updates should work like a charm; as always though, ensure you backup
163
 
164
  == Changelog ==
165
 
 
 
 
 
 
 
 
 
 
 
 
166
  = 3.0.2 - 07/05/2018 =
167
 
168
  * New - Add extra log message "Start process_payment for order ..."
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.3
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.3 - 14/05/2018 =
167
+
168
+ * Note - If you use Polylang or another multilanguage plugin, read this [FAQ item](https://github.com/mollie/WooCommerce/wiki/Common-issues#issues-with-polylang-or-other-multilanguage-plugins)!
169
+ * Fix - Polylang: Received all versions of Polylang from Frederic, made sure our integration works with all combinations
170
+
171
+ * Fix - Order confirmation/Thank you page ([issue #206](https://github.com/mollie/WooCommerce/issues/206)):
172
+ * Show pending payment message for open and pending payments, not just open
173
+ * Show payment instructions and pending payment message in WooCommerce notice style, so shop-customers notice it better
174
+ * Make sure pending payment message is also shown for creditcard, PayPal and Sofort payments
175
+ * Fix - Redirect to checkout payment URL (retry payment) more often, also for failed payments
176
+
177
  = 3.0.2 - 07/05/2018 =
178
 
179
  * New - Add extra log message "Start process_payment for order ..."