Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions includes/abstracts/abstract-wc-stripe-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
13 changes: 7 additions & 6 deletions includes/class-wc-stripe-webhook-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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.
Expand All @@ -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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there's a chance of this check getting longer, but maybe we could update it to use a single variable for the payment methods, like $is_immediate_processing_method.

$immediate_processing_methods    = array_merge( WC_Stripe_Payment_Methods::VOUCHER_PAYMENT_METHODS, WC_Stripe_Payment_Methods::WALLET_PAYMENT_METHODS, [ WC_Stripe_Payment_Methods::BLIK ] );
$is_immediate_processing_method = in_array( $payment_type_meta, immediate_processing_methods, true );

$charge = $this->get_latest_charge_from_intent( $intent );

do_action_deprecated(
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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).
11 changes: 11 additions & 0 deletions tests/phpunit/WC_Stripe_Webhook_Handler_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading