diff --git a/Readme.txt b/Readme.txt index 8c6c858d..a4cc2697 100755 --- a/Readme.txt +++ b/Readme.txt @@ -18,6 +18,7 @@ The Billwerk+ Payments plugin extends WooCommerce allowing you to take payments See installation guide right here: https://docu.billwerk.plus/help/en/apps/woocommerce/setup-woocommerce-plugin.html == Changelog == +v 1.6.3 - Woocommerce zero payment fixes v 1.6.2 - Fix user handle generate v 1.6.1 - Card saving fixes, user creation fixes v 1.6.0 - Lots of updates and fixes diff --git a/includes/Actions/Checkout.php b/includes/Actions/Checkout.php index 2d0b03ff..0e78c251 100644 --- a/includes/Actions/Checkout.php +++ b/includes/Actions/Checkout.php @@ -21,24 +21,6 @@ class Checkout { */ public function __construct() { add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'action_checkout_create_order_line_item' ), 10, 4 ); - add_filter( 'woocommerce_cart_needs_payment', array( $this, 'check_need_payment' ), 10 ); - } - - /** - * Count line item discount - * - * @param bool $need_payment need payment marker. - * - * @see WC_Cart::needs_payment - * - * @return bool - */ - public function check_need_payment( bool $need_payment ): bool { - if ( wcs_cart_have_subscription() ) { - return true; - } - - return $need_payment; } /** diff --git a/includes/Gateways/ReepayGateway.php b/includes/Gateways/ReepayGateway.php index 8541fe8b..57b467d9 100644 --- a/includes/Gateways/ReepayGateway.php +++ b/includes/Gateways/ReepayGateway.php @@ -1013,7 +1013,7 @@ public function process_payment( $order_id ) { ); } - $have_sub = class_exists( WC_Reepay_Renewals::class ) && WC_Reepay_Renewals::is_order_contain_subscription( $order ); + $have_sub = (class_exists( WC_Reepay_Renewals::class ) && WC_Reepay_Renewals::is_order_contain_subscription( $order )) || wcs_cart_have_subscription(); $only_items_lines = array(); @@ -1216,18 +1216,24 @@ public function process_session_charge( array $params, WC_Order $order ): array $params ); if ( is_wp_error( $result ) ) { + wc_add_notice( $result->get_error_message(), 'error' ); + return array( 'result' => 'failure', 'message' => $result->get_error_message(), ); } } else { + wc_add_notice( $result->get_error_message(), 'error' ); + return array( 'result' => 'failure', 'message' => $result->get_error_message(), ); } } else { + wc_add_notice( $result->get_error_message(), 'error' ); + return array( 'result' => 'failure', 'message' => $result->get_error_message(), diff --git a/includes/OrderFlow/Webhook.php b/includes/OrderFlow/Webhook.php index 9e9b5372..98b10d86 100644 --- a/includes/OrderFlow/Webhook.php +++ b/includes/OrderFlow/Webhook.php @@ -9,6 +9,7 @@ use Exception; use Reepay\Checkout\LoggingTrait; +use Reepay\Checkout\Tokens\ReepayTokens; use WC_Order_Item_Fee; use WC_Subscriptions_Manager; use WP_Error; @@ -436,6 +437,20 @@ public function process( array $data ) { $order = rp_get_order_by_session( $data['payment_method_reference'] ); if ( $order && order_contains_subscription( $order ) ) { WC_Subscriptions_Manager::activate_subscriptions_for_order( $order ); + + if(! empty( $data['payment_method'] )){ + try { + $token = ReepayTokens::reepay_save_token( $order, $data['payment_method'] ); + ReepayTokens::assign_payment_token( $order, $token ); + ReepayTokens::save_card_info_to_order( $order, $token->get_token() ); + + $order->payment_complete(); + } catch ( Exception $e ) { + $order->add_order_note( $e->getMessage() ); + $this->log( sprintf( 'WebHook: Token save error: %s', $e->getMessage() ) ); + return; + } + } } } diff --git a/includes/Tokens/ReepayTokens.php b/includes/Tokens/ReepayTokens.php index d40375fd..b1ae0bc6 100644 --- a/includes/Tokens/ReepayTokens.php +++ b/includes/Tokens/ReepayTokens.php @@ -224,7 +224,7 @@ public static function get_payment_token_subscription( WC_Subscription $subscrip $token = $order->get_meta( '_reepay_token' ); if ( empty( $token ) ) { $invoice_data = reepay()->api( $order )->get_invoice_data( $order ); - if ( ! empty( $invoice_data ) ) { + if ( ! empty( $invoice_data ) && ! is_wp_error( $invoice_data ) ) { if ( ! empty( $invoice_data['recurring_payment_method'] ) ) { $token = $invoice_data['recurring_payment_method']; } elseif ( ! empty( $invoice_data['transactions'] ) ) { diff --git a/reepay-woocommerce-payment.php b/reepay-woocommerce-payment.php index c94248a4..6530a818 100755 --- a/reepay-woocommerce-payment.php +++ b/reepay-woocommerce-payment.php @@ -4,7 +4,7 @@ * Description: Get a plug-n-play payment solution for WooCommerce, that is easy to use, highly secure and is built to maximize the potential of your e-commerce. * Author: Billwerk+ * Author URI: http://billwerk.plus - * Version: 1.6.2 + * Version: 1.6.3 * Text Domain: reepay-checkout-gateway * Domain Path: /languages * WC requires at least: 3.0.0 diff --git a/templates/meta-boxes/invoice.php b/templates/meta-boxes/invoice.php index 78114040..d2de0fc7 100644 --- a/templates/meta-boxes/invoice.php +++ b/templates/meta-boxes/invoice.php @@ -70,7 +70,7 @@ class="reepay-admin-card-logo"/> - + get_currency()) : $order_data['authorized_amount'] . ' ' . get_woocommerce_currency_symbol($order->get_currency()); ?>