Skip to content

Conversation

@daledupreez
Copy link
Contributor

@daledupreez daledupreez commented Nov 6, 2025

Fixes STRIPE-795

Changes proposed in this Pull Request:

This PR refactors some of our error logging in WC_Stripe_API into a single log_error_response() function and adds more logging when we encounter a specific situation where the URL we are trying to call fails validation. This specific case was seen while digging into error logs for STRIPE-745, but we need additional logging to be able to get more details when that occurs.

Testing instructions

The simplest way to test this is as follows:

  • Run this branch on an environment where you can modify /etc/hosts (or its equivalent)
    • In our default Docker environment, you can simply modify /etc/hosts for your host machine
  • Modify your /etc/hosts file to add a line like the following to redirect api.stripe.com to your local machine:
127.0.0.1      api.stripe.com
  • You may need to flush your DNS cache. You can do on MacOS by running the following commands:
sudo dscacheutil -flushcache;
sudo killall -HUP mDNSResponder;
  • Load your store so the Stripe code will try to load and call Stripe -- a surefire way is to navigate to the settings with payment methods
  • Remove the DNS redirect quickly to prevent your logs from being flooded - you can do that by removing the line you added or prefixing it with #.
  • Ensure you flush the DNS cache again to get back to the normal/real DNS records.
  • Inspect your logs and verify that the response logs include errors with the following message:
ERROR: Stripe API error: GET account; Possible DNS resolution problem for api.stripe.com
  • Inspect the detailed items for the log, and verify that it includes the resolved_ip_address and validation_details keys.

We don't think we're seeing anything as problematic as this in the wild, but we have seen some merchants report issues with HTTP requests to Stripe failing with this type of error, and this logging should help us to debug that should it occur again.


  • Covered with tests (or have a good reason not to test in description ☝️)
  • [N/A] Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@daledupreez daledupreez added this to the 10.1.0 milestone Nov 6, 2025
@daledupreez daledupreez marked this pull request as ready for review November 10, 2025 15:32
@daledupreez daledupreez requested review from a team, Mayisha, Copilot and diegocurbelo and removed request for a team November 10, 2025 15:32
Copy link
Contributor

Copilot AI left a 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 enhanced logging for URL validation issues when calling the Stripe API. The changes extract error logging into a dedicated method and add special handling to diagnose DNS resolution problems when WordPress core detects invalid URLs.

  • Refactored error logging from inline code into a reusable log_error_response() method
  • Added DNS resolution diagnostics when URL validation failures occur
  • Comprehensive test coverage for the new logging functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
includes/class-wc-stripe-api.php Extracted error logging to log_error_response() method and added DNS resolution diagnostics for URL validation errors
tests/phpunit/WC_Stripe_API_Test.php Added comprehensive tests for error logging scenarios including URL validation failures
readme.txt Updated changelog to document the new logging features
changelog.txt Updated changelog to document the new logging features

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

The changes look good, and it tests well:
Image

Image

Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

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

Works as described 👍

Screenshot 2025-11-12 at 3 51 26 PM

@daledupreez daledupreez enabled auto-merge (squash) November 12, 2025 10:39
@daledupreez daledupreez merged commit d6fc741 into develop Nov 12, 2025
40 checks passed
@daledupreez daledupreez deleted the add/logging-for-http-validation-failures branch November 12, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants