diff --git a/changelog.txt b/changelog.txt index 962d6ec990..13acc9a592 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ * Dev - Removes deprecated promotional banners (related to legacy checkout) * Fix - Error when using Puerto Rico addresses with express checkouts * Tweak - Improve error messages when Stripe API requests fail to better distinguish between request and retrieval errors +* Tweak - Changes BLIK confirmation webhook processing from deferred to immediate = 10.2.0 - 2025-12-08 = * Dev - Refactor display logic for payment method issue pills diff --git a/includes/abstracts/abstract-wc-stripe-payment-gateway.php b/includes/abstracts/abstract-wc-stripe-payment-gateway.php index a5cd9057a0..f2dadcc202 100644 --- a/includes/abstracts/abstract-wc-stripe-payment-gateway.php +++ b/includes/abstracts/abstract-wc-stripe-payment-gateway.php @@ -565,11 +565,17 @@ public function generate_payment_request( $order, $prepared_payment_method ) { * @throws WC_Stripe_Exception */ public function process_response( $response, $order ) { - WC_Stripe_Logger::log( 'Processing response: ' . print_r( $response, true ) ); + WC_Stripe_Logger::debug( + 'Processing charge response', + [ + 'response' => $response, + 'order' => $order, + ] + ); $potential_order = WC_Stripe_Helper::get_order_by_charge_id( $response->id ); if ( $potential_order && $potential_order->get_id() !== $order->get_id() ) { - WC_Stripe_Logger::log( 'Aborting, transaction already consumed by another order.' ); + WC_Stripe_Logger::error( 'Aborting, transaction already consumed by another order.' ); $localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' ); throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); } diff --git a/includes/class-wc-stripe-webhook-handler.php b/includes/class-wc-stripe-webhook-handler.php index fdcdce0a26..b5be461103 100644 --- a/includes/class-wc-stripe-webhook-handler.php +++ b/includes/class-wc-stripe-webhook-handler.php @@ -563,7 +563,7 @@ public function process_webhook_capture( $notification ) { */ public function process_webhook_charge_succeeded( $notification ) { if ( empty( $notification->data->object ) ) { - WC_Stripe_Logger::log( 'Missing charge object in charge.succeeded webhook, Event ID: %s', $notification->id ?? 'unknown' ); + WC_Stripe_Logger::error( 'Missing charge object in charge.succeeded webhook, Event ID: %s', $notification->id ?? 'unknown' ); return; } @@ -585,7 +585,7 @@ public function process_webhook_charge_succeeded( $notification ) { $order = WC_Stripe_Helper::get_order_by_charge_id( $charge->id ); if ( ! $order ) { - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $charge->id ); + WC_Stripe_Logger::debug( 'Could not find order via charge ID: ' . $charge->id ); return; } @@ -1107,6 +1107,7 @@ public function process_payment_intent( $notification ) { $payment_type_meta = $order_helper->get_stripe_upe_payment_type( $order ); $is_voucher_payment = in_array( $payment_type_meta, WC_Stripe_Payment_Methods::VOUCHER_PAYMENT_METHODS, true ); $is_wallet_payment = in_array( $payment_type_meta, WC_Stripe_Payment_Methods::WALLET_PAYMENT_METHODS, true ); + $is_blik_payment = WC_Stripe_Payment_Methods::BLIK === $payment_type_meta; switch ( $notification->type ) { // Asynchronous payment methods such as bank debits will only provide a charge ID at `payment_intent.processing`, once the required actions are taken by the customer. @@ -1129,13 +1130,13 @@ public function process_payment_intent( $notification ) { break; case 'payment_intent.succeeded': case 'payment_intent.amount_capturable_updated': - WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id succeeded for order $order_id" ); + WC_Stripe_Logger::debug( "Stripe PaymentIntent $intent->id succeeded for order $order_id" ); $process_webhook_async = apply_filters( 'wc_stripe_process_payment_intent_webhook_async', true, $order, $intent, $notification ); $is_awaiting_action = $order_helper->get_stripe_upe_waiting_for_redirect( $order ) ?? false; - // Process the webhook now if it's for a voucher or wallet payment, or if filtered to process immediately and order is not awaiting action. - if ( $is_voucher_payment || $is_wallet_payment || ( ! $process_webhook_async && ! $is_awaiting_action ) ) { + // Process the webhook now if it's for a voucher, wallet, or BLIK payment, or if filtered to process immediately and order is not awaiting action. + if ( $is_voucher_payment || $is_wallet_payment || $is_blik_payment || ( ! $process_webhook_async && ! $is_awaiting_action ) ) { $charge = $this->get_latest_charge_from_intent( $intent ); do_action_deprecated( @@ -1151,7 +1152,7 @@ public function process_payment_intent( $notification ) { $this->run_webhook_received_action( (string) $notification->type, $notification ); } else { - WC_Stripe_Logger::log( "Processing $notification->type ($intent->id) asynchronously for order $order_id." ); + WC_Stripe_Logger::debug( "Processing $notification->type ($intent->id) asynchronously for order $order_id." ); // Schedule a job to check on the status of this intent. $this->defer_webhook_processing( diff --git a/readme.txt b/readme.txt index acea33fa54..a5b31bfc36 100644 --- a/readme.txt +++ b/readme.txt @@ -146,5 +146,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Dev - Removes all references to the UPE-enabled feature flag * Dev - Removes deprecated promotional banners (related to legacy checkout) * Tweak - Improve error messages when Stripe API requests fail to better distinguish between request and retrieval errors +* Tweak - Changes BLIK confirmation webhook processing from deferred to immediate [See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt). diff --git a/tests/phpunit/WC_Stripe_Webhook_Handler_Test.php b/tests/phpunit/WC_Stripe_Webhook_Handler_Test.php index 39d09573c6..cefdcec874 100644 --- a/tests/phpunit/WC_Stripe_Webhook_Handler_Test.php +++ b/tests/phpunit/WC_Stripe_Webhook_Handler_Test.php @@ -678,6 +678,17 @@ public function provide_test_process_payment_intent() { 'expected process payment calls' => 1, 'expected process payment intent incomplete calls' => 0, ], + 'success, payment_intent.succeeded, BLIK payment' => [ + 'event type' => 'payment_intent.succeeded', + 'order status' => OrderStatus::PENDING, + 'order locked' => false, + 'payment type' => WC_Stripe_Payment_Methods::BLIK, + 'order status final' => false, + 'expected status' => OrderStatus::PROCESSING, + 'expected note' => '', + 'expected process payment calls' => 1, + 'expected process payment intent incomplete calls' => 0, + ], 'success, payment_intent.amount_capturable_updated, async payment, awaiting action' => [ 'event type' => 'payment_intent.amount_capturable_updated', 'order status' => OrderStatus::PENDING,