Mollie Payments for WooCommerce - Version 2.8.1

Version Description

  • 15/01/2018 =

  • New - iDEAL, KBC, Gift cards: Option to hide issuers/bank list in WooCommerce

  • New - Allow subscription switching (downgrade) when amount to pay is 0 and there is a valid mandate for the user

  • Fix - A new customerID was created for every new order where a payment method that supported recurring payments was selected

  • Fix - When plugin 2.8.0 was used with WooCommerce 2.6 or older, a fatal error would be shown on the return page (because of use of new WooCommerce 3.0 method)

  • Fix - Some cancelled payments for cancelled orders where redirected to "Retry payment" instead of "Order received" page, see Github issue #166

Download this release

Release Info

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

Code changes from version 2.8.0 to 2.8.1

includes/mollie/wc/gateway/abstract.php CHANGED
@@ -74,6 +74,11 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
74
  add_filter( 'the_title', array ( $this, 'onOrderReceivedTitle' ), 10, 2 );
75
  add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'onOrderReceivedText'), 10, 2 );
76
 
 
 
 
 
 
77
  if (!$this->isValidForUse())
78
  {
79
  // Disable gateway if it's not valid for use
@@ -320,8 +325,50 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
320
 
321
  $data = apply_filters('woocommerce_' . $this->id . '_args', $data, $order);
322
 
323
- try
324
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
326
  Mollie_WC_Plugin::debug( $this->id . ': Create payment for order ' . $order->id, true );
327
  } else {
@@ -911,27 +958,40 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
911
 
912
  }
913
 
914
- /**
915
- * @param WC_Order $order
916
- * @return string
917
- */
 
918
  public function getReturnRedirectUrlForOrder( WC_Order $order ) {
919
  $data_helper = Mollie_WC_Plugin::getDataHelper();
920
 
921
-
922
  if ( $this->orderNeedsPayment( $order ) ) {
923
 
924
  $hasCancelledMolliePayment = ( version_compare( WC_VERSION, '3.0', '<' ) ) ? $data_helper->hasCancelledMolliePayment( $order->id ) : $data_helper->hasCancelledMolliePayment( $order->get_id() );;
925
 
926
  if ( $hasCancelledMolliePayment ) {
927
 
928
- Mollie_WC_Plugin::addNotice( __( 'You have cancelled your payment. Please complete your order with a different payment method.', 'mollie-payments-for-woocommerce' ) );
 
929
 
930
- if ( method_exists( $order, 'get_checkout_payment_url' ) ) {
931
- /*
932
- * Return to order payment page
933
- */
934
- return $order->get_checkout_payment_url( false );
 
 
 
 
 
 
 
 
 
 
 
 
935
  }
936
 
937
  /*
@@ -1142,7 +1202,14 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1142
  $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
1143
  if ( $order_id > 0 ) {
1144
  $order = wc_get_order( $order_id );
1145
- if ( $order->get_order_key() != $order_key ) {
 
 
 
 
 
 
 
1146
  $order = false;
1147
  }
1148
  }
@@ -1458,4 +1525,15 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1458
  * @return string
1459
  */
1460
  abstract protected function getDefaultDescription ();
 
 
 
 
 
 
 
 
 
 
 
1461
  }
74
  add_filter( 'the_title', array ( $this, 'onOrderReceivedTitle' ), 10, 2 );
75
  add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'onOrderReceivedText'), 10, 2 );
76
 
77
+ /* Override show issuers dropdown? */
78
+ if ( $this->get_option( 'issuers_dropdown_shown', 'yes' ) == 'no' ) {
79
+ $this->has_fields = false;
80
+ }
81
+
82
  if (!$this->isValidForUse())
