Mollie Payments for WooCommerce - Version 6.5.1

Version Description

  • 12-07-2021 =

  • Fix - Subscription renewal failing

  • Fix - Action scheduler amount of entries

Download this release

Release Info

Developer carmen222
Plugin Icon wp plugin Mollie Payments for WooCommerce
Version 6.5.1
Comparing to
See all releases

Code changes from version 6.5.0 to 6.5.1

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: 6.5.0
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 5.0
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: 6.5.1
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 5.0
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: daanvm, danielhuesken, davdebcom, dinamiko, inpsyde, l.vangunst, n
3
  Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
4
  Requires at least: 3.8
5
  Tested up to: 5.7
6
- Stable tag: 6.5.0
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -181,6 +181,11 @@ Automatic updates should work like a charm; as always though, ensure you backup
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
184
  = 6.5.0 - 05-07-2021 =
185
 
186
  * Feature - Add expiry date for orders
3
  Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
4
  Requires at least: 3.8
5
  Tested up to: 5.7
6
+ Stable tag: 6.5.1
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
181
 
182
  == Changelog ==
183
 
184
+ = 6.5.1 - 12-07-2021 =
185
+
186
+ * Fix - Subscription renewal failing
187
+ * Fix - Action scheduler amount of entries
188
+
189
  = 6.5.0 - 05-07-2021 =
190
 
191
  * Feature - Add expiry date for orders
src/Mollie/WC/Gateway/Abstract.php CHANGED
@@ -1952,7 +1952,8 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1952
  */
1953
  public function get_transaction_url( $order ) {
1954
 
1955
- $resource = ($order->get_meta( '_mollie_order_id', true )) ? 'orders' : 'payments';
 
1956
 
1957
  $this->view_transaction_url = 'https://www.mollie.com/dashboard/' . $resource . '/%s';
1958
 
1952
  */
1953
  public function get_transaction_url( $order ) {
1954
 
1955
+ $isPaymentApi = substr($order->get_meta( '_mollie_order_id', true ), 0, 3) === 'tr_' ;
1956
+ $resource = ($order->get_meta( '_mollie_order_id', true ) && !$isPaymentApi) ? 'orders' : 'payments';
1957
 
1958
  $this->view_transaction_url = 'https://www.mollie.com/dashboard/' . $resource . '/%s';
1959
 
src/Mollie/WC/Gateway/AbstractSubscription.php CHANGED
@@ -232,28 +232,20 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
232
  $validMandate = false;
233
  try
234
  {
235
- if (isset($mandateId)) {
236
- Mollie_WC_Plugin::debug($this->id . ': Found mandate ID for renewal order ' . $renewal_order_id . ' with customer ID ' . $customer_id );
237
- $mandate = $mollieApiClient->customers->get($customer_id)->getMandate($mandateId);
 
 
 
 
 
238
  if ($mandate->status === 'valid') {
239
- $data['method'] = $mandate->method;
240
- $data['mandateId'] = $mandateId;
241
  $validMandate = true;
242
- }
243
- } else {
244
- // Get all mandates for the customer ID
245
- Mollie_WC_Plugin::debug($this->id . ': Try to get all mandates for renewal order ' . $renewal_order_id . ' with customer ID ' . $customer_id );
246
- $mandates = $mollieApiClient->customers->get($customer_id)->mandates();
247
- $renewalOrderMethod = $renewal_order->get_payment_method();
248
- $renewalOrderMethod = str_replace("mollie_wc_gateway_", "", $renewalOrderMethod);
249
- foreach ($mandates as $mandate) {
250
- if ($mandate->status === 'valid') {
251
- $validMandate = true;
252
  $data['method'] = $mandate->method;
253
- if($mandate->method === $renewalOrderMethod){
254
- $data['method'] = $mandate->method;
255
- break;
256
- }
257
  }
258
  }
259
  }
232
  $validMandate = false;
233
  try
234
  {
235
+ // Get all mandates for the customer ID
236
+ Mollie_WC_Plugin::debug(
237
+ $this->id . ': Try to get all mandates for renewal order ' . $renewal_order_id . ' with customer ID ' . $customer_id
238
+ );
239
+ $mandates = $mollieApiClient->customers->get($customer_id)->mandates();
240
+ $renewalOrderMethod = $renewal_order->get_payment_method();
241
+ $renewalOrderMethod = str_replace("mollie_wc_gateway_", "", $renewalOrderMethod);
242
+ foreach ($mandates as $mandate) {
243
  if ($mandate->status === 'valid') {
 
 
244
  $validMandate = true;
245
+ $data['method'] = $mandate->method;
246
+ if ($mandate->method === $renewalOrderMethod) {
 
 
 
 
 
 
 
 
247
  $data['method'] = $mandate->method;
248
+ break;
 
 
 
249
  }
250
  }
251
  }
src/Mollie/WC/Helper/MaybeFixSubscription.php CHANGED
@@ -6,7 +6,7 @@ class Mollie_WC_Helper_MaybeFixSubscription
6
 
7
  public function maybeFix()
8
  {
9
- $fixSubscriptionsProcess = get_option('mollie_wc_fix_subscriptions', false);
10
 
11
  $hasSubscriptionPlugin = function_exists('wcs_get_subscriptions');
12
  $canSchedule = function_exists('as_schedule_single_action');
@@ -44,7 +44,7 @@ class Mollie_WC_Helper_MaybeFixSubscription
44
  }
45
  }
46
  }
47
- update_option('mollie_wc_fix_subscriptions', true);
48
  }
49
  }
