Changeset 3250888
- Timestamp:
- 03/05/2025 07:41:17 AM (12 months ago)
- Location:
- woocommerce-quickpay
- Files:
-
- 16 edited
- 1 copied
-
tags/7.4.0 (copied) (copied from woocommerce-quickpay/trunk)
-
tags/7.4.0/README.txt (modified) (1 diff)
-
tags/7.4.0/classes/utils/woocommerce-quickpay-order-payments-utils.php (modified) (1 diff)
-
tags/7.4.0/classes/utils/woocommerce-quickpay-order-transaction-data-utils.php (modified) (1 diff)
-
tags/7.4.0/classes/utils/woocommerce-quickpay-order-utils.php (modified) (1 diff)
-
tags/7.4.0/classes/woocommerce-quickpay-callbacks.php (modified) (2 diffs)
-
tags/7.4.0/classes/woocommerce-quickpay-subscription.php (modified) (2 diffs)
-
tags/7.4.0/helpers/transactions.php (modified) (1 diff)
-
tags/7.4.0/woocommerce-quickpay.php (modified) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/classes/utils/woocommerce-quickpay-order-payments-utils.php (modified) (1 diff)
-
trunk/classes/utils/woocommerce-quickpay-order-transaction-data-utils.php (modified) (1 diff)
-
trunk/classes/utils/woocommerce-quickpay-order-utils.php (modified) (1 diff)
-
trunk/classes/woocommerce-quickpay-callbacks.php (modified) (2 diffs)
-
trunk/classes/woocommerce-quickpay-subscription.php (modified) (2 diffs)
-
trunk/helpers/transactions.php (modified) (1 diff)
-
trunk/woocommerce-quickpay.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-quickpay/tags/7.4.0/README.txt
r3239254 r3250888 28 28 29 29 == Changelog == 30 = 7.4.0 = 31 * Fix: Subscription switching was not always creating a subscription payment when upgrading from a free subscription to a paid variant where no previous payments have been made. 32 30 33 = 7.3.5 = 31 34 * Fix: woocommerce_quickpay_get_order now makes a specific check on WC_Order instance to avoid possible direct property access on a WC_Order object. -
woocommerce-quickpay/tags/7.4.0/classes/utils/woocommerce-quickpay-order-payments-utils.php
r2924617 r3250888 154 154 if ( WC_QuickPay_Subscription::is_subscription( $order_id ) ) { 155 155 $order_number = $order_id; 156 } // On initial subscription authorizations 157 else if ( ! $recurring && ! WC_QuickPay_Order_Utils::contains_switch_order( $order ) && WC_QuickPay_Order_Utils::contains_subscription( $order ) ) { 156 } 157 // On initial subscription authorizations 158 // 1. Either on parent orders 159 // 2. Or if the customer tries to upgrade a free subscription to a not-free variation. 160 else if ( ( ! $recurring || WC_QuickPay_Order_Utils::switches_from_free_to_paid( $order ) ) && WC_QuickPay_Order_Utils::contains_subscription( $order ) ) { 158 161 // Find all subscriptions 159 162 $subscriptions = WC_QuickPay_Subscription::get_subscriptions_for_order( $order_id ); -
woocommerce-quickpay/tags/7.4.0/classes/utils/woocommerce-quickpay-order-transaction-data-utils.php
r2924617 r3250888 131 131 132 132 // Get the correct order_post_id. We want to fetch the ID of the subscription to store data on subscription (if available). 133 // But only on the first attempt. In case of failed auto capture on the initial order, we dont want to add the subscription ID. 134 // If we are handlong a product switch, we will not need this ID as we are making a regular payment. 135 if ( ! WC_QuickPay_Order_Utils::contains_switch_order( $order ) ) { 136 $subscription_id = WC_QuickPay_Subscription::get_subscription_id( $order ); 137 if ( $subscription_id ) { 138 $custom_vars['subscription_post_id'] = $subscription_id; 139 } 133 if ( $subscription_id = WC_QuickPay_Subscription::get_subscription_id( $order ) ) { 134 $custom_vars['subscription_post_id'] = $subscription_id; 140 135 } 141 136 -
woocommerce-quickpay/tags/7.4.0/classes/utils/woocommerce-quickpay-order-utils.php
r2924617 r3250888 57 57 } 58 58 59 /** 60 * Checks if the order switches a subscription from free to paid. 61 * In this case we would often require authorization of a subscription transaction in order to 62 * be able to authorize payments automatically in the future. 63 * 64 * @param $order 65 * 66 * @return bool 67 */ 68 public static function switches_from_free_to_paid( $order ): bool { 69 if ( ! self::contains_switch_order( $order ) ) { 70 return false; 71 } 72 73 if ( ! ( $subscription_id = $order->get_meta( '_subscription_switch' ) ) || ! ( $subscription = woocommerce_quickpay_get_subscription( $subscription_id ) ) ) { 74 return false; 75 } 76 77 // Make sure to cast the return value as WC returns the total as a string regardless of context. 78 $old_total = (float) $subscription->get_total(); 79 $new_total = (float) $order->get_total(); 80 81 return $old_total === 0.0 && $new_total > 0; 82 } 83 84 /** 85 * @param WC_Order $order 86 * @param string|null $message 87 * 88 * @return void 89 */ 59 90 public static function add_note( WC_Order $order, ?string $message ): void { 60 91 if ( $message ) { -
woocommerce-quickpay/tags/7.4.0/classes/woocommerce-quickpay-callbacks.php
r3239254 r3250888 123 123 // Only make an instant payment if the order total is more than 0 124 124 if ( $related_order->get_total() > 0 ) { 125 // Check if this is an order containing a subscription or if it is a renewal order 126 if ( ! WC_QuickPay_Subscription::is_subscription( $related_order ) && ( WC_QuickPay_Order_Utils::contains_subscription( $related_order ) || WC_QuickPay_Subscription::is_renewal( $related_order ) ) ) { 127 // Process a recurring payment, but only if the subscription needs a payment. 128 // This check was introduced to avoid possible double payments in case Quickpay sends callbacks more than once. 129 if ( ( $wcs_subscription = wcs_get_subscription( $subscription->get_id() ) ) && $wcs_subscription->needs_payment() ) { 125 // Determine if the order is a subscription or renewal order 126 $is_subscription = WC_QuickPay_Subscription::is_subscription( $related_order ); 127 $contains_subscription = WC_QuickPay_Order_Utils::contains_subscription( $related_order ); 128 $is_renewal = WC_QuickPay_Subscription::is_renewal( $related_order ); 129 130 if ( ! $is_subscription && ( $contains_subscription || $is_renewal ) ) { 131 // Retrieve the subscription and check if a payment is needed 132 $wcs_subscription = wcs_get_subscription( $subscription->get_id() ); 133 // Checks if the subscription needs a payment. Also checks specifically on the related order as switch orders will not flag a subscription as needing a payment 134 $needs_payment = $wcs_subscription && ( $wcs_subscription->needs_payment() || $related_order->needs_payment() ); 135 136 if ( $needs_payment ) { 130 137 WC_QP()->process_recurring_payment( new WC_QuickPay_API_Subscription(), $transaction->id, $related_order->get_total(), $related_order ); 131 138 } … … 134 141 // If there is no initial payment, we will mark the order as complete. 135 142 // This is usually happening if a subscription has a free trial. 136 else { 137 // Only complete the order payment if we are not changing payment method. 138 // This is to avoid the subscription going into a 'processing' limbo. 139 if ( empty( $transaction->variables->change_payment ) ) { 140 $related_order->payment_complete(); 141 } 143 else if ( empty( $transaction->variables->change_payment ) ) { 144 $related_order->payment_complete(); 142 145 } 143 146 -
woocommerce-quickpay/tags/7.4.0/classes/woocommerce-quickpay-subscription.php
r2924617 r3250888 113 113 114 114 /** 115 * @param $order 116 * @param array $args 117 * 118 * @return WC_Subscription|null 119 */ 120 public static function get_last_subscription_for_order( $order, array $args = [] ): ?WC_Subscription { 121 $subscriptions = self::get_subscriptions_for_order( $order, $args ); 122 123 if ( ! empty( $subscriptions ) ) { 124 return end( $subscriptions ); 125 } 126 127 return null; 128 } 129 130 /** 115 131 * @param WC_Order $order 116 132 * … … 135 151 return end( $subscriptions )->get_id(); 136 152 } 153 137 154 return null; 138 155 } -
woocommerce-quickpay/tags/7.4.0/helpers/transactions.php
r3239254 r3250888 16 16 17 17 // If the order is a subscription or an attempt of updating the payment method 18 if ( ! WC_QuickPay_Subscription::cart_contains_switches() && ( WC_QuickPay_Order_Utils::contains_subscription( $order ) || WC_QuickPay_Requests_Utils::is_request_to_change_payment() ) ) { 19 // Instantiate a subscription transaction instead of a payment transaction 20 $api_transaction = new WC_QuickPay_API_Subscription(); 18 if ( WC_QuickPay_Order_Utils::contains_subscription( $order ) || WC_QuickPay_Requests_Utils::is_request_to_change_payment() ) { 19 if ( WC_QuickPay_Subscription::cart_contains_switches() ) { 20 $subscription = WC_QuickPay_Subscription::get_last_subscription_for_order( $order ); 21 $transaction_id = $subscription ? WC_QuickPay_Order_Utils::get_transaction_id( $subscription ) : null; 22 23 if ( ! $transaction_id && $order->needs_payment() ) { 24 // Instantiate a subscription transaction instead of a payment transaction 25 $api_transaction = new WC_QuickPay_API_Subscription(); 26 } 27 } else { 28 // Instantiate a subscription transaction instead of a payment transaction 29 $api_transaction = new WC_QuickPay_API_Subscription(); 30 } 21 31 } 22 32 -
woocommerce-quickpay/tags/7.4.0/woocommerce-quickpay.php
r3239254 r3250888 4 4 * Plugin URI: http://wordpress.org/plugins/woocommerce-quickpay/ 5 5 * Description: Integrates your Quickpay payment gateway into your WooCommerce installation. 6 * Version: 7. 3.56 * Version: 7.4.0 7 7 * Author: Perfect Solution 8 8 * Text Domain: woo-quickpay … … 20 20 } 21 21 22 define( 'WCQP_VERSION', '7. 3.5' );22 define( 'WCQP_VERSION', '7.4.0' ); 23 23 define( 'WCQP_URL', plugins_url( __FILE__ ) ); 24 24 define( 'WCQP_PATH', plugin_dir_path( __FILE__ ) ); -
woocommerce-quickpay/trunk/README.txt
r3239254 r3250888 28 28 29 29 == Changelog == 30 = 7.4.0 = 31 * Fix: Subscription switching was not always creating a subscription payment when upgrading from a free subscription to a paid variant where no previous payments have been made. 32 30 33 = 7.3.5 = 31 34 * Fix: woocommerce_quickpay_get_order now makes a specific check on WC_Order instance to avoid possible direct property access on a WC_Order object. -
woocommerce-quickpay/trunk/classes/utils/woocommerce-quickpay-order-payments-utils.php
r2924617 r3250888 154 154 if ( WC_QuickPay_Subscription::is_subscription( $order_id ) ) { 155 155 $order_number = $order_id; 156 } // On initial subscription authorizations 157 else if ( ! $recurring && ! WC_QuickPay_Order_Utils::contains_switch_order( $order ) && WC_QuickPay_Order_Utils::contains_subscription( $order ) ) { 156 } 157 // On initial subscription authorizations 158 // 1. Either on parent orders 159 // 2. Or if the customer tries to upgrade a free subscription to a not-free variation. 160 else if ( ( ! $recurring || WC_QuickPay_Order_Utils::switches_from_free_to_paid( $order ) ) && WC_QuickPay_Order_Utils::contains_subscription( $order ) ) { 158 161 // Find all subscriptions 159 162 $subscriptions = WC_QuickPay_Subscription::get_subscriptions_for_order( $order_id ); -
woocommerce-quickpay/trunk/classes/utils/woocommerce-quickpay-order-transaction-data-utils.php
r2924617 r3250888 131 131 132 132 // Get the correct order_post_id. We want to fetch the ID of the subscription to store data on subscription (if available). 133 // But only on the first attempt. In case of failed auto capture on the initial order, we dont want to add the subscription ID. 134 // If we are handlong a product switch, we will not need this ID as we are making a regular payment. 135 if ( ! WC_QuickPay_Order_Utils::contains_switch_order( $order ) ) { 136 $subscription_id = WC_QuickPay_Subscription::get_subscription_id( $order ); 137 if ( $subscription_id ) { 138 $custom_vars['subscription_post_id'] = $subscription_id; 139 } 133 if ( $subscription_id = WC_QuickPay_Subscription::get_subscription_id( $order ) ) { 134 $custom_vars['subscription_post_id'] = $subscription_id; 140 135 } 141 136 -
woocommerce-quickpay/trunk/classes/utils/woocommerce-quickpay-order-utils.php
r2924617 r3250888 57 57 } 58 58 59 /** 60 * Checks if the order switches a subscription from free to paid. 61 * In this case we would often require authorization of a subscription transaction in order to 62 * be able to authorize payments automatically in the future. 63 * 64 * @param $order 65 * 66 * @return bool 67 */ 68 public static function switches_from_free_to_paid( $order ): bool { 69 if ( ! self::contains_switch_order( $order ) ) { 70 return false; 71 } 72 73 if ( ! ( $subscription_id = $order->get_meta( '_subscription_switch' ) ) || ! ( $subscription = woocommerce_quickpay_get_subscription( $subscription_id ) ) ) { 74 return false; 75 } 76 77 // Make sure to cast the return value as WC returns the total as a string regardless of context. 78 $old_total = (float) $subscription->get_total(); 79 $new_total = (float) $order->get_total(); 80 81 return $old_total === 0.0 && $new_total > 0; 82 } 83 84 /** 85 * @param WC_Order $order 86 * @param string|null $message 87 * 88 * @return void 89 */ 59 90 public static function add_note( WC_Order $order, ?string $message ): void { 60 91 if ( $message ) { -
woocommerce-quickpay/trunk/classes/woocommerce-quickpay-callbacks.php
r3239254 r3250888 123 123 // Only make an instant payment if the order total is more than 0 124 124 if ( $related_order->get_total() > 0 ) { 125 // Check if this is an order containing a subscription or if it is a renewal order 126 if ( ! WC_QuickPay_Subscription::is_subscription( $related_order ) && ( WC_QuickPay_Order_Utils::contains_subscription( $related_order ) || WC_QuickPay_Subscription::is_renewal( $related_order ) ) ) { 127 // Process a recurring payment, but only if the subscription needs a payment. 128 // This check was introduced to avoid possible double payments in case Quickpay sends callbacks more than once. 129 if ( ( $wcs_subscription = wcs_get_subscription( $subscription->get_id() ) ) && $wcs_subscription->needs_payment() ) { 125 // Determine if the order is a subscription or renewal order 126 $is_subscription = WC_QuickPay_Subscription::is_subscription( $related_order ); 127 $contains_subscription = WC_QuickPay_Order_Utils::contains_subscription( $related_order ); 128 $is_renewal = WC_QuickPay_Subscription::is_renewal( $related_order ); 129 130 if ( ! $is_subscription && ( $contains_subscription || $is_renewal ) ) { 131 // Retrieve the subscription and check if a payment is needed 132 $wcs_subscription = wcs_get_subscription( $subscription->get_id() ); 133 // Checks if the subscription needs a payment. Also checks specifically on the related order as switch orders will not flag a subscription as needing a payment 134 $needs_payment = $wcs_subscription && ( $wcs_subscription->needs_payment() || $related_order->needs_payment() ); 135 136 if ( $needs_payment ) { 130 137 WC_QP()->process_recurring_payment( new WC_QuickPay_API_Subscription(), $transaction->id, $related_order->get_total(), $related_order ); 131 138 } … … 134 141 // If there is no initial payment, we will mark the order as complete. 135 142 // This is usually happening if a subscription has a free trial. 136 else { 137 // Only complete the order payment if we are not changing payment method. 138 // This is to avoid the subscription going into a 'processing' limbo. 139 if ( empty( $transaction->variables->change_payment ) ) { 140 $related_order->payment_complete(); 141 } 143 else if ( empty( $transaction->variables->change_payment ) ) { 144 $related_order->payment_complete(); 142 145 } 143 146 -
woocommerce-quickpay/trunk/classes/woocommerce-quickpay-subscription.php
r2924617 r3250888 113 113 114 114 /** 115 * @param $order 116 * @param array $args 117 * 118 * @return WC_Subscription|null 119 */ 120 public static function get_last_subscription_for_order( $order, array $args = [] ): ?WC_Subscription { 121 $subscriptions = self::get_subscriptions_for_order( $order, $args ); 122 123 if ( ! empty( $subscriptions ) ) { 124 return end( $subscriptions ); 125 } 126 127 return null; 128 } 129 130 /** 115 131 * @param WC_Order $order 116 132 * … … 135 151 return end( $subscriptions )->get_id(); 136 152 } 153 137 154 return null; 138 155 } -
woocommerce-quickpay/trunk/helpers/transactions.php
r3239254 r3250888 16 16 17 17 // If the order is a subscription or an attempt of updating the payment method 18 if ( ! WC_QuickPay_Subscription::cart_contains_switches() && ( WC_QuickPay_Order_Utils::contains_subscription( $order ) || WC_QuickPay_Requests_Utils::is_request_to_change_payment() ) ) { 19 // Instantiate a subscription transaction instead of a payment transaction 20 $api_transaction = new WC_QuickPay_API_Subscription(); 18 if ( WC_QuickPay_Order_Utils::contains_subscription( $order ) || WC_QuickPay_Requests_Utils::is_request_to_change_payment() ) { 19 if ( WC_QuickPay_Subscription::cart_contains_switches() ) { 20 $subscription = WC_QuickPay_Subscription::get_last_subscription_for_order( $order ); 21 $transaction_id = $subscription ? WC_QuickPay_Order_Utils::get_transaction_id( $subscription ) : null; 22 23 if ( ! $transaction_id && $order->needs_payment() ) { 24 // Instantiate a subscription transaction instead of a payment transaction 25 $api_transaction = new WC_QuickPay_API_Subscription(); 26 } 27 } else { 28 // Instantiate a subscription transaction instead of a payment transaction 29 $api_transaction = new WC_QuickPay_API_Subscription(); 30 } 21 31 } 22 32 -
woocommerce-quickpay/trunk/woocommerce-quickpay.php
r3239254 r3250888 4 4 * Plugin URI: http://wordpress.org/plugins/woocommerce-quickpay/ 5 5 * Description: Integrates your Quickpay payment gateway into your WooCommerce installation. 6 * Version: 7. 3.56 * Version: 7.4.0 7 7 * Author: Perfect Solution 8 8 * Text Domain: woo-quickpay … … 20 20 } 21 21 22 define( 'WCQP_VERSION', '7. 3.5' );22 define( 'WCQP_VERSION', '7.4.0' ); 23 23 define( 'WCQP_URL', plugins_url( __FILE__ ) ); 24 24 define( 'WCQP_PATH', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.