Mollie Payments for WooCommerce - Version 6.5.0

Version Description

  • 05-07-2021 =

  • Feature - Add expiry date for orders

  • Feature - Hide API keys in settings

  • Feature - Improve Klarna notice about enabling default fields

  • Feature - New Wiki entry: Gateways hide when surcharge fee is applied

  • Feature - PayPal button improvements

  • Feature - Primary key on pending_payment table

  • Feature - PHP and WordPress upgrade

  • Feature - Default translations for Klarna payment methods. (by @Timollie)

  • Fix - Select the first payment when two subscriptions have the same payment method

  • Fix - Credit card icon missing mollie-gateway-icon class

  • Fix - Payments transaction ID link leads to orders dashboard in Mollie

  • Fix - Manual cancelation of order returns to pending payment

  • Fix - Broken compatibility with WooFunnels plugin

  • Fix - Enqueue of style script on non-checkout pages

  • Fix - IngHomePay class showing in the composer class-map

Download this release

Release Info

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

Code changes from version 6.4.0 to 6.5.0

inc/utils.php CHANGED
@@ -216,6 +216,9 @@ function mollieWooCommerceCheckIfNeedShipping($product)
216
  return false;
217
  }
218
  $needs_shipping = false;
 
 
 
219
 
220
  if ($product->needs_shipping()) {
221
  $needs_shipping = true;
@@ -251,4 +254,18 @@ function mollieWooCommerceIsVoucherEnabled(){
251
  return $voucherSettings? ($voucherSettings['enabled'] == 'yes'): false;
252
  }
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
216
  return false;
217
  }
218
  $needs_shipping = false;
219
+ if ($product->is_type('variable')){
220
+ return false;
221
+ }
222
 
223
  if ($product->needs_shipping()) {
224
  $needs_shipping = true;
254
  return $voucherSettings? ($voucherSettings['enabled'] == 'yes'): false;
255
  }
256
 
257
+ /**
258
+ * Check if is a Mollie gateway
259
+ * @param $gateway string
260
+ *
261
+ * @return bool
262
+ */
263
+ function mollieWooCommerceIsMollieGateway($gateway)
264
+ {
265
+ if (strpos($gateway, 'mollie_wc_gateway_') !== false) {
266
+ return true;
267
+ }
268
+ return false;
269
+ }
270
+
271
 
languages/mollie-payments-for-woocommerce-fr_FR.po CHANGED
@@ -468,7 +468,7 @@ msgstr "Pour accepter les paiements via Klarna, tous les champs de paiement par
468
 
469
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:33
470
  msgid "Klarna Pay later"
471
- msgstr "Klarna Pay Later"
472
 
473
  #: src/Mollie/WC/Helper/Status.php:131
474
  msgid "Mollie Payments for WooCommerce require PHP cURL functions to be available. Please make sure all of these functions are available."
468
 
469
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:33
470
  msgid "Klarna Pay later"
471
+ msgstr "Paiement en 3 fois sans frais"
472
 
473
  #: src/Mollie/WC/Helper/Status.php:131
474
  msgid "Mollie Payments for WooCommerce require PHP cURL functions to be available. Please make sure all of these functions are available."
languages/mollie-payments-for-woocommerce-nl_BE.po CHANGED
@@ -459,7 +459,7 @@ msgstr "Verzending"
459
 
460
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:33
461
  msgid "Klarna Slice it"
462
- msgstr "Klarna Slice it"
463
 
464
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:40
465
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:40
459
 
460
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:33
461
  msgid "Klarna Slice it"
462
+ msgstr "Betaal in 3 termijnen met creditcard"
463
 
464
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:40
465
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:40
languages/mollie-payments-for-woocommerce-nl_NL.po CHANGED
@@ -462,7 +462,7 @@ msgstr "Verzending"
462
 
463
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:33
464
  msgid "Klarna Slice it"
465
- msgstr "Klarna Slice it"
466
 
467
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:40
468
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:40
462
 
463
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:33
464
  msgid "Klarna Slice it"
465
+ msgstr "Betaal in 3 termijnen met creditcard"
466
 
467
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:40
468
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:40
languages/mollie-payments-for-woocommerce-nl_NL_formal.po CHANGED
@@ -462,7 +462,7 @@ msgstr "Verzending"
462
 
463
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:33
464
  msgid "Klarna Slice it"
465
- msgstr "Klarna Slice it"
466
 
467
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:40
468
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:40
462
 
463
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:33
464
  msgid "Klarna Slice it"
465
+ msgstr "Betaal in 3 termijnen met creditcard"
466
 
467
  #: src/Mollie/WC/Gateway/KlarnaPayLater.php:40
468
  #: src/Mollie/WC/Gateway/KlarnaSliceIt.php:40
mollie-payments-for-woocommerce.php CHANGED
@@ -3,16 +3,17 @@
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.4.0
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
- * Requires at least: 3.8
10
  * Tested up to: 5.7
11
  * Text Domain: mollie-payments-for-woocommerce
12
  * Domain Path: /languages
13
  * License: GPLv2 or later
14
  * WC requires at least: 3.0
15
- * WC tested up to: 5.3
 
16
  */
17
 
18
 
@@ -141,30 +142,6 @@ $bootstrap = Closure::bind(
141
  }
142
  return;
143
  }
144
- $checker->maybeShowWarning(
145
- new WordPressConstraint('5.0'),
146
- sprintf(
147
- __(
148
- 'Mollie Payments for WooCommerce is dropping support for WordPress versions less than 5.0. Please update WordPress to the latest version.</br> Without an update, you will not receive any new features.
149
- Contact our support team %1$shere%2$s if any questions remain.',
150
- 'mollie-payments-for-woocommerce'
151
- ),
152
- '<a href="https://mollie.inpsyde.com/" target="_blank">',
153
- '</a>'
154
- )
155
- );
156
- $checker->maybeShowWarning(
157
- new PhpConstraint('7.2'),
158
- sprintf(
159
- __(
160
- 'Mollie Payments for WooCommerce is dropping support for PHP versions less than 7.2. As such, using outdated and unsupported versions of PHP may expose your site to security vulnerabilities. Please update PHP to the latest version.
161
- For further informations see %1$shere%2$s and if any questions remain contact our support team.',
162
- 'mollie-payments-for-woocommerce'
163
- ),
164
- '<a href="https://mollie.inpsyde.com/docs/php-7-2-update/" target="_blank">',
165
- '</a>'
166
- )
167
- );
168
 
169
  add_action(
170
  'init',
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
10
  * Tested up to: 5.7
11
  * Text Domain: mollie-payments-for-woocommerce
12
  * Domain Path: /languages
13
  * License: GPLv2 or later
14
  * WC requires at least: 3.0
15
+ * WC tested up to: 5.4
16
+ * Requires PHP: 7.2
17
  */
18
 
19
 
142
  }
143
  return;
