diff --git a/README.txt b/README.txt index 49ae9dc..6b3150a 100644 --- a/README.txt +++ b/README.txt @@ -154,6 +154,10 @@ Alternatively you could look into using WooCommerce "Early renewals": [https://d == Changelog == += 1.9.1 = +* Fix: Renewal orders will no longer transition to `completed` when the setting for this is turned off. +* Fix: Fixed a problem where our `_vipps_recurring_waiting_for_gateway_change` was never processed for orders where the subscription was not `wc-active`. Added `wc-on-hold` and `wc-pending` to this list. + = 1.9.0 = * Enhancement: Added a setting for what sort order we should check charges by. * Enhancement: Added a setting for how many charges we should check at a time. diff --git a/includes/wc-gateway-vipps-recurring.php b/includes/wc-gateway-vipps-recurring.php index ba6760e..c0b4db4 100644 --- a/includes/wc-gateway-vipps-recurring.php +++ b/includes/wc-gateway-vipps-recurring.php @@ -659,7 +659,7 @@ public function complete_order( $order, $transaction_id ) { // controlled by the `transition_renewals_to_completed` setting // only applicable to renewal orders - if ( $this->transition_renewals_to_completed && wcs_order_contains_renewal( $order ) ) { + if ( $this->transition_renewals_to_completed === "yes" && wcs_order_contains_renewal( $order ) ) { $order->update_status( 'wc-completed' ); } @@ -845,7 +845,7 @@ public function cancel_subscription( $subscription ) { return; } - set_transient( 'cancel_subscription_lock' . $subscription_id, uniqid(), 30 ); + set_transient( 'cancel_subscription_lock' . $subscription_id, uniqid( '', true ), 30 ); $agreement_id = WC_Vipps_Recurring_Helper::get_agreement_id_from_order( $subscription ); $agreement = $this->api->get_agreement( $agreement_id ); @@ -956,7 +956,7 @@ public function process_subscription_payment( $amount, $renewal_order ): bool { return true; } - set_transient( 'order_lock_' . $renewal_order_id, uniqid(), 30 ); + set_transient( 'order_lock_' . $renewal_order_id, uniqid( '', true ), 30 ); WC_Vipps_Recurring_Logger::log( sprintf( '[%s] process_subscription_payment attempting to create charge', $renewal_order->get_id() ) ); @@ -1858,7 +1858,7 @@ public function maybe_cancel_due_charge( $order_id ) { return; } - set_transient( 'maybe_cancel_due_charge_lock' . $order_id, uniqid(), 30 ); + set_transient( 'maybe_cancel_due_charge_lock' . $order_id, uniqid( '', true ), 30 ); $charge = $this->api->get_charge( $agreement_id, $charge_id ); if ( in_array( $charge['status'], [ 'DUE', 'PENDING' ] ) ) { diff --git a/woo-vipps-recurring.php b/woo-vipps-recurring.php index ee0a825..5ae1ebd 100644 --- a/woo-vipps-recurring.php +++ b/woo-vipps-recurring.php @@ -5,7 +5,7 @@ * Description: Offer recurring payments with Vipps for WooCommerce Subscriptions * Author: Everyday AS * Author URI: https://everyday.no - * Version: 1.9.0 + * Version: 1.9.1 * Requires at least: 4.4 * Tested up to: 5.8 * WC tested up to: 5.6.0 @@ -17,7 +17,7 @@ // phpcs:disable WordPress.Files.FileName -define( 'WC_VIPPS_RECURRING_VERSION', '1.9.0' ); +define( 'WC_VIPPS_RECURRING_VERSION', '1.9.1' ); add_action( 'plugins_loaded', 'woocommerce_gateway_vipps_recurring_init' ); @@ -680,13 +680,13 @@ public function check_gateway_change_agreement_statuses() { $posts = get_posts( [ 'post_type' => 'shop_subscription', - 'post_status' => 'wc-active', + 'post_status' => [ 'wc-active', 'wc-pending', 'wc-on-hold' ], 'meta_key' => WC_Vipps_Recurring_Helper::META_SUBSCRIPTION_WAITING_FOR_GATEWAY_CHANGE, 'meta_compare' => '=', 'meta_value' => 1, 'return' => 'ids', ] ); - + foreach ( $posts as $post ) { // check charge status $gateway->maybe_process_gateway_change( $post->ID );