83
  {
84
  // Disable gateway if it's not valid for use
325
 
326
  $data = apply_filters('woocommerce_' . $this->id . '_args', $data, $order);
327
 
328
+ // If this is a subscription switch and customer has a valid mandate, process the order internally
329
+ try {
330
+
331
+ if ( ( '0.00' === $order->get_total() ) && ( $this->is_subscription( $order_id ) == true ) &&
332
+ 0 != $order->get_user_id() && ( wcs_order_contains_switch( $order ) )
333
+ ) {
334
+ try {
335
+ Mollie_WC_Plugin::debug( $this->id . ': Subscription switch, fetch mandate ' . $order_id );
336
+ $mandates = Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->customers_mandates->withParentId( $customer_id )->all();
337
+ $validMandate = false;
338
+ foreach ( $mandates as $mandate ) {
339
+ if ( $mandate->status == 'valid' ) {
340
+ $validMandate = true;
341
+ $data['method'] = $mandate->method;
342
+ break;
343
+ }
344
+ }
345
+ if ( $validMandate ) {
346
+
347
+ $order->payment_complete();
348
+
349
+ $order->add_order_note( sprintf(
350
+ __( 'Order completed internally because of an existing valid mandate at Mollie.', 'mollie-payments-for-woocommerce' ) ) );
351
+
352
+ Mollie_WC_Plugin::debug( $this->id . ': Subscription switch, valid mandate ' . $order_id );
353
+
354
+ return array (
355
+ 'result' => 'success',
356
+ 'redirect' => $this->get_return_url( $order ),
357
+ );
358
+
359
+ } else {
360
+ Mollie_WC_Plugin::debug( $this->id . ': Subscription switch, payment problem ' . $order_id );
361
+ throw new Mollie_API_Exception( __( 'Subscription switch cannot be processed, no valid mandate.', 'mollie-payments-for-woocommerce-mandate-problem' ) );
362
+ }
363
+ }
364
+ catch ( Mollie_API_Exception $e ) {
365
+ if ( $e->getField() ) {
366
+ throw $e;
367
+ }
368
+ }
369
+
370
+ }
371
+
372
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
373
  Mollie_WC_Plugin::debug( $this->id . ': Create payment for order ' . $order->id, true );
374
  } else {
958
 
959
  }
960
 
961
+ /**
962
+ * @param WC_Order $order
963
+ *
964
+ * @return string
965
+ */
966
  public function getReturnRedirectUrlForOrder( WC_Order $order ) {
967
  $data_helper = Mollie_WC_Plugin::getDataHelper();
968
 
 
969
  if ( $this->orderNeedsPayment( $order ) ) {
970
 
971
  $hasCancelledMolliePayment = ( version_compare( WC_VERSION, '3.0', '<' ) ) ? $data_helper->hasCancelledMolliePayment( $order->id ) : $data_helper->hasCancelledMolliePayment( $order->get_id() );;
972
 
973
  if ( $hasCancelledMolliePayment ) {
974
 
975
+ $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
976
+ $order_status_cancelled_payments = $settings_helper->getOrderStatusCancelledPayments();
977
 
978
+ // If user set all cancelled payments to also cancel the order,
979
+ // redirect to /checkout/order-received/ with a message about the
980
+ // order being cancelled. Otherwise redirect to /checkout/order-pay/ so
981
+ // customers can try to pay with another payment method.
982
+ if ( $order_status_cancelled_payments == 'cancelled' ) {
983
+
984
+ return $this->get_return_url( $order );
985
+
986
+ } else {
987
+ Mollie_WC_Plugin::addNotice( __( 'You have cancelled your payment. Please complete your order with a different payment method.', 'mollie-payments-for-woocommerce' ) );
988
+
989
+ if ( method_exists( $order, 'get_checkout_payment_url' ) ) {
990
+ /*
991
+ * Return to order payment page
992
+ */
993
+ return $order->get_checkout_payment_url( false );
994
+ }
995
  }
996
 
997
  /*
1202
  $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
1203
  if ( $order_id > 0 ) {
1204
  $order = wc_get_order( $order_id );
1205
+
1206
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
1207
+ $order_key_db = $order->order_key;
1208
+ } else {
1209
+ $order_key_db = $order->get_order_key();
1210
+ }
1211
+
1212
+ if ( $order_key_db != $order_key ) {
1213
  $order = false;
1214
  }
1215
  }
1525
  * @return string
1526
  */
1527
  abstract protected function getDefaultDescription ();
1528
+
1529
+ /**
1530
+ * @param $order_id
1531
+ * @return bool
1532
+ */
1533
+ protected function is_subscription( $order_id )
1534
+ {
1535
+ return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
1536
+ }
1537
+
1538
+
1539
  }
includes/mollie/wc/gateway/abstractsubscription.php CHANGED
@@ -520,55 +520,6 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
520
  return $this;
521
  }
522
 
523
- /**
524
- * @param $order
525
- * @param bool|false $test_mode
526
- * @return null|string
527
- */
528
- protected function getUserMollieCustomerId($order, $test_mode = false)
529
- {
530
- if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
531
- $user_id = $order->customer_user;
532
- } else {
533
- $user_id = $order->get_customer_id();
534
- }
535
-
536
- if (empty($user_id)){
537
- return null;
538
- }
539
-
540
- $customer_id = null;
541
- try
542
- {
543
- $userdata = get_userdata($user_id);
544
-
545
- // Get the best name for use as Mollie Customer name
546
- $user_full_name = $userdata->first_name . ' ' . $userdata->last_name;
547
-
548
- if ( strlen( trim( $user_full_name ) ) == null ) {
549
- $user_full_name = $userdata->display_name;
550
- }
551
-
552
- $customer = Mollie_WC_Plugin::getApiHelper()->getApiClient( $test_mode )->customers->create( array (
553
- 'name' => trim( $user_full_name ),
554
- 'email' => trim( $userdata->user_email ),
555
- 'locale' => trim( $this->getCurrentLocale() ),
556
- 'metadata' => array ( 'user_id' => $user_id ),
557
- ) );
558
-
559
-
560
- $customer_id = $customer->id;
561
- }
562
- catch (Exception $e)
563
- {
564
- Mollie_WC_Plugin::debug(
565
- __FUNCTION__ . ": Could not create customer $user_id (" . ($test_mode ? 'test' : 'live') . "): " . $e->getMessage() . ' (' . get_class($e) . ')'
566
- );
567
- }
568
-
569
- return $customer_id;
570
- }
571
-
572
  /**
573
  * @return mixed
574
  */
520
  return $this;
521
  }