144
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  add_action(
147
  'init',
public/css/mollie-gateway-icons.min.css CHANGED
@@ -1 +1 @@
1
- .mollie-gateway-icon{width:32px;vertical-align:bottom}label .mollie-gateway-icon{float:right}.mollie_custom_icon{padding:1em}#mol-paypal-settings-icon{margin-left:1em}
1
+ .mollie-gateway-icon{vertical-align:bottom;height:24px}.mollie-gateway-icon svg,label .mollie-gateway-icon{float:right}.mollie_custom_icon{padding:1em}#mol-paypal-settings-icon{margin-left:1em}
public/js/paypalButton.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/public/js/",n(n.s="GBNm")}({GBNm:function(e,t){!function(e){var t=e._,n=e.molliepaypalbutton,o=e.jQuery;if(!t.isEmpty(n)){var r=n.product,a=r.id,i=r.needShipping,u=void 0===i||i,l=r.isVariation,c=void 0!==l&&l,d=r.price,s=r.minFee,p=n.ajaxUrl;if(a&&d&&p){var f=document.querySelector("#mollie-PayPal-button"),m=function(e){var t=e*d;o.ajax({url:p,method:"POST",data:{action:"mollie_paypal_update_amount",productId:_,productQuantity:e,nonce:v},success:function(e){t=parseFloat(e.data),function(e){e?y():b()}(parseFloat(s)>t)},error:function(e){console.warn(e)}})},y=function(){null!==f.parentNode&&f.parentNode.removeChild(f)},b=function(){document.getElementsByClassName("entry-summary")[0].appendChild(f)},v=f.children[0].value,_=a,g=1,j="";if(document.querySelector("input.qty").addEventListener("change",(function(e){g=e.currentTarget.value,m(g)})),m(g),c&&(o(".single_variation_wrap").on("show_variation",(function(e,t){t.variation_id&&(_=t.variation_id),f.disabled=!1,f.classList.remove("buttonDisabled")})),f.disabled=!0,f.classList.add("buttonDisabled")),null!=f.parentNode){var S=!1;document.querySelector("#mollie-PayPal-button").addEventListener("click",(function(e){null!==f.parentNode&&(f.disabled=!0,f.classList.add("buttonDisabled"),S||(S=!0,o.ajax({url:p,method:"POST",data:{action:"mollie_paypal_create_order",productId:_,productQuantity:g,needShipping:u,"mollie-payments-for-woocommerce_issuer_paypal_button":"paypal",nonce:v},success:function(e){var t=e.data;!0===e.success?(j=t.redirect,window.location.href=j):console.log(e.data)},error:function(e,t,n){f.disabled=!1,f.classList.remove("buttonDisabled"),console.warn(t,n)}})))}))}}}}(window)}});
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/public/js/",n(n.s="GBNm")}({GBNm:function(e,t){!function(e){var t=e._,n=e.molliepaypalbutton,o=e.jQuery;if(!t.isEmpty(n)){var r=n.product,a=r.id,i=r.needShipping,u=void 0===i||i,l=r.isVariation,c=void 0!==l&&l,d=r.price,s=r.minFee,p=n.ajaxUrl;if(a&&d&&p){var f=document.querySelector("#mollie-PayPal-button"),m=function(e){var t=e*d;o.ajax({url:p,method:"POST",data:{action:"mollie_paypal_update_amount",productId:_,productQuantity:e,nonce:y},success:function(e){t=parseFloat(e.data),function(e){e?b():v()}(parseFloat(s)>t)},error:function(e){console.warn(e)}})},b=function(){null!==f.parentNode&&f.parentNode.removeChild(f)},v=function(){document.getElementsByClassName("entry-summary")[0].appendChild(f)},y=f.children[0].value,_=a,g=1,j="";document.querySelector("input.qty").addEventListener("change",(function(e){g=e.currentTarget.value,m(g)})),m(g);var S=function(){f.disabled=!0,f.classList.add("buttonDisabled")};if(c&&(o(".single_variation_wrap").on("show_variation",(function(e,t){t.is_virtual&&t.variation_id&&(_=t.variation_id,f.disabled=!1,f.classList.remove("buttonDisabled"))})),o(".reset_variations").on("click.wc-variation-form",(function(e){_="",S()})),S()),null!=f.parentNode){var h=!1;document.querySelector("#mollie-PayPal-button").addEventListener("click",(function(e){null===f.parentNode||f.disabled||(f.disabled=!0,f.classList.add("buttonDisabled"),h||(h=!0,o.ajax({url:p,method:"POST",data:{action:"mollie_paypal_create_order",productId:_,productQuantity:g,needShipping:u,"mollie-payments-for-woocommerce_issuer_paypal_button":"paypal",nonce:y},success:function(e){var t=e.data;!0===e.success?(j=t.redirect,window.location.href=j):console.log(e.data)},error:function(e,t,n){f.disabled=!1,f.classList.remove("buttonDisabled"),console.warn(t,n)}})))}))}}}}(window)}});
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.4.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,24 @@ Automatic updates should work like a charm; as always though, ensure you backup
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  = 6.4.0 - 19-05-2021 =
185
 
186
  * Feature - PayPal Button for digital goods
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
 
182
  == Changelog ==
183
 
184
+ = 6.5.0 - 05-07-2021 =
185
+
186
+ * Feature - Add expiry date for orders
187
+ * Feature - Hide API keys in settings
188
+ * Feature - Improve Klarna notice about enabling default fields
189
+ * Feature - New Wiki entry: Gateways hide when surcharge fee is applied
190
+ * Feature - PayPal button improvements
191
+ * Feature - Primary key on pending_payment table
192
+ * Feature - PHP and WordPress upgrade
193
+ * Feature - Default translations for Klarna payment methods. (by @Timollie)
194
+ * Fix - Select the first payment when two subscriptions have the same payment method
195
+ * Fix - Credit card icon missing mollie-gateway-icon class
196
+ * Fix - Payments transaction ID link leads to orders dashboard in Mollie
197
+ * Fix - Manual cancelation of order returns to pending payment
198
+ * Fix - Broken compatibility with WooFunnels plugin
199
+ * Fix - Enqueue of style script on non-checkout pages
200
+ * Fix - IngHomePay class showing in the composer class-map
201
+
202
  = 6.4.0 - 19-05-2021 =
203
 
204
  * Feature - PayPal Button for digital goods
src/Mollie/WC/ActivationHandle/ConstraintsChecker.php CHANGED
@@ -30,9 +30,9 @@ class Mollie_WC_ActivationHandle_ConstraintsChecker
30
  */
31
  public function __construct()
32
  {
33
- $wpConstraint = new WordPressConstraint('3.8');
34
  $wcConstraint = new PluginConstraint('3.0', 'woocommerce', 'WooCommerce');
35
- $phpConstraint = new PhpConstraint('5.6');
36
  $jsonConstraint = new ExtensionConstraint('json');
37
  $collectionFactory = new ConstraintsCollectionFactory();
38
  $constraintsCollection = $collectionFactory->create(
30
  */
31
  public function __construct()
32
  {
33
+ $wpConstraint = new WordPressConstraint('5.0');
34
  $wcConstraint = new PluginConstraint('3.0', 'woocommerce', 'WooCommerce');
35
+ $phpConstraint = new PhpConstraint('7.2');
36
  $jsonConstraint = new ExtensionConstraint('json');
37
  $collectionFactory = new ConstraintsCollectionFactory();
38
  $constraintsCollection = $collectionFactory->create(
src/Mollie/WC/Gateway/Abstract.php CHANGED
@@ -176,6 +176,10 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
176
  if (isset($_POST['save']) ) {
177
  $this->processAdminOptionCustomLogo();
178
  $this->processAdminOptionSurcharge();
 
 
 
 
179
  }
180
  parent::process_admin_options();
181
  }
@@ -1304,7 +1308,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1304
  // order being cancelled. Otherwise redirect to /checkout/order-pay/ so
1305
  // customers can try to pay with another payment method.
1306
  if ( $order_status_cancelled_payments == 'cancelled' ) {
1307
- return $returnRedirect;
1308
 
1309
  } else {
1310
  Mollie_WC_Plugin::addNotice(
@@ -1317,9 +1321,6 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1317
  // Return to order payment page
1318
  return $failedRedirect;
1319
  }
1320
-
1321
- // Return to order payment page
1322
- return $failedRedirect;
1323
  }
1324
 
1325
  try {
@@ -1346,7 +1347,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
1346
  /*
1347
  * Return to order received page
1348
  */
1349
- return $returnRedirect;
1350
  }
1351
  /**
1352
  * Retrieve the payment object
176
  if (isset($_POST['save']) ) {
177
  $this->processAdminOptionCustomLogo();
178
  $this->processAdminOptionSurcharge();
179
+ //only credit cards have a selector
180
+ if ($this->id == 'mollie_wc_gateway_creditcard') {
181
+ $this->processAdminOptionCreditcardSelector();
182
+ }
183
  }
184
  parent::process_admin_options();
185
  }
1308
  // order being cancelled. Otherwise redirect to /checkout/order-pay/ so
1309
  // customers can try to pay with another payment method.
1310
  if ( $order_status_cancelled_payments == 'cancelled' ) {
1311
+ return $this->get_return_url( $order );
1312
 
1313
  } else {
1314
  Mollie_WC_Plugin::addNotice(
1321
  // Return to order payment page
1322
  return $failedRedirect;
1323
  }
 
 
 
1324
  }
1325
 
1326
  try {
1347
  /*
1348
  * Return to order received page
1349
  */
1350
+ return $this->get_return_url( $order );
1351
  }
1352
  /**
1353
  * Retrieve the payment object
src/Mollie/WC/Gateway/AbstractSubscription.php CHANGED
@@ -210,6 +210,8 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
210
  $subscriptions = wcs_get_subscriptions_for_renewal_order( $renewal_order->get_id() );
211
  $subscription = array_pop( $subscriptions ); // Just need one valid subscription
212
  $subscription_mollie_payment_id = $subscription->get_meta( '_mollie_payment_id' );
 
 
213
 
214
  if ( ! empty( $subscription_mollie_payment_id ) && ! empty( $subscription ) ) {
215
  $customer_id = $this->restore_mollie_customer_id_and_mandate( $customer_id, $subscription_mollie_payment_id, $subscription );
@@ -224,25 +226,34 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
224
  // Create a renewal payment
225
  try
226
  {
227
-
228
  do_action(Mollie_WC_Plugin::PLUGIN_ID . '_create_payment', $data, $renewal_order);
229
  $payment = null;
230
-
231
- // Get all mandates for the customer ID
232
  try
233
  {
234
- Mollie_WC_Plugin::debug($this->id . ': Try to get all mandates for renewal order ' . $renewal_order_id . ' with customer ID ' . $customer_id );
235
- $mandates = Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode)->customers->get($customer_id)->mandates();
236
- $validMandate = false;
237
- $renewalOrderMethod = $renewal_order->get_payment_method();
238
- $renewalOrderMethod = str_replace("mollie_wc_gateway_", "", $renewalOrderMethod);
239
- foreach ($mandates as $mandate) {
240
- if ($mandate->status == 'valid') {
241
- $validMandate = true;
242
  $data['method'] = $mandate->method;
243
- if($mandate->method == $renewalOrderMethod){
 
 
 
 
 
 
 
 
 
 
 
244
  $data['method'] = $mandate->method;
245
- break;
 
 
 
246
  }
247
  }
248
  }
210
  $subscriptions = wcs_get_subscriptions_for_renewal_order( $renewal_order->get_id() );
211
  $subscription = array_pop( $subscriptions ); // Just need one valid subscription
212
  $subscription_mollie_payment_id = $subscription->get_meta( '_mollie_payment_id' );
213
+ $subcriptionParentOrder = $subscription->get_parent();
214
+ $mandateId = isset($subcriptionParentOrder)? $subcriptionParentOrder->get_meta('_mollie_mandate_id') : null;
215
 
216
  if ( ! empty( $subscription_mollie_payment_id ) && ! empty( $subscription ) ) {
217
  $customer_id = $this->restore_mollie_customer_id_and_mandate( $customer_id, $subscription_mollie_payment_id, $subscription );
226
  // Create a renewal payment
227
  try
228
  {
 
229
  do_action(Mollie_WC_Plugin::PLUGIN_ID . '_create_payment', $data, $renewal_order);
230
  $payment = null;
231
+ $mollieApiClient = Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode);
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
  }
src/Mollie/WC/Gateway/BankTransfer.php CHANGED
@@ -7,6 +7,7 @@ class Mollie_WC_Gateway_BankTransfer extends Mollie_WC_Gateway_Abstract
7
  const EXPIRY_DEFAULT_DAYS = 12;
8
  const EXPIRY_MIN_DAYS = 5;
9
  const EXPIRY_MAX_DAYS = 60;
 
10
 
11
  /**
12
  *
@@ -29,6 +30,8 @@ class Mollie_WC_Gateway_BankTransfer extends Mollie_WC_Gateway_Abstract
29
  public function init_form_fields()
30
  {
31
  parent::init_form_fields();
 
 
32
 
33
  $this->form_fields = array_merge($this->form_fields, array(
34
  'activate_expiry_days_setting' => array(
@@ -38,10 +41,10 @@ class Mollie_WC_Gateway_BankTransfer extends Mollie_WC_Gateway_Abstract
38
  'type' => 'checkbox',
39
  'default' => 'no',
40
  ),
41
- 'expiry_days' => array(
42
  'title' => __('Expiry date', 'mollie-payments-for-woocommerce'),
43
  'type' => 'number',
44
- 'description' => sprintf(__('Number of days after the payment will expire. Default <code>%d</code> days', 'mollie-payments-for-woocommerce'), self::EXPIRY_DEFAULT_DAYS),
45
  'default' => self::EXPIRY_DEFAULT_DAYS,
46
  'custom_attributes' => array(
47
  'min' => self::EXPIRY_MIN_DAYS,
@@ -68,7 +71,7 @@ class Mollie_WC_Gateway_BankTransfer extends Mollie_WC_Gateway_Abstract
68
  public function addPaymentArguments( array $args, WC_Order $order ) {
69
  // Expiry date
70
  $expiry_days = (int)$this->get_option(
71
- 'expiry_days',
72
  self::EXPIRY_DEFAULT_DAYS
73
  );
74
 
7
  const EXPIRY_DEFAULT_DAYS = 12;
8
  const EXPIRY_MIN_DAYS = 5;
9
  const EXPIRY_MAX_DAYS = 60;
10
+ const EXPIRY_DAYS_OPTION = 'order_dueDate';
11
 
12
  /**
13
  *
30
  public function init_form_fields()
31
  {
32
  parent::init_form_fields();
33
+ unset($this->form_fields['activate_expiry_days_setting']);
34
+ unset($this->form_fields['order_dueDate']);
35
 
36
  $this->form_fields = array_merge($this->form_fields, array(
37
  'activate_expiry_days_setting' => array(
41
  'type' => 'checkbox',
42
  'default' => 'no',
43
  ),
44
+ 'order_dueDate' => array(
45
  'title' => __('Expiry date', 'mollie-payments-for-woocommerce'),
46
  'type' => 'number',
47
+ 'description' => sprintf(__('Number of DAYS after the payment will expire. Default <code>%d</code> days', 'mollie-payments-for-woocommerce'), self::EXPIRY_DEFAULT_DAYS),
48
  'default' => self::EXPIRY_DEFAULT_DAYS,
49
  'custom_attributes' => array(
50
  'min' => self::EXPIRY_MIN_DAYS,
71
  public function addPaymentArguments( array $args, WC_Order $order ) {
72
  // Expiry date
73
  $expiry_days = (int)$this->get_option(
74
+ self::EXPIRY_DAYS_OPTION,
75
  self::EXPIRY_DEFAULT_DAYS
76
  );
77
 
src/Mollie/WC/Gateway/Creditcard.php CHANGED
@@ -202,7 +202,7 @@ class Mollie_WC_Gateway_Creditcard extends Mollie_WC_Gateway_AbstractSubscriptio
202
  $actual = get_transient('svg_creditcards_string');
203
  if(!$actual){
204
  $actual
205
- = "<svg width=\"{$cardsWidth}\" height=\"24\" style=\"float:right\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
206
  foreach ($enabledCreditCards as $creditCard) {
207
  $svgString = file_get_contents(
208
  $assetsImagesPath . $creditCard
@@ -239,4 +239,13 @@ class Mollie_WC_Gateway_Creditcard extends Mollie_WC_Gateway_AbstractSubscriptio
239
 
240
  return substr_replace($svgString, $positionString, $positionAfterSvgWord, 0);
241
  }
 
 
 
 
 
 
 
 
 
242
  }
202
  $actual = get_transient('svg_creditcards_string');
203
  if(!$actual){
204
  $actual
205
+ = "<svg width=\"{$cardsWidth}\" height=\"24\" class=\"mollie-gateway-icon\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
206
  foreach ($enabledCreditCards as $creditCard) {
207
  $svgString = file_get_contents(
208
  $assetsImagesPath . $creditCard
239
 
240
  return substr_replace($svgString, $positionString, $positionAfterSvgWord, 0);
241
  }
242
+
243
+ /**
244
+ * Deletes the selector transient when the Admin option changes
245
+ *
246
+ */
247
+ protected function processAdminOptionCreditcardSelector()
248
+ {
249
+ delete_transient('svg_creditcards_string');
250
+ }
251
  }
src/Mollie/WC/Helper/PaymentMethodsIconUrl.php CHANGED
@@ -44,6 +44,7 @@ class Mollie_WC_Helper_PaymentMethodsIconUrl
44
  }
45
 
46
  $svgPath = false;
 
47
  $gatewaySettings = get_option("mollie_wc_gateway_{$paymentMethodName}_settings", false);
48
 
49
  if($gatewaySettings){
44
  }
45
 
46
  $svgPath = false;
47
+ $svgUrl = false;
48
  $gatewaySettings = get_option("mollie_wc_gateway_{$paymentMethodName}_settings", false);
49
 
50
  if($gatewaySettings){
src/Mollie/WC/Helper/Settings.php CHANGED
@@ -231,7 +231,35 @@ class Mollie_WC_Helper_Settings
231
  'custom_attributes'=>['step'=>'0.01', 'min'=>'0.01', 'max'=>'999'],
232
  'default' => '0.01',
233
  'desc_tip' => true,
234
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  ];
236
 
237
  if ($paymentConfirmation) {
@@ -642,10 +670,6 @@ class Mollie_WC_Helper_Settings
642
  ),
643
  'css' => 'width: 350px',
644
  'placeholder' => $live_placeholder = __('Live API key should start with live_', 'mollie-payments-for-woocommerce'),
645
- 'custom_attributes' => array(
646
- 'placeholder' => $live_placeholder,
647
- 'pattern' => '^live_\w{30,}$',
648
- ),
649
  ),
650
  array(
651
  'id' => $this->getSettingId('test_mode_enabled'),
@@ -668,10 +692,6 @@ class Mollie_WC_Helper_Settings
668
  ),
669
  'css' => 'width: 350px',
670
  'placeholder' => $test_placeholder = __('Test API key should start with test_', 'mollie-payments-for-woocommerce'),
671
- 'custom_attributes' => array(
672
- 'placeholder' => $test_placeholder,
673
- 'pattern' => '^test_\w{30,}$',
674
- ),
675
  ),
676
  [
677
  'id' => $this->getSettingId('debug'),
@@ -822,9 +842,15 @@ class Mollie_WC_Helper_Settings
822
 
823
  if ($woocommerce_klarnapaylater_gateway->is_available() || $woocommerce_klarnasliceit_gateway->is_available()) {
824
  $content .= '<div class="notice notice-warning is-dismissible"><p>';
825
- $content .= __(
826
- 'To accept Klarna payments via Mollie, all default WooCommerce checkout fields should be enabled and required. Please ensure that is the case.',
827
- 'mollie-payments-for-woocommerce'
 
 
 
 
 
 
828
  );
829
  $content .= '</p></div> ';
830
 
231
  'custom_attributes'=>['step'=>'0.01', 'min'=>'0.01', 'max'=>'999'],
232
  'default' => '0.01',
233
  'desc_tip' => true,
234
+ ],
235
+ [
236
+ 'id' => $defaultTitle . '_' . 'advanced',
237
+ 'title' => sprintf(__(
238
+ '%s advanced',
239
+ 'mollie-payments-for-woocommerce'
240
+ ), $defaultTitle),
241
+ 'type' => 'title'
242
+ ],
243
+ 'activate_expiry_days_setting' => array(
244
+ 'title' => __('Activate expiry date setting', 'mollie-payments-for-woocommerce'),
245
+ 'label' => __('Enable expiry date for payments', 'mollie-payments-for-woocommerce'),
246
+ 'description' => __('Enable this option if you want to be able to set the number of days after the order will expire.', 'mollie-payments-for-woocommerce'),
247
+ 'type' => 'checkbox',
248
+ 'default' => 'no',
249
+ ),
250
+ 'order_dueDate' => [
251
+ 'title' => sprintf(__('Expiry date', 'mollie-payments-for-woocommerce')),
252
+ 'type' => 'number',
253
+ 'description' => sprintf(
254
+ __(
255
+ 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce. A value of 0 means no expiry date will be considered.',
256
+ 'mollie-payments-for-woocommerce'
257
+ )
258
+ ),
259
+ 'custom_attributes'=>['step'=>'1', 'min'=>'0', 'max'=>'526000'],
260
+ 'default' => '0',
261
+ 'desc_tip' => true,
262
+ ],
263
  ];
