Skip to content

Fix handling for "no such customer" response for customer payment_methods query #4561

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

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 @@ -32,6 +32,7 @@
* Dev - Move some testing and compiler node dependencies to devDependencies
* Dev - Minor CSS change to comply with a SASS rule deprecation
* Dev - Update SCSS to replace @import with @use and @forward
* Fix - Handle missing customer when calling payment_methods API

= 9.7.1 - 2025-07-28 =
* Add - Add state mapping for Lithuania in express checkout
Expand Down
9 changes: 9 additions & 0 deletions includes/class-wc-stripe-customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,15 @@ public function get_payment_methods( $payment_method_type ) {
);

if ( ! empty( $response->error ) ) {
if (
isset( $response->error->code, $response->error->param, $response->error->type )
&& 'customer' === $response->error->param
&& 'resource_missing' === $response->error->code
&& 'invalid_request_error' === $response->error->type
) {
// If the customer doesn't exist, cache an empty array as a result.
set_transient( self::PAYMENT_METHODS_TRANSIENT_KEY . $payment_method_type . $this->get_id(), [], DAY_IN_SECONDS );
}
return [];
}

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
* Dev - Move some testing and compiler node dependencies to devDependencies
* Dev - Minor CSS change to comply with a SASS rule deprecation
* Dev - Update SCSS to replace @import with @use and @forward
* Fix - Handle missing customer when calling payment_methods API

[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).
Loading