Skip to content

Conversation

daledupreez
Copy link
Contributor

Fixes STRIPE-727
Fixes #4697

Changes proposed in this Pull Request:

This PR updates the logic for building Stripe customer data to look at multiple sources, including the WooCommerce customer object. The PR also changes the logic to build a composite set of data across sources. I am not sure if that is the best idea -- it may be better to simply use the WC_Customer instance instead of the current user.

Testing instructions


  • Covered with tests (or have a good reason not to test in description ☝️)
  • 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 requested a review from Copilot October 10, 2025 15:13
Copy link
Contributor

@Copilot 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 enhances the Stripe customer data building logic to use multiple data sources in a hierarchical fashion. Instead of relying solely on WordPress user data or billing fields, the updated logic now checks user data first, then WooCommerce customer data, and finally falls back to submitted billing data to create a comprehensive customer profile for Stripe.

  • Updated generate_customer_request() method to use a composite data approach across multiple sources
  • Added new get_wc_customer() method to access WooCommerce customer object
  • Refactored address field generation into a separate helper method for better maintainability

Reviewed Changes

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

File Description
includes/class-wc-stripe-customer.php Enhanced customer data building logic with hierarchical data source fallbacks and new helper methods
tests/phpunit/WC_Stripe_Customer_Test.php Added comprehensive test coverage for the new customer request generation logic
readme.txt Updated changelog entry for the customer data building fix
changelog.txt Added changelog entry documenting the enhancement

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

/**
* Get the current WooCommerce customer object.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

Missing @return annotation for the method. Should include @return WC_Customer|null to document the return type.

Suggested change
* Get the current WooCommerce customer object.
* Get the current WooCommerce customer object.
*
* @return WC_Customer|null

Copilot uses AI. Check for mistakes.

Comment on lines +283 to +285
if ( null === $value ) {
$value = '';
}
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

The condition null === $value will never be true. get_user_meta() with $single = true returns an empty string for non-existent meta keys, not null. This check should be removed or changed to check for empty string.

Suggested change
if ( null === $value ) {
$value = '';
}

Copilot uses AI. Check for mistakes.

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.

Payment Fails with “Missing required customer field: address->line1” Since v9.7 – Validation Bug on Guest & Auto Account Flows

1 participant