264
 
265
  if ($paymentConfirmation) {
670
  ),
671
  'css' => 'width: 350px',
672
  'placeholder' => $live_placeholder = __('Live API key should start with live_', 'mollie-payments-for-woocommerce'),
 
 
 
 
673
  ),
674
  array(
675
  'id' => $this->getSettingId('test_mode_enabled'),
692
  ),
693
  'css' => 'width: 350px',
694
  'placeholder' => $test_placeholder = __('Test API key should start with test_', 'mollie-payments-for-woocommerce'),
 
 
 
 
695
  ),
696
  [
697
  'id' => $this->getSettingId('debug'),
842
 
843
  if ($woocommerce_klarnapaylater_gateway->is_available() || $woocommerce_klarnasliceit_gateway->is_available()) {
844
  $content .= '<div class="notice notice-warning is-dismissible"><p>';
845
+ $content .= sprintf(
846
+ __(
847
+ 'You have activated Klarna. To accept payments, please make sure all default WooCommerce checkout fields are enabled and required. For more information, go to %1sKlarna Pay Later documentation%2s or %3sKlarna Slice it documentation%4s',
848
+ 'mollie-payments-for-woocommerce'
849
+ ),
850
+ '<a href="https://github.com/mollie/WooCommerce/wiki/Setting-up-Klarna-Pay-later-gateway">',
851
+ '</a>',
852
+ '<a href=" https://github.com/mollie/WooCommerce/wiki/Setting-up-Klarna-Slice-it-gateway">',
853
+ '</a>'
854
  );
855
  $content .= '</p></div> ';
856
 
src/Mollie/WC/Payment/Object.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
  use Mollie\Api\Exceptions\ApiException;
 
 
4
 
5
  class Mollie_WC_Payment_Object {
6
 
@@ -17,7 +19,6 @@ class Mollie_WC_Payment_Object {
17
 
18
  $base_location = wc_get_base_location();
19
  static::$shop_country = $base_location['country'];
20
-
21
  }
22
 
23
 
@@ -425,6 +426,7 @@ class Mollie_WC_Payment_Object {
425
 
426
  }
427
 
 
428
  /**
429
  * @param WC_Order $order
430
  * @param Mollie\Api\Resources\Payment $payment
@@ -522,6 +524,27 @@ class Mollie_WC_Payment_Object {
522
  }
523
  }
524
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  /**
526
  * @param $order
527
  */
@@ -558,7 +581,7 @@ class Mollie_WC_Payment_Object {
558
  * @param WC_Order $order
559
  * @param $newOrderStatus
560
  * @param $paymentMethodTitle
561
- * @param \Mollie\Api\Resources\Payment|Mollie\Api\Resources\Order $payment
562
  */
563
  protected function failedSubscriptionProcess(
564
  $orderId,
@@ -660,4 +683,20 @@ class Mollie_WC_Payment_Object {
660
  );
661
  }
662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  }
1
  <?php
2
 
3
  use Mollie\Api\Exceptions\ApiException;
4
+ use Mollie\Api\Resources\Order;
5
+ use Mollie\Api\Resources\Payment;
6
 
7
  class Mollie_WC_Payment_Object {
8
 
19
 
20
  $base_location = wc_get_base_location();
21
  static::$shop_country = $base_location['country'];
 
22
  }
23
 
24
 
426
 
427
  }
428
 
429
+
430
  /**
431
  * @param WC_Order $order
432
  * @param Mollie\Api\Resources\Payment $payment
524
  }
525
  }
526
 
527
+ /**
528
+ * @param WC_Order $order
529
+ * @param Order| Payment $payment
530
+ */
531
+ protected function addMandateIdMetaToFirstPaymentSubscriptionOrder(
532
+ WC_Order $order,
533
+ $payment
534
+ ) {
535
+ if (class_exists('WC_Subscriptions')) {
536
+ $payment = isset($payment->_embedded->payments[0])? $payment->_embedded->payments[0] : false;
537
+ if ($payment && $payment->sequenceType === 'first'
538
+ && isset($payment->mandateId)) {
539
+ $order->update_meta_data(
540
+ '_mollie_mandate_id',
541
+ $payment->mandateId
542
+ );
543
+ $order->save();
544
+ }
545
+ }
546
+ }
547
+
548
  /**
549
  * @param $order
550
  */
581
  * @param WC_Order $order
582
  * @param $newOrderStatus
583
  * @param $paymentMethodTitle
584
+ * @param Payment|Mollie\Api\Resources\Order $payment
585
  */
586
  protected function failedSubscriptionProcess(
587
  $orderId,
683
  );
684
  }
685
 
686
+ protected function addPaypalTransactionIdToOrder(
687
+ WC_Order $order
688
+ ) {
689
+ $payment = Mollie_WC_Plugin::getPaymentObject()->getActiveMolliePayment( $order->get_id() );
690
+
691
+ if($payment->isPaid() && $payment->details){
692
+ update_post_meta($order->get_id(), '_paypal_transaction_id', $payment->details->paypalReference);
693
+ $order->add_order_note(sprintf(
694
+ /* translators: Placeholder 1: PayPal consumer name, placeholder 2: PayPal email, placeholder 3: PayPal transaction ID */
695
+ __("Payment completed by <strong>%s</strong> - %s (PayPal transaction ID: %s)", 'mollie-payments-for-woocommerce'),
696
+ $payment->details->consumerName,
697
+ $payment->details->consumerAccount,
698
+ $payment->details->paypalReference
699
+ ));
700
+ }
701
+ }
702
  }
