Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5940c8a
[E2E][QIT] Migrate remaining shopper specs
mgascam Dec 3, 2025
8832b55
Add changelog entry
mgascam Dec 3, 2025
774085a
Fix Alipay and pay-for-order test failures
mgascam Dec 3, 2025
7977468
Skip Alipay tests due to QIT environment limitation
mgascam Dec 3, 2025
61d20ed
Skip cardTestingPreventionEnabled: true case in pay-for-order test
mgascam Dec 3, 2025
1de9aa1
Merge branch 'develop' into dev/qit-e2e-shopper-remaining-specs
mgascam Dec 3, 2025
698a093
Remove unused emptyCart import
mgascam Dec 3, 2025
9da894f
Add exception logging during the payment process
dmvrtx Dec 5, 2025
877df7b
Changelog entry
dmvrtx Dec 5, 2025
d200dce
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 5, 2025
2f11fc8
Update includes/class-logger.php
dmvrtx Dec 5, 2025
405c76b
Update includes/class-wc-payment-gateway-wcpay.php
dmvrtx Dec 5, 2025
57f1ceb
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 5, 2025
5df3a56
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 9, 2025
6f4ee67
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 9, 2025
b7da429
Show exception message in the logged message.
dmvrtx Dec 10, 2025
58f1c67
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 10, 2025
3694fe7
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 11, 2025
88174f2
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 11, 2025
d4be141
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 12, 2025
22815ea
Merge branch 'develop' into woopmnt-5541-add-notes-or-logging-for-fai…
dmvrtx Dec 12, 2025
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
4 changes: 4 additions & 0 deletions changelog/woopmnt-5541-add-notes-or-logging-for-failed-orders
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Log exceptions during the payment process.
27 changes: 25 additions & 2 deletions includes/class-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace WCPay;

use Throwable;
use WCPay\Internal\Logger as InternalLogger;

defined( 'ABSPATH' ) || exit; // block direct access.
Expand Down Expand Up @@ -82,13 +83,35 @@ public static function critical( $message, $context = [] ) {
/**
* Creates a log entry of type error
*
* @param string $message To send to the log file.
* @param array<string, mixed> $context Context data.
* @param string $message to send to the log file.
* @param array<string, mixed> $context context data.
*/
public static function error( $message, $context = [] ) {
self::log( $message, 'error', $context );
}

/**
* Creates a log entry for exception
*
* @param string $message message to prepend to an exception.
* @param Throwable $e exception to log.
* @param array<string, mixed> $context context data.
*/
public static function exception( $message, $e, $context = [] ) {
self::error(
$message,
array_merge(
[
'exception' => get_class( $e ),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'trace' => $e->getTraceAsString(),
],
$context
)
);
}

/**
* Creates a log entry of type warning
*
Expand Down
5 changes: 4 additions & 1 deletion includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,9 @@ public function process_payment( $order_id ) {
$payment_information = $this->prepare_payment_information( $order );
return $this->process_payment_for_order( WC()->cart, $payment_information );
} catch ( Exception $e ) {
// Log the exception.
Logger::exception( 'Error occurred during the payment process.', $e );

// We set this variable to be used in following checks.
$blocked_by_fraud_rules = $this->is_blocked_by_fraud_rules( $e );

Expand Down Expand Up @@ -2045,7 +2048,7 @@ public function process_redirect_payment( $order, $intent_id, $save_payment_meth
}
}
} catch ( Exception $e ) {
Logger::log( 'Error: ' . $e->getMessage() );
Logger::exception( 'Error occured during the redirect payment process.', $e );

$is_order_id_mismatched_exception =
$e instanceof Process_Payment_Exception
Expand Down
Loading