Mollie Payments for WooCommerce - Version 5.0.5

Version Description

  • 22-11-2018 =

  • Fix - WooCommerce Subscriptions: improve support for options "Accept Manual Renewals" and "Turn off Automatic Payments"

  • Fix - Update Refunds and Chargebacks processing to support Orders and Payments API

  • Fix - Remove option to set a description for payments, the new Orders API does not support this

  • Fix - Update is_available to use billing country, and add filter Mollie_WC_Plugin::PLUGIN_ID . 'is_available_billing_countryfor_payment_gateways'

  • Fix - Add new hook after renewal payment is created: mollie-payments-for-woocommerce_after_renewal_payment_created

  • Fix - Improve warnings in WooCommerce > Settings > Payments so they are less confusing to users (and really dismissable)

  • Fix - Simplify log messages in shipAndCaptureOrderAtMollie, cancelOrderAtMollie

Download this release

Release Info

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

Code changes from version 5.0.4 to 5.0.5

includes/mollie/wc/gateway/abstract.php CHANGED
@@ -278,6 +278,8 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
278
  $currency = get_woocommerce_currency();
279
  }
280
 
 
 
281
  // Get current locale for this user
282
  $payment_locale = Mollie_WC_Plugin::getSettingsHelper()->getPaymentLocale();
283
 
@@ -287,7 +289,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
287
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order_total, $currency )
288
  ),
289
  'resource' => 'orders',
290
- 'billingCountry' => WC()->customer->get_shipping_country(),
291
  'locale' => $payment_locale,
292
  'sequenceType' => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_ONEOFF
293
  );
@@ -305,7 +307,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
305
  $accept_manual_renewals = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no' ) ) ? true : false;
306
  $supports_subscriptions = $this->supports( 'subscriptions' );
307
 
308
- if ( $accept_manual_renewals !== 1 && $supports_subscriptions ) {
309
 
310
  if ( ! empty( $recurring_totals ) ) {
311
  foreach ( $recurring_totals as $recurring_total ) {
@@ -317,7 +319,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
317
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $recurring_total, $currency )
318
  ),
319
  'resource' => 'orders',
320
- 'billingCountry' => WC()->customer->get_shipping_country(),
321
  'locale' => $payment_locale,
322
  'sequenceType' => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_RECURRING
323
  );
@@ -334,7 +336,7 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
334
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order_total, $currency )
335
  ),
336
  'resource' => 'orders',
337
- 'billingCountry' => WC()->customer->get_shipping_country(),
338
  'locale' => $payment_locale,
339
  'sequenceType' => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_FIRST
340
  );
@@ -813,20 +815,19 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
813
  Mollie_WC_Plugin::debug($this->id . ": Mollie payment object {$payment->id} (" . $payment->mode . ") webhook call for order {$order->get_id()}.", true);
814
  }
815
 
816
- // TODO David: move to payment object?
817
  // Order does not need a payment
818
- // if ( ! $this->orderNeedsPayment( $order ) ) {
819
- //
820
- // // TODO David: move to payment object?
821
- // // Add a debug message that order was already paid for
822
- // $this->handlePaidOrderWebhook( $order, $payment );
823
- //
824
- // // Check and process a possible refund or chargeback
825
- // $this->processRefunds( $order, $payment );
826
- // $this->processChargebacks( $order, $payment );
827
- //
828
- // return;
829
- // }
830
 
831
  // Get payment method title
832
  $payment_method_title = $this->getPaymentMethodTitle( $payment );
@@ -872,10 +873,10 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
872
  }
873
 
874
  /**
875
- * @param WC_Order $order
876
- * @param Mollie\Api\Resources\Payment $payment
877
  */
878
- protected function processRefunds( WC_Order $order, Mollie\Api\Resources\Payment $payment ) {
879
 
880
  // Get order ID in the correct way depending on WooCommerce version
881
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
@@ -968,10 +969,10 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
968
  }
969
 
970
  /**
971
- * @param WC_Order $order
972
- * @param Mollie\Api\Resources\Payment $payment
973
  */
974
- protected function processChargebacks( WC_Order $order, Mollie\Api\Resources\Payment $payment ) {
975
 
976
  // Get order ID in the correct way depending on WooCommerce version
977
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
278
  $currency = get_woocommerce_currency();
279
  }