src/Mollie/WC/Payment/Order.php CHANGED
@@ -248,19 +248,8 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
248
  Mollie_WC_Plugin::debug( __METHOD__ . " called for order {$orderId}" );
249
 
250
  if($payment->method === 'paypal'){
251
- $address = $payment->shippingAddress;
252
- $filter = FILTER_SANITIZE_STRING;
253
- $shippingAddress = [
254
- 'first_name' => filter_var($address->givenName, $filter),
255
- 'last_name' => filter_var($address->familyName, $filter),
256
- 'email' => filter_var($address->email, $filter),
257
- 'postcode' => filter_var($address->postalCode, $filter),
258
- 'country' => strtoupper(filter_var($address->country, $filter)),
259
- 'city' => filter_var($address->city, $filter),
260
- 'address_1' => filter_var($address->streetAndNumber, $filter)
261
- ];
262
-
263
- $order->set_address($shippingAddress, 'shipping');
264
  }
265
 
266
  $order->payment_complete($payment->id);
@@ -291,6 +280,7 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
291
  );
292
 
293
  // Subscription processing
 
294
  $this->deleteSubscriptionFromPending($order);
295
  } else {
296
  // Add messages to log
@@ -359,19 +349,8 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
359
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $orderId );
360
 
361
  if($payment->method === 'paypal'){
362
- $address = $payment->shippingAddress;
363
- $filter = FILTER_SANITIZE_STRING;
364
- $shippingAddress = [
365
- 'first_name' => filter_var($address->givenName, $filter),
366
- 'last_name' => filter_var($address->familyName, $filter),
367
- 'email' => filter_var($address->email, $filter),
368
- 'postcode' => filter_var($address->postalCode, $filter),
369
- 'country' => strtoupper(filter_var($address->country, $filter)),
370
- 'city' => filter_var($address->city, $filter),
371
- 'address_1' => filter_var($address->streetAndNumber, $filter)
372
- ];
373
-
374
- $order->set_address($shippingAddress, 'shipping');
375
  }
376
  $order->payment_complete($payment->id);
377
  // Add messages to log
@@ -439,6 +418,10 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
439
  } elseif ( $orderStatusCancelledPayments == 'cancelled' ) {
440
  $newOrderStatus = Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
441
  }
 
 
 
 
442
 
443
  // Overwrite plugin-wide
444
  $newOrderStatus = apply_filters( Mollie_WC_Plugin::PLUGIN_ID . '_order_status_cancelled', $newOrderStatus );
@@ -1088,4 +1071,27 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
1088
  );
1089
  return $shippingAddress;
1090
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1091
  }
248
  Mollie_WC_Plugin::debug( __METHOD__ . " called for order {$orderId}" );
249
 
250
  if($payment->method === 'paypal'){
251
+ $this->addAddressToPaypalOrder($payment, $order);
252
+ $this->addPaypalTransactionIdToOrder($order);
 
 
 
 
 
 
 
 
 
 
 
253
  }