50
 
6
 
7
  public function maybeFix()
8
  {
9
+ $fixSubscriptionsProcess = get_option('mollie_wc_fix_subscriptions2', false);
10
 
11
  $hasSubscriptionPlugin = function_exists('wcs_get_subscriptions');
12
  $canSchedule = function_exists('as_schedule_single_action');
44
  }
45
  }
46
  }
47
+ update_option('mollie_wc_fix_subscriptions2', true);
48
  }
49
  }
50
 
src/Mollie/WC/Payment/Payment.php CHANGED
@@ -149,16 +149,14 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
149
 
150
  public function setActiveMolliePayment($orderId)
151
  {
152
- parent::setActiveMolliePayment($orderId);
153
  self::$paymentId = $this->getMolliePaymentIdFromPaymentObject();
154
  self::$customerId = $this->getMollieCustomerIdFromPaymentObject();
155
  self::$order = wc_get_order($orderId);
156
 
157
  self::$order->update_meta_data('_mollie_payment_id', $this->data->id);
158
- self::$order->update_meta_data( '_mollie_order_id', false );
159
  self::$order->save();
160
 
161
- return $this;
162
  }
163
 
164
  public function getMolliePaymentIdFromPaymentObject() {
149
 
150
  public function setActiveMolliePayment($orderId)
151
  {
 
152
  self::$paymentId = $this->getMolliePaymentIdFromPaymentObject();
153
  self::$customerId = $this->getMollieCustomerIdFromPaymentObject();
154
  self::$order = wc_get_order($orderId);
155
 
156
  self::$order->update_meta_data('_mollie_payment_id', $this->data->id);
 
157
  self::$order->save();
158
 
159
+ return parent::setActiveMolliePayment($orderId);
160
  }
161
 
162
  public function getMolliePaymentIdFromPaymentObject() {
src/Mollie/WC/Plugin.php CHANGED
@@ -8,7 +8,7 @@ class Mollie_WC_Plugin
8
  {
9
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
10
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
11
- const PLUGIN_VERSION = '6.5.0';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -292,7 +292,7 @@ class Mollie_WC_Plugin
292
  $gatewaSurchargeHandler = new Mollie_WC_Helper_GatewaySurchargeHandler();
293
  }
294
  /**
295
- * See MOL-322
296
  */
297
  public static function maybeFixSubscriptions(){
298
  $fixer = new Mollie_WC_Helper_MaybeFixSubscription();
@@ -339,7 +339,6 @@ class Mollie_WC_Plugin
339
 
340
  public static function cancelOrderOnExpiryDate ()
341
  {
342
- $minHeldDuration = 526000;
343
  foreach (self::$GATEWAYS as $gateway){
344
  $gatewayName = strtolower($gateway).'_settings';
345
  $gatewaySettings = get_option( $gatewayName );
@@ -348,9 +347,6 @@ class Mollie_WC_Plugin
348
  if ( $heldDuration < 1 ) {
349
  continue;
350
  }
351
- if($heldDuration < $minHeldDuration){
352
- $minHeldDuration = $heldDuration;
353
- }
354
  $heldDurationInSeconds = $heldDuration*60;
355
  if($gateway == 'Mollie_WC_Gateway_BankTransfer'){
356
  $durationInHours = absint( $heldDuration )*24;
@@ -377,9 +373,6 @@ class Mollie_WC_Plugin
377
  }
378
  }
379
  }
380
-
381
- wp_clear_scheduled_hook( 'mollie_woocommerce_cancel_unpaid_orders' );
382
- wp_schedule_single_event( time() + ( absint( $minHeldDuration ) * 60 ), 'mollie_woocommerce_cancel_unpaid_orders' );
383
  }
384
 
385
  public static function voucherEnabledHooks(){
@@ -1653,7 +1646,10 @@ class Mollie_WC_Plugin
1653
  {
1654
  $canSchedule = function_exists('as_schedule_single_action');
1655
  if ($canSchedule) {
1656
- as_schedule_single_action(time(), 'mollie_woocommerce_cancel_unpaid_orders');
 
 
 
1657
  add_action(
1658
  'mollie_woocommerce_cancel_unpaid_orders',
1659
  array(__CLASS__, 'cancelOrderOnExpiryDate'),
@@ -1661,7 +1657,6 @@ class Mollie_WC_Plugin
1661
  2
1662
  );
1663
  }
1664
-
1665
  }
1666
  }
1667
 
8
  {
9
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
10
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
11
+ const PLUGIN_VERSION = '6.5.1';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
292
  $gatewaSurchargeHandler = new Mollie_WC_Helper_GatewaySurchargeHandler();
293
  }
294
  /**
295
+ * See MOL-322, 405
296
  */
297
  public static function maybeFixSubscriptions(){
298
  $fixer = new Mollie_WC_Helper_MaybeFixSubscription();
339
 
340
  public static function cancelOrderOnExpiryDate ()
341
  {
 
342
  foreach (self::$GATEWAYS as $gateway){
343
  $gatewayName = strtolower($gateway).'_settings';
344
  $gatewaySettings = get_option( $gatewayName );
347
  if ( $heldDuration < 1 ) {
348
  continue;
349
  }
 
 
 
350
  $heldDurationInSeconds = $heldDuration*60;
351
  if($gateway == 'Mollie_WC_Gateway_BankTransfer'){
352
  $durationInHours = absint( $heldDuration )*24;
373
  }
374
  }
375
  }
 
 
 
376
  }
377
 
378
  public static function voucherEnabledHooks(){
1646
  {
1647
  $canSchedule = function_exists('as_schedule_single_action');
1648
  if ($canSchedule) {
1649
+ if ( false === as_next_scheduled_action( 'mollie_woocommerce_cancel_unpaid_orders' ) ) {
1650
+ as_schedule_recurring_action( time(), 600, 'mollie_woocommerce_cancel_unpaid_orders');
1651
+ }
1652
+
1653
  add_action(
1654
  'mollie_woocommerce_cancel_unpaid_orders',
1655
  array(__CLASS__, 'cancelOrderOnExpiryDate'),
1657
  2
1658
  );
1659
  }
 
1660
  }
1661
  }
1662