522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  /**
524
  * @return mixed
525
  */
includes/mollie/wc/gateway/giftcard.php CHANGED
@@ -25,10 +25,17 @@ class Mollie_WC_Gateway_Giftcard extends Mollie_WC_Gateway_Abstract
25
  parent::init_form_fields();
26
 
27
  $this->form_fields = array_merge($this->form_fields, array(
 
 
 
 
 
 
 
28
  'issuers_empty_option' => array(
29
  'title' => __('Issuers empty option', 'mollie-payments-for-woocommerce'),
30
  'type' => 'text',
31
- 'description' => sprintf(__('This text will be displayed as the first option in the Giftcard issuers drop down', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
32
  'default' => '',
33
  'desc_tip' => true,
34
  ),
25
  parent::init_form_fields();
26
 
27
  $this->form_fields = array_merge($this->form_fields, array(
28
+ 'issuers_dropdown_shown' => array(
29
+ 'title' => __('Show gift cards dropdown', 'mollie-payments-for-woocommerce'),
30
+ 'type' => 'checkbox',
31
+ 'description' => sprintf(__('If you disable this, a dropdown with various gift cards will not be shown in the WooCommerce checkout, so users will select a gift card on the Mollie payment page after checkout.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
32
+ 'default' => 'yes',
33
+ 'desc_tip' => true,
34
+ ),
35
  'issuers_empty_option' => array(
36
  'title' => __('Issuers empty option', 'mollie-payments-for-woocommerce'),
37
  'type' => 'text',
38
+ 'description' => sprintf(__('This text will be displayed as the first option in the gift card dropdown, but only if the above \'Show gift cards dropdown\' is enabled.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
39
  'default' => '',
40
  'desc_tip' => true,
41
  ),
includes/mollie/wc/gateway/ideal.php CHANGED
@@ -25,10 +25,17 @@ class Mollie_WC_Gateway_Ideal extends Mollie_WC_Gateway_AbstractSepaRecurring
25
  parent::init_form_fields();
26
 
27
  $this->form_fields = array_merge($this->form_fields, array(
 
 
 
 
 
 
 
28
  'issuers_empty_option' => array(
29
  'title' => __('Issuers empty option', 'mollie-payments-for-woocommerce'),
30
  'type' => 'text',
31
- 'description' => sprintf(__('This text will be displayed as the first option in the iDEAL issuers drop down, if nothing is entered, "Select your bank" will be shown.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
32
  'default' => 'Select your bank',
33
  'desc_tip' => true,
34
  ),
25
  parent::init_form_fields();
26
 
27
  $this->form_fields = array_merge($this->form_fields, array(
28
+ 'issuers_dropdown_shown' => array(
29
+ 'title' => __('Show iDEAL banks dropdown', 'mollie-payments-for-woocommerce'),
30
+ 'type' => 'checkbox',
31
+ 'description' => sprintf(__('If you disable this, a dropdown with various iDEAL banks will not be shown in the WooCommerce checkout, so users will select a iDEAL bank on the Mollie payment page after checkout.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
32
+ 'default' => 'yes',
33
+ 'desc_tip' => true,
34
+ ),
35
  'issuers_empty_option' => array(
36
  'title' => __('Issuers empty option', 'mollie-payments-for-woocommerce'),
37
  'type' => 'text',
38
+ 'description' => sprintf(__('This text will be displayed as the first option in the iDEAL issuers drop down, if nothing is entered, "Select your bank" will be shown. Only if the above \'Show iDEAL banks dropdown\' is enabled.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
39
  'default' => 'Select your bank',
40
  'desc_tip' => true,
41
  ),
includes/mollie/wc/gateway/kbc.php CHANGED
@@ -25,10 +25,17 @@ class Mollie_WC_Gateway_Kbc extends Mollie_WC_Gateway_AbstractSepaRecurring
25
  parent::init_form_fields();
26
 
27
  $this->form_fields = array_merge($this->form_fields, array(
 
 
 
 
 
 
 
28
  'issuers_empty_option' => array(
29
  'title' => __('Issuers empty option', 'mollie-payments-for-woocommerce'),
30
  'type' => 'text',
31
- 'description' => sprintf(__('This text will be displayed as the first option in the KBC/CBC issuers drop down, if nothing is entered, "Select your bank" will be shown.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
32
  'default' => 'Select your bank',
33
  'desc_tip' => true,
34
  ),
25
  parent::init_form_fields();
26
 
27
  $this->form_fields = array_merge($this->form_fields, array(
28
+ 'issuers_dropdown_shown' => array(
29
+ 'title' => __('Show KBC/CBC banks dropdown', 'mollie-payments-for-woocommerce'),
30
+ 'type' => 'checkbox',
31
+ 'description' => sprintf(__('If you disable this, a dropdown with various KBC/CBC banks will not be shown in the WooCommerce checkout, so users will select a KBC/CBC bank on the Mollie payment page after checkout.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
32
+ 'default' => 'yes',
33
+ 'desc_tip' => true,
34
+ ),
35
  'issuers_empty_option' => array(
36
  'title' => __('Issuers empty option', 'mollie-payments-for-woocommerce'),
37
  'type' => 'text',
38
+ 'description' => sprintf(__('This text will be displayed as the first option in the KBC/CBC issuers drop down, if nothing is entered, "Select your bank" will be shown. Only if the above \'\'Show KBC/CBC banks dropdown\' is enabled.', 'mollie-payments-for-woocommerce'), $this->getDefaultTitle()),
39
  'default' => 'Select your bank',
40
  'desc_tip' => true,
41
  ),
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 = '2.8.0';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
7
  {
8
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
9
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
10
+ const PLUGIN_VERSION = '2.8.1';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
mollie-payments-for-woocommerce.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Mollie Payments for WooCommerce
4
  * Plugin URI: https://github.com/mollie/WooCommerce
5
  * Description: Accept payments in WooCommerce with the official Mollie plugin
6
- * Version: 2.8.0
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://github.com/mollie/WooCommerce
5
  * Description: Accept payments in WooCommerce with the official Mollie plugin
6
+ * Version: 2.8.1
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: mollie, payments, woocommerce, payment gateway, e-commerce, credit card, i
4
  Requires at least: 3.8
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
- Stable tag: 2.8.0
8
  Requires PHP: 5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -159,6 +159,15 @@ Automatic updates should work like a charm; as always though, ensure you backup
159
 
160
  == Changelog ==
161
 
 
 
 
 
 
 
 
 
 
162
  = 2.8.0 - 09/01/2018 =
163
 
164
  * New - Updated required WooCommerce version to 2.2.0
4
  Requires at least: 3.8
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
+ Stable tag: 2.8.1
8
  Requires PHP: 5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
159
 
160
  == Changelog ==
161
 
162
+ = 2.8.1 - 15/01/2018 =
163
+
164
+ * New - iDEAL, KBC, Gift cards: Option to hide issuers/bank list in WooCommerce
165
+ * New - Allow subscription switching (downgrade) when amount to pay is €0 and there is a valid mandate for the user
166
+
167
+ * Fix - A new customerID was created for every new order where a payment method that supported recurring payments was selected
168
+ * Fix - When plugin 2.8.0 was used with WooCommerce 2.6 or older, a fatal error would be shown on the return page (because of use of new WooCommerce 3.0 method)
169
+ * Fix - Some cancelled payments for cancelled orders where redirected to "Retry payment" instead of "Order received" page, see Github issue #166
170
+
171
  = 2.8.0 - 09/01/2018 =
172
 
173
  * New - Updated required WooCommerce version to 2.2.0