254
 
255
  $order->payment_complete($payment->id);
280
  );
281
 
282
  // Subscription processing
283
+ $this->addMandateIdMetaToFirstPaymentSubscriptionOrder($order, $payment);
284
  $this->deleteSubscriptionFromPending($order);
285
  } else {
286
  // Add messages to log
349
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $orderId );
350
 
351
  if($payment->method === 'paypal'){
352
+ $this->addAddressToPaypalOrder($payment, $order);
353
+ $this->addPaypalTransactionIdToOrder($order);
 
 
 
 
 
 
 
 
 
 
 
354
  }
355
  $order->payment_complete($payment->id);
356
  // Add messages to log
418
  } elseif ( $orderStatusCancelledPayments == 'cancelled' ) {
419
  $newOrderStatus = Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
420
  }
421
+ // if I cancel manually the order is canceled in Woo before calling Mollie
422
+ if($order->get_status() == 'cancelled'){
423
+ $newOrderStatus = Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
424
+ }
425
 
426
  // Overwrite plugin-wide
427
  $newOrderStatus = apply_filters( Mollie_WC_Plugin::PLUGIN_ID . '_order_status_cancelled', $newOrderStatus );
1071
  );
1072
  return $shippingAddress;
1073
  }
1074
+
1075
+ /**
1076
+ * @param \Mollie\Api\Resources\Order $payment
1077
+ * @param WC_Order $order
1078
+ */
1079
+ protected function addAddressToPaypalOrder(
1080
+ \Mollie\Api\Resources\Order $payment,
1081
+ WC_Order $order
1082
+ ) {
1083
+ $address = $payment->shippingAddress;
1084
+ $filter = FILTER_SANITIZE_STRING;
1085
+ $shippingAddress = [
1086
+ 'first_name' => filter_var($address->givenName, $filter),
1087
+ 'last_name' => filter_var($address->familyName, $filter),
1088
+ 'email' => filter_var($address->email, $filter),
1089
+ 'postcode' => filter_var($address->postalCode, $filter),
1090
+ 'country' => strtoupper(filter_var($address->country, $filter)),
1091
+ 'city' => filter_var($address->city, $filter),
1092
+ 'address_1' => filter_var($address->streetAndNumber, $filter)
1093
+ ];
1094
+
1095
+ $order->set_address($shippingAddress, 'shipping');
1096
+ }
1097
  }
src/Mollie/WC/Payment/Payment.php CHANGED
@@ -149,14 +149,16 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
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() {
@@ -232,6 +234,10 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
232
  // Add messages to log
233
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for payment ' . $orderId );
234
 
 
 
 
 
235
  // WooCommerce 2.2.0 has the option to store the Payment transaction id.
236
  $order->payment_complete($payment->id);
237
 
@@ -308,6 +314,11 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
308
  } elseif ( $orderStatusCancelledPayments == 'cancelled' ) {
309
  $newOrderStatus = Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
310
  }
 
 
 
 
 
311
  // Get current gateway
312
  $gateway = wc_get_payment_gateway_by_order( $order );
313
  // Overwrite plugin-wide
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() {
234
  // Add messages to log
235
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for payment ' . $orderId );
236
 
237
+ if($payment->method === 'paypal'){
238
+ $this->addPaypalTransactionIdToOrder($order);
239
+ }
240
+
241
  // WooCommerce 2.2.0 has the option to store the Payment transaction id.
242
  $order->payment_complete($payment->id);
243
 
314
  } elseif ( $orderStatusCancelledPayments == 'cancelled' ) {
315
  $newOrderStatus = Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
316
  }
317
+ // if I cancel manually the order is canceled in Woo before calling Mollie
318
+ if($order->get_status() == 'cancelled'){
319
+ $newOrderStatus = Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
320
+ }
321
+
322
  // Get current gateway
323
  $gateway = wc_get_payment_gateway_by_order( $order );
324
  // Overwrite plugin-wide
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.4.0';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -89,7 +89,7 @@ class Mollie_WC_Plugin
89
  id int(11) NOT NULL AUTO_INCREMENT,
90
  post_id bigint NOT NULL,
91
  expired_time int NOT NULL,
92
- UNIQUE KEY id (id)
93
  );";
94
  dbDelta($sql);
95
 
@@ -236,10 +236,12 @@ class Mollie_WC_Plugin
236
  add_filter(
237
  'woocommerce_cancel_unpaid_order',
238
  array( __CLASS__, 'maybeLetWCCancelOrder' ),
239
- 90,
240
  2
241
  );
242
 
 
 
243
  // Enqueue Scripts
244
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueFrontendScripts']);
245
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueComponentsAssets']);
@@ -280,7 +282,6 @@ class Mollie_WC_Plugin
280
  self::initDb();
281
  self::schedulePendingPaymentOrdersExpirationCheck();
282
  self::registerFrontendScripts();
283
- wp_enqueue_style('mollie-gateway-icons');
284
  self::maybeFixSubscriptions();
285
 
286
  // Mark plugin initiated
@@ -321,20 +322,66 @@ class Mollie_WC_Plugin
321
 
