-
Notifications
You must be signed in to change notification settings - Fork 72
Log exceptions during the payment process #11187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Log exceptions during the payment process #11187
Conversation
Migrates 8 shopper test specs to QIT: My Account: - My account payment methods add failures - My account saved cards management Multicurrency & Pay for Order: - Multi-currency checkout - Multi-currency widget - Pay for order flow Alternative Payment Methods: - Alipay checkout purchase - Klarna checkout purchase - BNPLs (Buy Now Pay Later) checkout Tests cover shopper flows for account management, currency switching, and alternative payment methods.
- Alipay: Disable multi-currency before tests (like Klarna does) - Alipay: Use URL check for redirect instead of page text - Pay for order: Handle both 'card was declined' and 'payment was not processed' errors
Alipay payments require specific Stripe account configuration that is not available in the QIT test environment. The payment method can be enabled in settings but checkout fails with 'Invalid or missing payment details'.
The QIT devtools implementation uses WP-CLI to set options directly, but the card testing protection feature relies on filters/hooks from the Dev Tools plugin (option_wcpay_account_data, woocommerce_payments_account_refreshed) that aren't available in the QIT environment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| Logger::exception( 'Error occurred during the payment process.', $e ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern here is that it could create a humongous log file for high-volume merchants, as it will be logging any failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this specific point, I was wondering if we don't go ahead with logging full exception maybe we could extract the message and add to logs or order notes - that alone sometimes help crack the case. Eg SQUARE-167
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added exception message in b7da429
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds structured exception logging during payment processing by introducing a new Logger::exception() method that captures exception details (class, message, code, and trace) in a unified format, and applies it to two critical payment flows.
- Added
Logger::exception()method to log exceptions with structured context - Integrated exception logging into
process_payment()andprocess_redirect_payment()methods - Replaced basic string logging with comprehensive exception logging in redirect payment flow
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| includes/class-logger.php | Introduces new exception() static method for structured exception logging with trace information |
| includes/class-wc-payment-gateway-wcpay.php | Adds exception logging to payment processing catch blocks for better debugging |
| changelog/woopmnt-5541-add-notes-or-logging-for-failed-orders | Documents the feature addition in changelog |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
|
Size Change: 0 B Total Size: 927 kB ℹ️ View Unchanged
|
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Fixes WOOPMNT-5541
Changes proposed in this Pull Request
Logger::exceptionmethod to log exceptions in a unified way.Testing instructions
WooCommerce > Status > Logs > woopayments. The exception should be logged there.Screen.Recording.2025-12-05.at.13.54.56.mov
npm run changelogto add a changelog file, choosepatchto leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge