diff --git a/Readme.txt b/Readme.txt index 6dd6da73..9b8fab15 100755 --- a/Readme.txt +++ b/Readme.txt @@ -18,6 +18,7 @@ The Reepay plugin extends WooCommerce allowing you to take payments on your stor See installation guide right here: https://intercom.help/reepay/reepay-plugins/woocommerce-plugin == Changelog == +v 1.4.31 - WC subscription fixing v 1.4.30 - Fix capture v 1.4.29 - Mobile conditions subscriptions, allow any webhooks, subscriptions recurring v 1.4.28 - Settle fee on complete diff --git a/includes/abstracts/abstract-wc-gateway-reepay.php b/includes/abstracts/abstract-wc-gateway-reepay.php index b731e791..cbe0cf56 100644 --- a/includes/abstracts/abstract-wc-gateway-reepay.php +++ b/includes/abstracts/abstract-wc-gateway-reepay.php @@ -582,7 +582,7 @@ public function process_payment($order_id) ); } - if (wcs_cart_only_subscriptions()) { + if (wc_cart_only_reepay_subscriptions()) { $method = $this->api->request('GET', 'https://api.reepay.com/v1/payment_method/' . $token->get_token()); if (!empty($method) && $method['state'] == 'active') { @@ -628,9 +628,11 @@ public function process_payment($order_id) $customer_handle = $this->api->get_customer_handle_order($order->get_id()); // If here's Subscription or zero payment - if (abs($order->get_total()) < 0.01 || wcs_cart_only_subscriptions()) { + if (abs($order->get_total()) < 0.01 || wc_cart_only_reepay_subscriptions()) { + var_dump(wc_cart_only_reepay_subscriptions()); + exit; $params = [ - 'locale' > $this->get_language(), + 'locale' => $this->get_language(), 'button_text' => __('Pay', 'woocommerce-gateway-reepay-checkout'), 'create_customer' => [ 'test' => $this->test_mode === 'yes', diff --git a/includes/class-wc-reepay-order-statuses.php b/includes/class-wc-reepay-order-statuses.php index c350a406..cdbab743 100755 --- a/includes/class-wc-reepay-order-statuses.php +++ b/includes/class-wc-reepay-order-statuses.php @@ -389,7 +389,9 @@ public static function set_pending_status(WC_Order $order, $note, $transaction_i */ public static function set_authorized_status(WC_Order $order, $note, $transaction_id) { - if ('1' === $order->get_meta('_reepay_state_authorized')) { + $authorized_status = apply_filters('reepay_authorized_order_status', 'on-hold', $order); + + if (!empty($order->get_meta('_reepay_state_authorized')) || $order->get_status() == $authorized_status) { return; } @@ -401,7 +403,7 @@ public static function set_authorized_status(WC_Order $order, $note, $transactio self::update_order_status( $order, - apply_filters('reepay_authorized_order_status', 'on-hold', $order), + $authorized_status, $note, $transaction_id ); diff --git a/includes/functions.php b/includes/functions.php index ecffda8f..b6494cdb 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -94,10 +94,12 @@ function wcs_cart_have_subscription() { if (class_exists('WC_Subscriptions_Product')) { // Check is Recurring Payment - $cart = WC()->cart->get_cart(); - foreach ($cart as $key => $item) { - if (is_object($item['data']) && WC_Subscriptions_Product::is_subscription($item['data'])) { - return true; + if (!is_null(WC()->cart)) { + $cart = WC()->cart->get_cart(); + foreach ($cart as $key => $item) { + if (is_object($item['data']) && WC_Subscriptions_Product::is_subscription($item['data'])) { + return true; + } } } } @@ -136,6 +138,18 @@ function wcs_cart_only_subscriptions() } } +if (!function_exists('wc_cart_only_reepay_subscriptions')) { + /** + * Check is Cart have only Subscription Products. + * + * @return bool + */ + function wc_cart_only_reepay_subscriptions() + { + return apply_filters('wcs_cart_only_subscriptions', false); + } +} + if (!function_exists('rp_prepare_amount')) { /** * Prepare amount. diff --git a/reepay-woocommerce-payment.php b/reepay-woocommerce-payment.php index cfb663a7..6e4edc2a 100755 --- a/reepay-woocommerce-payment.php +++ b/reepay-woocommerce-payment.php @@ -1,10 +1,10 @@ '' . esc_html__('Get free test account', 'reepay-checkout-gateway') . '', + 'pricing' => '' . esc_html__('Pricing', 'reepay-checkout-gateway') . '', + ); + + + return array_merge($links, $row_meta); + } + /** * Install */