280
 
281
+ $billing_country = apply_filters( Mollie_WC_Plugin::PLUGIN_ID . '_is_available_billing_country_for_payment_gateways', WC()->customer->get_billing_country() );
282
+
283
  // Get current locale for this user
284
  $payment_locale = Mollie_WC_Plugin::getSettingsHelper()->getPaymentLocale();
285
 
289
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order_total, $currency )
290
  ),
291
  'resource' => 'orders',
292
+ 'billingCountry' => $billing_country,
293
  'locale' => $payment_locale,
294
  'sequenceType' => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_ONEOFF
295
  );
307
  $accept_manual_renewals = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no' ) ) ? true : false;
308
  $supports_subscriptions = $this->supports( 'subscriptions' );
309
 
310
+ if ( $accept_manual_renewals !== true && $supports_subscriptions ) {
311
 
312
  if ( ! empty( $recurring_totals ) ) {
313
  foreach ( $recurring_totals as $recurring_total ) {
319
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $recurring_total, $currency )
320
  ),
321
  'resource' => 'orders',
322
+ 'billingCountry' => $billing_country,
323
  'locale' => $payment_locale,
324
  'sequenceType' => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_RECURRING
325
  );
336
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order_total, $currency )
337
  ),
338
  'resource' => 'orders',
339
+ 'billingCountry' => $billing_country,
340
  'locale' => $payment_locale,
341
  'sequenceType' => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_FIRST
342
  );
815
  Mollie_WC_Plugin::debug($this->id . ": Mollie payment object {$payment->id} (" . $payment->mode . ") webhook call for order {$order->get_id()}.", true);
816
  }
817
 
 
818
  // Order does not need a payment
819
+ if ( ! $this->orderNeedsPayment( $order ) ) {
820
+
821
+ // TODO David: move to payment object?
822
+ // Add a debug message that order was already paid for
823
+ $this->handlePaidOrderWebhook( $order, $payment );
824
+
825
+ // Check and process a possible refund or chargeback
826
+ $this->processRefunds( $order, $payment );
827
+ $this->processChargebacks( $order, $payment );
828
+
829
+ return;
830
+ }
831
 
832
  // Get payment method title
833
  $payment_method_title = $this->getPaymentMethodTitle( $payment );
873
  }
874
 
875
  /**
876
+ * @param WC_Order $order
877
+ * @param Mollie\Api\Resources\Payment|Mollie\Api\Resources\Order $payment
878
  */
879
+ protected function processRefunds( WC_Order $order, $payment ) {
880
 
881
  // Get order ID in the correct way depending on WooCommerce version
882
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
969
  }
970
 
971
  /**
972
+ * @param WC_Order $order
973
+ * @param Mollie\Api\Resources\Payment|Mollie\Api\Resources\Order $payment
974
  */
975
+ protected function processChargebacks( WC_Order $order, $payment ) {
976
 
977
  // Get order ID in the correct way depending on WooCommerce version
978
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
includes/mollie/wc/gateway/abstractsubscription.php CHANGED
@@ -60,69 +60,59 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
60
  * @param $customer_id
61
  * @return array
62
  */
63
- protected function getRecurringPaymentRequestData($order, $customer_id)
64
- {
65
 
66
- // TODO David: is this still used?
67
- $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
68
- $payment_description = $settings_helper->getPaymentDescription();
69
- $payment_locale = $settings_helper->getPaymentLocale();
70
- $mollie_method = $this->getMollieMethodId();
71
- $selected_issuer = $this->getSelectedIssuer();
72
- $return_url = $this->getReturnUrl($order);
73
- $webhook_url = $this->getWebhookUrl($order);
74
 
75
- if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
76
- $payment_description = strtr($payment_description, array(
77
- '{order_number}' => $order->get_order_number(),
78
- '{order_date}' => date_i18n(wc_date_format(), strtotime($order->order_date)),
79
- ));
80
-
81
- $data = array_filter(array(
82
- 'amount' => array (
83
- 'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
84
- 'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue($order->get_total(), Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ))
85
- ),
86
- 'description' => $payment_description,
87
- 'redirectUrl' => $return_url,
88
- 'webhookUrl' => $webhook_url,
89
- 'method' => $mollie_method,
90
- 'issuer' => $selected_issuer,
91
- 'locale' => $payment_locale,
92
- 'metadata' => array(
93
- 'order_id' => $order->id,
94
- ),
95
- 'sequenceType' => 'recurring',
96
- 'customerId' => $customer_id,
97
- ));
98
- } else {
99
 
100
- $payment_description = strtr($payment_description, array(
101
- '{order_number}' => $order->get_order_number(),
102
- '{order_date}' => date_i18n(wc_date_format(), $order->get_date_created()->getTimestamp()),
103
- ));
104
-
105
- $data = array_filter( array (
106
- 'amount' => array (
107
- 'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
108
- 'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order->get_total(), Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) )
109
- ),
110
- 'description' => $payment_description,
111
- 'redirectUrl' => $return_url,
112
- 'webhookUrl' => $webhook_url,
113
- 'method' => $mollie_method,
114
- 'issuer' => $selected_issuer,
115
- 'locale' => $payment_locale,
116
- 'metadata' => array(
117
- 'order_id' => $order->get_id(),
118
- ),
119
- 'sequenceType' => 'recurring',
120
- 'customerId' => $customer_id,
121
- ));
122
- }
123
-
124
- return $data;
125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  /**
128
  * @param $renewal_order
@@ -299,13 +289,15 @@ abstract class Mollie_WC_Gateway_AbstractSubscription extends Mollie_WC_Gateway_
299
  // Tell WooCommerce a new payment was created for the order/subscription
300
  do_action(Mollie_WC_Plugin::PLUGIN_ID . '_payment_created', $payment, $renewal_order);
301
 
302
- // Set initial status
303
- // Status is only updated if the new status is not the same as the default order status (pending)
304
  $this->_updateScheduledPaymentOrder($renewal_order, $initial_order_status, $payment);
305
 
306
  // Update status of subscriptions with payment method SEPA Direct Debit or similar
307
  $this->update_subscription_status_for_direct_debit( $renewal_order );
308
 
 
 
 
309
  return array(
310
  'result' => 'success',
311
  );
60
  * @param $customer_id
61
  * @return array
62
  */
63
+ protected function getRecurringPaymentRequestData( $order, $customer_id ) {
 
64
 
65
+ // TODO David: is this still used?
66
+ $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
67
+ $payment_description = _( 'Order', 'woocommerce' ) . ' ' . $order->get_order_number();
68
+ $payment_locale = $settings_helper->getPaymentLocale();
69
+ $mollie_method = $this->getMollieMethodId();
70
+ $selected_issuer = $this->getSelectedIssuer();
71
+ $return_url = $this->getReturnUrl( $order );
72
+ $webhook_url = $this->getWebhookUrl( $order );
73
 
74
+ if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
+ $data = array_filter( array (
77
+ 'amount' => array (
78
+ 'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
79
+ 'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order->get_total(), Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) )
80
+ ),
81
+ 'description' => $payment_description,
82
+ 'redirectUrl' => $return_url,
83
+ 'webhookUrl' => $webhook_url,
84
+ 'method' => $mollie_method,
85
+ 'issuer' => $selected_issuer,
86
+ 'locale' => $payment_locale,
87
+ 'metadata' => array (
88
+ 'order_id' => $order->id,
89
+ ),
90
+ 'sequenceType' => 'recurring',
91
+ 'customerId' => $customer_id,
92
+ ) );
93
+ } else {
94
+
95
+ $data = array_filter( array (
96
+ 'amount' => array (
97
+ 'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
98
+ 'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order->get_total(), Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) )
99
+ ),
100
+ 'description' => $payment_description,
101
+ 'redirectUrl' => $return_url,
102
+ 'webhookUrl' => $webhook_url,
103
+ 'method' => $mollie_method,
104
+ 'issuer' => $selected_issuer,
105
+ 'locale' => $payment_locale,
106
+ 'metadata' => array (
107
+ 'order_id' => $order->get_id(),
108
+ ),
109
+ 'sequenceType' => 'recurring',
110
+ 'customerId' => $customer_id,
111
+ ) );
112
+ }
113
+
114
+ return $data;
115
+ }
116
 
117
  /**
118
  * @param $renewal_order
289
  // Tell WooCommerce a new payment was created for the order/subscription
290
  do_action(Mollie_WC_Plugin::PLUGIN_ID . '_payment_created', $payment, $renewal_order);
291
 
292
+ // Update order status and add order note
 
293
  $this->_updateScheduledPaymentOrder($renewal_order, $initial_order_status, $payment);
294
 
295
  // Update status of subscriptions with payment method SEPA Direct Debit or similar
296
  $this->update_subscription_status_for_direct_debit( $renewal_order );
297
 
298
+ // Tell WooCommerce a new payment was created for the order/subscription
299
+ do_action(Mollie_WC_Plugin::PLUGIN_ID . '_after_renewal_payment_created', $payment, $renewal_order);
300
+
301
  return array(
302
  'result' => 'success',
303
  );
includes/mollie/wc/helper/settings.php CHANGED
@@ -21,16 +21,6 @@ class Mollie_WC_Helper_Settings
21
  return trim(get_option($this->getSettingId($setting_id)));
22
  }
23
 
24
- /**
25
- * Description send to Mollie
26
- *
27
- * @return string|null
28
- */
29
- public function getPaymentDescription ()
30
- {
31
- return trim(get_option($this->getSettingId('payment_description')));
32
- }
33
-
34
  /**
35
  * Order status for cancelled payments
36
  *
@@ -328,10 +318,6 @@ class Mollie_WC_Helper_Settings
328
  . $this->getPluginStatus()
329
  . $this->getMollieMethods();
330
 
331
- /* translators: Default payment description. {order_number} and {order_date} are available tags. */
332
- $default_payment_description = __('Order {order_number}', 'mollie-payments-for-woocommerce');
333
- $payment_description_tags = '<code>{order_number}</code>, <code>{order_date}</code>';
334
-
335
  $debug_desc = __('Log plugin events.', 'mollie-payments-for-woocommerce');
336
 
337
  // For WooCommerce 2.2.0+ display view logs link
@@ -566,10 +552,6 @@ class Mollie_WC_Helper_Settings
566
  $content .= $warning_message;
567
  $content .= '</p></div> ';
568
 
569
- $content .= '<strong><p>';
570
- $content .= $warning_message;
571
- $content .= '</p></strong> ';
572
-
573
  return $content;
574
  }
575
 
@@ -591,10 +573,6 @@ class Mollie_WC_Helper_Settings
591
  $content .= __( 'You have the WooCommerce default Direct Bank Transfer (BACS) payment gateway enabled in WooCommerce. Mollie strongly advices only using Bank Transfer via Mollie and disabling the default WooCommerce BACS payment gateway to prevent possible conflicts.', 'mollie-payments-for-woocommerce' );
592
  $content .= '</p></div> ';
593
 
594
- $content .= '<strong><p>';
595
- $content .= __( 'You have the WooCommerce default Direct Bank Transfer (BACS) payment gateway enabled in WooCommerce. Mollie strongly advices only using Bank Transfer via Mollie and disabling the default WooCommerce BACS payment gateway to prevent possible conflicts.', 'mollie-payments-for-woocommerce' );
596
- $content .= '</p></strong> ';
597
-
598
  return $content;
599
  }
600
 
@@ -615,14 +593,10 @@ class Mollie_WC_Helper_Settings
615
 
616
  if ( $woocommerce_klarnapaylater_gateway->is_available() || $woocommerce_klarnasliceit_gateway->is_available() ) {
617
 
618
- $content .= '<div class="notice notice-error is-dismissible"><p>';
619
- $content .= __( 'To accept Klarna payments via Mollie, all default WooCommerce checkout fields should be enabled and required.', 'mollie-payments-for-woocommerce' );
620
  $content .= '</p></div> ';
621
 
622
- $content .= '<strong><p>';
623
- $content .= __( 'To accept Klarna payments via Mollie, all default WooCommerce checkout fields should be enabled and required.', 'mollie-payments-for-woocommerce' );
624
- $content .= '</p></strong> ';
625
-
626
  return $content;
627
  }
628
  }
@@ -644,14 +618,10 @@ class Mollie_WC_Helper_Settings
644
 
645
  if ( $woocommerce_klarnapaylater_gateway->is_available() || $woocommerce_klarnasliceit_gateway->is_available() ) {
646
 
647
- $content .= '<div class="notice notice-error is-dismissible"><p>';
648
  $content .= sprintf(__( 'To accept Klarna payments via Mollie, you need to use at least WooCommerce 3.0 or higher, you are now using version %s.', 'mollie-payments-for-woocommerce' ), WC_VERSION);
649
  $content .= '</p></div> ';
650
 
651
- $content .= '<strong><p>';
652
- $content .= sprintf(__( 'To accept Klarna payments via Mollie, you need to use at least WooCommerce 3.0 or higher, you are now using version %s.', 'mollie-payments-for-woocommerce' ), WC_VERSION);
653
- $content .= '</p></strong> ';
654
-
655
  return $content;
656
  }
657
  }
21
  return trim(get_option($this->getSettingId($setting_id)));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Order status for cancelled payments
26
  *
318
  . $this->getPluginStatus()
319
  . $this->getMollieMethods();
320
 
 
 
 
 
321
  $debug_desc = __('Log plugin events.', 'mollie-payments-for-woocommerce');
322
 
323
  // For WooCommerce 2.2.0+ display view logs link
552
  $content .= $warning_message;
553
  $content .= '</p></div> ';
554
 
 
 
 
 
555
  return $content;
556
  }
557
 
573
  $content .= __( 'You have the WooCommerce default Direct Bank Transfer (BACS) payment gateway enabled in WooCommerce. Mollie strongly advices only using Bank Transfer via Mollie and disabling the default WooCommerce BACS payment gateway to prevent possible conflicts.', 'mollie-payments-for-woocommerce' );
574
  $content .= '</p></div> ';
575
 
 
 
 
 
576
  return $content;
577
  }
578
 
593
 
594
  if ( $woocommerce_klarnapaylater_gateway->is_available() || $woocommerce_klarnasliceit_gateway->is_available() ) {
595
 
596
+ $content .= '<div class="notice notice-warning is-dismissible"><p>';
597
+ $content .= __( 'To accept Klarna payments via Mollie, all default WooCommerce checkout fields should be enabled and required. Please make sure that is the case.', 'mollie-payments-for-woocommerce' );
598
  $content .= '</p></div> ';
599
 
 
 
 
 
600
  return $content;
601
  }
602
  }
618
 
619
  if ( $woocommerce_klarnapaylater_gateway->is_available() || $woocommerce_klarnasliceit_gateway->is_available() ) {
620
 
621
+ $content .= '<div class="notice notice-warning is-dismissible"><p>';
622
  $content .= sprintf(__( 'To accept Klarna payments via Mollie, you need to use at least WooCommerce 3.0 or higher, you are now using version %s.', 'mollie-payments-for-woocommerce' ), WC_VERSION);
623
  $content .= '</p></div> ';
624
 
 
 
 
 
625
  return $content;
626
  }
627
  }
includes/mollie/wc/payment/order.php CHANGED
@@ -38,7 +38,6 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
38
  */
39
  public function getPaymentRequestData( $order, $customer_id ) {
40
  $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
41
- $payment_description = $settings_helper->getPaymentDescription();
42
  $payment_locale = $settings_helper->getPaymentLocale();
43
  $store_customer = $settings_helper->shouldStoreCustomer();
44
 
@@ -55,17 +54,11 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
55
 
56
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
57
 
58
- $payment_description = strtr( $payment_description, array (
59
- '{order_number}' => $order->get_order_number(),
60
- '{order_date}' => date_i18n( wc_date_format(), strtotime( $order->order_date ) ),
61
- ) );
62
-
63
  $paymentRequestData = array (
64
  'amount' => array (
65
  'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
66
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order->get_total(), Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) )
67
  ),
68
- 'description' => $payment_description,
69
  'redirectUrl' => $return_url,
70
  'webhookUrl' => $webhook_url,
71
  'method' => $mollie_method,
@@ -79,7 +72,14 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
79
  // Add sequenceType for subscriptions first payments
80
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
81
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->id ) ) {
82
- $paymentRequestData['payment']['sequenceType'] = 'first';
 
 
 
 
 
 
 
83
  }
84
  }
85
 
@@ -144,13 +144,20 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
144
  // Add sequenceType for subscriptions first payments
145
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
146
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->get_id() ) ) {
147
- $paymentRequestData['payment']['sequenceType'] = 'first';
 
 
 
 
 
 
 
148
  }
149
  }
150
  }
151
 
152
  // Only add shippingAddress if all required fields are set
153
- if ( isset( $shippingAddress->streetandNumber ) && isset( $shippingAddress->postalCode ) && isset( $shippingAddress->city ) && isset( $shippingAddress->country ) ) {
154
  $paymentRequestData['shippingAddress'] = $shippingAddress;
155
  }
156
 
38
  */
39
  public function getPaymentRequestData( $order, $customer_id ) {
40
  $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
 
41
  $payment_locale = $settings_helper->getPaymentLocale();
42
  $store_customer = $settings_helper->shouldStoreCustomer();
43
 
54
 
55
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
56
 
 
 
 
 
 
57
  $paymentRequestData = array (
58
  'amount' => array (
59
  'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
60
  'value' => Mollie_WC_Plugin::getDataHelper()->formatCurrencyValue( $order->get_total(), Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ) )
61
  ),
 
62
  'redirectUrl' => $return_url,
63
  'webhookUrl' => $webhook_url,
64
  'method' => $mollie_method,
72
  // Add sequenceType for subscriptions first payments
73
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
74
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->id ) ) {
75
+
76
+ // See get_available_payment_gateways() in woocommerce-subscriptions/includes/gateways/class-wc-subscriptions-payment-gateways.php
77
+ $disable_automatic_payments = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no' ) ) ? true : false;
78
+ $supports_subscriptions = $gateway->supports( 'subscriptions' );
79
+
80
+ if ( $supports_subscriptions == true && $disable_automatic_payments == false ) {
81
+ $paymentRequestData['payment']['sequenceType'] = 'first';
82
+ }
83
  }
84
  }
85
 
144
  // Add sequenceType for subscriptions first payments
145
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
146
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->get_id() ) ) {
147
+
148
+ // See get_available_payment_gateways() in woocommerce-subscriptions/includes/gateways/class-wc-subscriptions-payment-gateways.php
149
+ $disable_automatic_payments = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no' ) ) ? true : false;
150
+ $supports_subscriptions = $gateway->supports( 'subscriptions' );
151
+
152
+ if ( $supports_subscriptions == true && $disable_automatic_payments == false ) {
153
+ $paymentRequestData['payment']['sequenceType'] = 'first';
154
+ }
155
  }
156
  }
157
  }
158
 
159
  // Only add shippingAddress if all required fields are set
160
+ if ( isset( $shippingAddress->streetAndNumber ) && isset( $shippingAddress->postalCode ) && isset( $shippingAddress->city ) && isset( $shippingAddress->country ) ) {
161
  $paymentRequestData['shippingAddress'] = $shippingAddress;
162
  }
163
 
includes/mollie/wc/payment/payment.php CHANGED
@@ -32,7 +32,7 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
32
  */
33
  public function getPaymentRequestData( $order, $customer_id ) {
34
  $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
35
- $payment_description = $settings_helper->getPaymentDescription();
36
  $payment_locale = $settings_helper->getPaymentLocale();
37
  $store_customer = $settings_helper->shouldStoreCustomer();
38
 
@@ -49,11 +49,6 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
49
 
50
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
51
 
52
- $payment_description = strtr( $payment_description, array (
53
- '{order_number}' => $order->get_order_number(),
54
- '{order_date}' => date_i18n( wc_date_format(), strtotime( $order->order_date ) ),
55
- ) );
56
-
57
  $paymentRequestData = array (
58
  'amount' => array (
59
  'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
@@ -73,17 +68,19 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
73
  // Add sequenceType for subscriptions first payments
74
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
75
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->id ) ) {
76
- $paymentRequestData['sequenceType'] = 'first';
 
 
 
 
 
 
 
77
  }
78
  }
79
 
80
  } else {
81
 
82
- $payment_description = strtr( $payment_description, array (
83
- '{order_number}' => $order->get_order_number(),
84
- '{order_date}' => date_i18n( wc_date_format(), $order->get_date_created()->getTimestamp() ),
85
- ) );
86
-
87
  $paymentRequestData = array (
88
  'amount' => array (
89
  'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
@@ -103,7 +100,14 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
103
  // Add sequenceType for subscriptions first payments
104
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
105
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->get_id() ) ) {
106
- $paymentRequestData['sequenceType'] = 'first';
 
 
 
 
 
 
 
107
  }
108
  }
109
  }
32
  */
33
  public function getPaymentRequestData( $order, $customer_id ) {
34
  $settings_helper = Mollie_WC_Plugin::getSettingsHelper();
35
+ $payment_description = _( 'Order', 'woocommerce' ) . ' ' . $order->get_order_number();
36
  $payment_locale = $settings_helper->getPaymentLocale();
37
  $store_customer = $settings_helper->shouldStoreCustomer();
38
 
49
 
50
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
51
 
 
 
 
 
 
52
  $paymentRequestData = array (
53
  'amount' => array (
54
  'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
68
  // Add sequenceType for subscriptions first payments
69
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
70
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->id ) ) {
71
+
72
+ // See get_available_payment_gateways() in woocommerce-subscriptions/includes/gateways/class-wc-subscriptions-payment-gateways.php
73
+ $disable_automatic_payments = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no' ) ) ? true : false;
74
+ $supports_subscriptions = $gateway->supports( 'subscriptions' );
75
+
76
+ if ( $supports_subscriptions == true && $disable_automatic_payments == false ) {
77
+ $paymentRequestData['sequenceType'] = 'first';
78
+ }
79
  }
80
  }
81
 
82
  } else {
83
 
 
 
 
 
 
84
  $paymentRequestData = array (
85
  'amount' => array (
86
  'currency' => Mollie_WC_Plugin::getDataHelper()->getOrderCurrency( $order ),
100
  // Add sequenceType for subscriptions first payments
101
  if ( class_exists( 'WC_Subscriptions' ) && class_exists( 'WC_Subscriptions_Admin' ) ) {
102
  if ( Mollie_WC_Plugin::getDataHelper()->isSubscription( $order->get_id() ) ) {
103
+
104
+ // See get_available_payment_gateways() in woocommerce-subscriptions/includes/gateways/class-wc-subscriptions-payment-gateways.php
105
+ $disable_automatic_payments = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'no' ) ) ? true : false;
106
+ $supports_subscriptions = $gateway->supports( 'subscriptions' );
107
+
108
+ if ( $supports_subscriptions == true && $disable_automatic_payments == false ) {
109
+ $paymentRequestData['sequenceType'] = 'first';
110
+ }
111
  }
112
  }
113
  }
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 = '5.0.4';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -604,8 +604,6 @@ class Mollie_WC_Plugin
604
  return;
605
  }
606
 
607
- Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Start processing completed order for a potential capture at Mollie.' );
608
-
609
  $order = Mollie_WC_Plugin::getDataHelper()->getWcOrder( $order_id );
610
 
611
  // Set Klarna payment methods
@@ -618,11 +616,11 @@ class Mollie_WC_Plugin
618
 
619
  // Does WooCommerce order contain a payment via Klarna?
620
  if ( ! in_array( $order->get_payment_method(), $klarna_methods, true ) ) {
621
- Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Processing completed order stopped, not a Klarna payment.' );
622
-
623
  return;
624
  }
625
 
 
 
626
  // Does WooCommerce order contain a Mollie Order?
627
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
628
  $mollie_order_id = ( $mollie_order_id = get_post_meta( $order->id, '_mollie_order_id', true ) ) ? $mollie_order_id : false;
@@ -694,8 +692,6 @@ class Mollie_WC_Plugin
694
  return;
695
  }
696
 
697
- Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Start canceling an order at Mollie.' );
698
-
699
  $order = Mollie_WC_Plugin::getDataHelper()->getWcOrder( $order_id );
700
 
701
  // Set Klarna payment methods
@@ -708,11 +704,11 @@ class Mollie_WC_Plugin
708
 
709
  // Does WooCommerce order contain a payment via Klarna?
710
  if ( ! in_array( $order->get_payment_method(), $klarna_methods, true ) ) {
711
- Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Canceling order stopped, not a Klarna payment.' );
712
-
713
  return;
714
  }
715
 
 
 
716
  // Does WooCommerce order contain a Mollie Order?
717
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
718
  $mollie_order_id = ( $mollie_order_id = get_post_meta( $order->id, '_mollie_order_id', true ) ) ? $mollie_order_id : false;
7
  {
8
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
9
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
10
+ const PLUGIN_VERSION = '5.0.5';
11
 
12
  const DB_VERSION = '1.0';
13
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
604
  return;
605
  }
606
 
 
 
607
  $order = Mollie_WC_Plugin::getDataHelper()->getWcOrder( $order_id );
608
 
609
  // Set Klarna payment methods
616
 
617
  // Does WooCommerce order contain a payment via Klarna?
618
  if ( ! in_array( $order->get_payment_method(), $klarna_methods, true ) ) {
 
 
619
  return;
620
  }
621
 
622
+ Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Try to process completed order for a potential capture at Mollie.' );
623
+
624
  // Does WooCommerce order contain a Mollie Order?
625
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
626
  $mollie_order_id = ( $mollie_order_id = get_post_meta( $order->id, '_mollie_order_id', true ) ) ? $mollie_order_id : false;
692
  return;
693
  }
694
 
 
 
695
  $order = Mollie_WC_Plugin::getDataHelper()->getWcOrder( $order_id );
696
 
697
  // Set Klarna payment methods
704
 
705
  // Does WooCommerce order contain a payment via Klarna?
706
  if ( ! in_array( $order->get_payment_method(), $klarna_methods, true ) ) {
 
 
707
  return;
708
  }
709
 
710
+ Mollie_WC_Plugin::debug( __METHOD__ . ' - ' . $order_id . ' - Try to process cancelled order at Mollie.' );
711
+
712
  // Does WooCommerce order contain a Mollie Order?
713
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
714
  $mollie_order_id = ( $mollie_order_id = get_post_meta( $order->id, '_mollie_order_id', true ) ) ? $mollie_order_id : false;
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: 5.0.4
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: 5.0.5
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: 5.0.4
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -181,10 +181,17 @@ Automatic updates should work like a charm; as always though, ensure you backup
181
 
182
  == Changelog ==
183
 
184
- = 5.0.4 - 08-11-2018 =
185
 
186
- IMPORTANT
187
- This version requires PHP 5.6 or higher. If you are using an older PHP version, please read this article: [PHP & Mollie API v2](https://github.com/mollie/WooCommerce/wiki/PHP-&-Mollie-API-v2).
 
 
 
 
 
 
 
188
 
189
  * Fix - Get test mode higher in scheduled_subscription_payment() process
190
  * Fix - Add automated option to restore a customer ID from Mollie API
@@ -193,9 +200,6 @@ This version requires PHP 5.6 or higher. If you are using an older PHP version,
193
 
194
  = 5.0.3 - 01-11-2018 =
195
 
196
- IMPORTANT
197
- This version requires PHP 5.6 or higher. If you are using an older PHP version, please read this article: [PHP & Mollie API v2](https://github.com/mollie/WooCommerce/wiki/PHP-&-Mollie-API-v2).
198
-
199
  * Fix - Improvements to refunds: better log messages, show errors to shop-manager
200
  * Fix - Remove option to set a description for payments, the new Orders API does not support this
201
  * Fix - Update WooCommerce status constants in our plugin (cancelled and refunded)
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: 5.0.5
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
+ = 5.0.5 - 22-11-2018 =
185
 
186
+ * Fix - WooCommerce Subscriptions: improve support for options "Accept Manual Renewals" and "Turn off Automatic Payments"
187
+ * Fix - Update Refunds and Chargebacks processing to support Orders and Payments API
188
+ * Fix - Remove option to set a description for payments, the new Orders API does not support this
189
+ * Fix - Update is_available to use billing country, and add filter Mollie_WC_Plugin::PLUGIN_ID . '_is_available_billing_country_for_payment_gateways'
190
+ * Fix - Add new hook after renewal payment is created: mollie-payments-for-woocommerce_after_renewal_payment_created
191
+ * Fix - Improve warnings in WooCommerce > Settings > Payments so they are less confusing to users (and really dismissable)
192
+ * Fix - Simplify log messages in shipAndCaptureOrderAtMollie, cancelOrderAtMollie
193
+
194
+ = 5.0.4 - 08-11-2018 =
195
 
196
  * Fix - Get test mode higher in scheduled_subscription_payment() process
197
  * Fix - Add automated option to restore a customer ID from Mollie API
200
 
201
  = 5.0.3 - 01-11-2018 =
202
 
 
 
 
203
  * Fix - Improvements to refunds: better log messages, show errors to shop-manager
204
  * Fix - Remove option to set a description for payments, the new Orders API does not support this
205
  * Fix - Update WooCommerce status constants in our plugin (cancelled and refunded)