322
  public static function maybeLetWCCancelOrder($willCancel, $order) {
323
  if (!empty($willCancel)) {
324
- if ($order->get_payment_method()
325
- !== 'mollie_wc_gateway_banktransfer'
 
 
 
 
326
  ) {
327
  return $willCancel;
328
  }
329
- //is banktransfer due date setting activated
330
- $dueDateActive = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_banktransfer_settings', 'activate_expiry_days_setting');
331
- if ($dueDateActive) {
332
- return false;
333
- }
334
  }
335
  return $willCancel;
336
  }
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  public static function voucherEnabledHooks(){
339
  if(mollieWooCommerceIsVoucherEnabled()){
340
  add_filter(
@@ -824,6 +871,8 @@ class Mollie_WC_Plugin
824
  if (is_admin() || !mollieWooCommerceIsCheckoutContext()) {
825
  return;
826
  }
 
 
827
  $applePayGatewayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_applepay_settings', 'enabled');
828
 
829
  if (!$applePayGatewayEnabled) {
@@ -1091,9 +1140,8 @@ class Mollie_WC_Plugin
1091
  $isWcApiRequest = (bool)filter_input(INPUT_GET, 'wc-api', FILTER_SANITIZE_STRING);
1092
  $bankTransferSettings = get_option('mollie_wc_gateway_banktransfer_settings', false);
1093
  $isSettingActivated = false;
1094
- if($bankTransferSettings && isset($bankTransferSettings['activate_expiry_days_setting'])){
1095
- $expiryDays = $bankTransferSettings['activate_expiry_days_setting'];
1096
- $isSettingActivated = mollieWooCommerceStringToBoolOption($expiryDays);
1097
  }
1098
 
1099
  /*
@@ -1600,5 +1648,20 @@ class Mollie_WC_Plugin
1600
 
1601
  return implode(',', wp_list_pluck($data['lines'], 'id'));
1602
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1603
  }
1604
 
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';
89
  id int(11) NOT NULL AUTO_INCREMENT,
90
  post_id bigint NOT NULL,
91
  expired_time int NOT NULL,
92
+ PRIMARY KEY id (id)
93
  );";
94
  dbDelta($sql);
95
 
236
  add_filter(
237
  'woocommerce_cancel_unpaid_order',
238
  array( __CLASS__, 'maybeLetWCCancelOrder' ),
239
+ 9,
240
  2
241
  );
242
 
243
+ self::handleExpiryDateCancelation();
244
+
245
  // Enqueue Scripts
246
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueFrontendScripts']);
247
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueComponentsAssets']);
282
  self::initDb();
283
  self::schedulePendingPaymentOrdersExpirationCheck();
284
  self::registerFrontendScripts();
 
285
  self::maybeFixSubscriptions();
286
 
287
  // Mark plugin initiated
322
 
323
  public static function maybeLetWCCancelOrder($willCancel, $order) {
324
  if (!empty($willCancel)) {
325
+ $isMollieGateway = mollieWooCommerceIsMollieGateway($order->get_payment_method(
326
+ ));
327
+
328
+ $mollieDueDateEnabled = mollieWooCommerceIsGatewayEnabled($order->get_payment_method(
329
+ ), 'activate_expiry_days_setting');
330
+ if (!$isMollieGateway || !$mollieDueDateEnabled
331
  ) {
332
  return $willCancel;
333
  }
334
+
335
+ return false;
 
 
 
336
  }
337
  return $willCancel;
338
  }
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 );
346
+ $heldDuration = isset($gatewaySettings['order_dueDate'])?$gatewaySettings['order_dueDate']:0;
347
+
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;
357
+ $durationInMinutes = $durationInHours*60;
358
+ $heldDurationInSeconds = $durationInMinutes*60;
359
+ }
360
+ $args = [
361
+ 'limit' => -1,
362
+ 'status' => 'pending',
363
+ 'payment_method' => strtolower($gateway),
364
+ 'date_modified' => '<' . (time() - $heldDurationInSeconds),
365
+ 'return'=>'ids'
366
+ ];
367
+ $unpaid_orders =wc_get_orders( $args );
368
+
369
+ if ( $unpaid_orders ) {
370
+ foreach ( $unpaid_orders as $unpaid_order ) {
371
+ $order = wc_get_order( $unpaid_order );
372
+ add_filter('mollie-payments-for-woocommerce_order_status_cancelled', function($newOrderStatus){
373
+ return Mollie_WC_Gateway_Abstract::STATUS_CANCELLED;
374
+ });
375
+ $order->update_status( 'cancelled', __( 'Unpaid order cancelled - time limit reached.', 'woocommerce' ), true );
376
+ self::cancelOrderAtMollie( $order->get_id() );
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(){
386
  if(mollieWooCommerceIsVoucherEnabled()){
387
  add_filter(
871
  if (is_admin() || !mollieWooCommerceIsCheckoutContext()) {
872
  return;
873
  }
874
+ wp_enqueue_style('mollie-gateway-icons');
875
+
876
  $applePayGatewayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_applepay_settings', 'enabled');
877
 
878
  if (!$applePayGatewayEnabled) {
1140
  $isWcApiRequest = (bool)filter_input(INPUT_GET, 'wc-api', FILTER_SANITIZE_STRING);
1141
  $bankTransferSettings = get_option('mollie_wc_gateway_banktransfer_settings', false);
1142
  $isSettingActivated = false;
1143
+ if($bankTransferSettings && isset($bankTransferSettings['order_dueDate'])){
1144
+ $isSettingActivated = $bankTransferSettings['order_dueDate']>0;
 
1145
  }
1146
 
1147
  /*
1648
 
1649
  return implode(',', wp_list_pluck($data['lines'], 'id'));
1650
  }
1651
+
1652
+ public static function handleExpiryDateCancelation()
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'),
1660
+ 11,
1661
+ 2
1662
+ );
1663
+ }
1664
+
1665
+ }
1666
  }
1667
 
src/Mollie/WC/Settings/Page/Mollie.php CHANGED
@@ -22,6 +22,8 @@ class Mollie_WC_Settings_Page_Mollie extends WC_Settings_Page
22
  {
23
  global $current_section;
24
  $settings = $this->get_settings($current_section);
 
 
25
  WC_Admin_Settings::output_fields($settings);
26
  }
27
  /**
@@ -35,30 +37,9 @@ class Mollie_WC_Settings_Page_Mollie extends WC_Settings_Page
35
 
36
  $settings = $this->get_settings($current_section);
37
  if ('applepay_button' === $current_section) {
38
- $data = filter_var_array($_POST,FILTER_SANITIZE_STRING);
39
-
40
- $applepaySettings = [];
41
- isset($data['enabled']) &&($data['enabled'] === '1') ? $applepaySettings['enabled'] = 'yes'
42
- : $applepaySettings['enabled'] = 'no';
43
- isset($data['display_logo'])&&($data['display_logo'] === '1') ?
44
- $applepaySettings['display_logo'] = 'yes'
45
- : $applepaySettings['display_logo'] = 'no';
46
- isset($data['mollie_apple_pay_button_enabled_cart']) && ($data['mollie_apple_pay_button_enabled_cart'] === '1') ?
47
- $applepaySettings['mollie_apple_pay_button_enabled_cart'] = 'yes'
48
- : $applepaySettings['mollie_apple_pay_button_enabled_cart'] = 'no';
49
- isset($data['mollie_apple_pay_button_enabled_product']) && ($data['mollie_apple_pay_button_enabled_product'] === '1') ?
50
- $applepaySettings['mollie_apple_pay_button_enabled_product'] = 'yes'
51
- : $applepaySettings['mollie_apple_pay_button_enabled_product'] = 'no';
52
- isset($data['title']) ? $applepaySettings['title'] = $data['title']
53
- : $applepaySettings['title'] = '';
54
- isset($data['description']) ?
55
- $applepaySettings['description'] = $data['description']
56
- : $applepaySettings['description'] = '';
57
- update_option(
58
- 'mollie_wc_gateway_applepay_settings',
59
- $applepaySettings
60
- );
61
  } else {
 
62
  WC_Admin_Settings::save_fields($settings);
63
  }
64
  }
@@ -171,4 +152,125 @@ class Mollie_WC_Settings_Page_Mollie extends WC_Settings_Page
171
  $sections
172
  );
173
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
22
  {
23
  global $current_section;
24
  $settings = $this->get_settings($current_section);
25
+ $settings = $this->hideKeysIntoStars($settings);
26
+
27
  WC_Admin_Settings::output_fields($settings);
28
  }
29
  /**
37
 
38
  $settings = $this->get_settings($current_section);
39
  if ('applepay_button' === $current_section) {
40
+ $this->saveApplePaySettings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  } else {
42
+ $settings = $this->saveApiKeys($settings);
43
  WC_Admin_Settings::save_fields($settings);
44
  }
45
  }
152
  $sections
153
  );
154
  }
155
+
156
+ /**
157
+ * @param $settings
158
+ *
159
+ * @return array
160
+ */
161
+ protected function hideKeysIntoStars($settings)
162
+ {
163
+ $liveKeyName = 'mollie-payments-for-woocommerce_live_api_key';
164
+ $testKeyName = 'mollie-payments-for-woocommerce_test_api_key';
165
+ $liveValue = get_option($liveKeyName);
166
+ $testValue = get_option($testKeyName);
167
+
168
+ foreach ($settings as $key => $setting) {
169
+ if (($setting['id']
170
+ === $liveKeyName
171
+ && $liveValue)
172
+ || ($setting['id']
173
+ === $testKeyName
174
+ && $testValue)
175
+ ) {
176
+ $settings[$key]['value'] = '**********';
177
+ }
178
+ }
179
+ return $settings;
180
+ }
181
+
182
+ /**
183
+ * @param $settings
184
+ *
185
+ * @return array
186
+ */
187
+ protected function saveApiKeys($settings)
188
+ {
189
+
190
+ $liveKeyName = 'mollie-payments-for-woocommerce_live_api_key';
191
+ $testKeyName = 'mollie-payments-for-woocommerce_test_api_key';
192
+ $liveValueInDb = get_option($liveKeyName);
193
+ $testValueInDb = get_option($testKeyName);
194
+ $postedLiveValue = isset($_POST[$liveKeyName])? sanitize_text_field( $_POST[$liveKeyName] ):'';
195
+ $postedTestValue = isset($_POST[$testKeyName])? sanitize_text_field( $_POST[$testKeyName] ):'';
196
+
197
+ foreach ($settings as $setting) {
198
+ if ($setting['id']
199
+ === $liveKeyName
200
+ && $liveValueInDb
201
+ ) {
202
+ if ($postedLiveValue === '**********') {
203
+ $_POST[$liveKeyName] = $liveValueInDb;
204
+ }else {
205
+ $pattern = '/^live_\w{30,}$/';
206
+ $this->validateApiKeyOrRemove(
207
+ $pattern,
208
+ $postedLiveValue,
209
+ $liveKeyName
210
+ );
211
+ }
212
+ } elseif ($setting['id']
213
+ === $testKeyName
214
+ && $testValueInDb
215
+ ) {
216
+ if ($postedTestValue === '**********') {
217
+ $_POST[$testKeyName] = $testValueInDb;
218
+ }else {
219
+ $pattern = '/^test_\w{30,}$/';
220
+ $this->validateApiKeyOrRemove(
221
+ $pattern,
222
+ $postedTestValue,
223
+ $testKeyName
224
+ );
225
+ }
226
+ }
227
+ }
228
+ return $settings;
229
+ }
230
+
231
+ protected function saveApplePaySettings()
232
+ {
233
+ $data = filter_var_array($_POST, FILTER_SANITIZE_STRING);
234
+
235
+ $applepaySettings = [];
236
+ isset($data['enabled']) && ($data['enabled'] === '1') ?
237
+ $applepaySettings['enabled'] = 'yes'
238
+ : $applepaySettings['enabled'] = 'no';
239
+ isset($data['display_logo']) && ($data['display_logo'] === '1') ?
240
+ $applepaySettings['display_logo'] = 'yes'
241
+ : $applepaySettings['display_logo'] = 'no';
242
+ isset($data['mollie_apple_pay_button_enabled_cart'])
243
+ && ($data['mollie_apple_pay_button_enabled_cart'] === '1') ?
244
+ $applepaySettings['mollie_apple_pay_button_enabled_cart'] = 'yes'
245
+ : $applepaySettings['mollie_apple_pay_button_enabled_cart'] = 'no';
246
+ isset($data['mollie_apple_pay_button_enabled_product'])
247
+ && ($data['mollie_apple_pay_button_enabled_product'] === '1')
248
+ ?
249
+ $applepaySettings['mollie_apple_pay_button_enabled_product'] = 'yes'
250
+ :
251
+ $applepaySettings['mollie_apple_pay_button_enabled_product'] = 'no';
252
+ isset($data['title']) ? $applepaySettings['title'] = $data['title']
253
+ : $applepaySettings['title'] = '';
254
+ isset($data['description']) ?
255
+ $applepaySettings['description'] = $data['description']
256
+ : $applepaySettings['description'] = '';
257
+ update_option(
258
+ 'mollie_wc_gateway_applepay_settings',
259
+ $applepaySettings
260
+ );
261
+ }
262
+
263
+ /**
264
+ * @param $pattern
265
+ * @param $value
266
+ * @param $keyName
267
+ *
268
+ */
269
+ protected function validateApiKeyOrRemove($pattern, $value, $keyName)
270
+ {
271
+ $hasApiFormat = preg_match($pattern, $value);
272
+ if (!$hasApiFormat) {
273
+ unset($_POST[$keyName]);
274
+ }
275
+ }
276
  }
vendor/composer/autoload_classmap.php CHANGED
@@ -43,7 +43,6 @@ return array(
43
  'Mollie_WC_Gateway_Giftcard' => $baseDir . '/src/Mollie/WC/Gateway/Giftcard.php',
44
  'Mollie_WC_Gateway_Giropay' => $baseDir . '/src/Mollie/WC/Gateway/Giropay.php',
45
  'Mollie_WC_Gateway_Ideal' => $baseDir . '/src/Mollie/WC/Gateway/Ideal.php',
46
- 'Mollie_WC_Gateway_IngHomePay' => $baseDir . '/src/Mollie/WC/Gateway/IngHomePay.php',
47
  'Mollie_WC_Gateway_Kbc' => $baseDir . '/src/Mollie/WC/Gateway/Kbc.php',
48
  'Mollie_WC_Gateway_KlarnaPayLater' => $baseDir . '/src/Mollie/WC/Gateway/KlarnaPayLater.php',
49
  'Mollie_WC_Gateway_KlarnaSliceIt' => $baseDir . '/src/Mollie/WC/Gateway/KlarnaSliceIt.php',
43
  'Mollie_WC_Gateway_Giftcard' => $baseDir . '/src/Mollie/WC/Gateway/Giftcard.php',
44
  'Mollie_WC_Gateway_Giropay' => $baseDir . '/src/Mollie/WC/Gateway/Giropay.php',
45
  'Mollie_WC_Gateway_Ideal' => $baseDir . '/src/Mollie/WC/Gateway/Ideal.php',
 
46
  'Mollie_WC_Gateway_Kbc' => $baseDir . '/src/Mollie/WC/Gateway/Kbc.php',
47
  'Mollie_WC_Gateway_KlarnaPayLater' => $baseDir . '/src/Mollie/WC/Gateway/KlarnaPayLater.php',
48
  'Mollie_WC_Gateway_KlarnaSliceIt' => $baseDir . '/src/Mollie/WC/Gateway/KlarnaSliceIt.php',
vendor/composer/autoload_static.php CHANGED
@@ -163,7 +163,6 @@ class ComposerStaticInit68ce666d6530886f5f9fc388596510e2
163
  'Mollie_WC_Gateway_Giftcard' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Giftcard.php',
164
  'Mollie_WC_Gateway_Giropay' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Giropay.php',
165
  'Mollie_WC_Gateway_Ideal' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Ideal.php',
166
- 'Mollie_WC_Gateway_IngHomePay' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/IngHomePay.php',
167
  'Mollie_WC_Gateway_Kbc' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Kbc.php',
168
  'Mollie_WC_Gateway_KlarnaPayLater' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/KlarnaPayLater.php',
169
  'Mollie_WC_Gateway_KlarnaSliceIt' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/KlarnaSliceIt.php',
163
  'Mollie_WC_Gateway_Giftcard' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Giftcard.php',
164
  'Mollie_WC_Gateway_Giropay' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Giropay.php',
165
  'Mollie_WC_Gateway_Ideal' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Ideal.php',
 
166
  'Mollie_WC_Gateway_Kbc' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Kbc.php',
167
  'Mollie_WC_Gateway_KlarnaPayLater' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/KlarnaPayLater.php',
168
  'Mollie_WC_Gateway_KlarnaSliceIt' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/KlarnaSliceIt.php',