Skip to content

Cache enabled payment method IDs for non-admin pages #4183

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

Closed
wants to merge 46 commits into from

Conversation

hsingyuc
Copy link
Contributor

@hsingyuc hsingyuc commented Apr 2, 2025

Fixes #4182

Changes proposed in this Pull Request:

This PR caches enabled payment method IDs. Frontend uses the cache if it’s set, and the backend updates the cache.

Testing instructions

  1. Please checkout branch dev/cache-enabled-payment-methods-test
  2. Visit the merchant site like the checkout page, and admin page
  3. Check your debug log

  • 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

@hsingyuc hsingyuc requested review from a team and wjrosa and removed request for a team April 2, 2025 03:53
changelog.txt Outdated
@@ -43,6 +43,7 @@
* Tweak - Add save payment method parameter to update intent call for non-deferred intent payment methods.
* Dev - Fetch Stripe settings with Stripe configuration API.
* Add - Hook up payment methods configuration.
* Dev - Cache enabled payment method IDs
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should explain the change better here 👀

@@ -84,6 +95,7 @@ public static function get_upe_enabled_payment_method_ids() {
}
}

set_transient( self::UPE_ENABLED_PAYMENT_METHOD_IDS_TRANSIENT_KEY, $enabled_payment_method_ids, DAY_IN_SECONDS );
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should include a cache bust function when the merchant changes the available payment methods.

@wjrosa
Copy link
Contributor

wjrosa commented Apr 2, 2025

Check your debug log

Thanks for working on this! I could not find any indication on my debug.log file related to the cache setting/querying 🤔 . Maybe some testing steps are missing from the instructions?

@diegocurbelo diegocurbelo self-assigned this Apr 3, 2025
Copy link

github-actions bot commented Apr 8, 2025

📈 PHP Unit Code Coverage Report

Package Line Rate Health
includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php 23%
includes/abstracts/abstract-wc-stripe-payment-gateway.php 47%
includes/admin/class-wc-rest-stripe-settings-controller.php 82%
includes/admin/class-wc-stripe-amazon-pay-controller.php 0%
includes/admin/class-wc-stripe-payment-requests-controller.php 0%
includes/admin/class-wc-stripe-settings-controller.php 21%
includes/class-wc-stripe-feature-flags.php 94%
includes/class-wc-stripe-helper.php 58%
includes/class-wc-stripe-intent-controller.php 25%
includes/class-wc-stripe-webhook-handler.php 31%
includes/compat/trait-wc-stripe-subscriptions.php 21%
includes/payment-methods/class-wc-gateway-stripe-alipay.php 39%
includes/payment-methods/class-wc-gateway-stripe-bancontact.php 26%
includes/payment-methods/class-wc-gateway-stripe-boleto.php 9%
includes/payment-methods/class-wc-gateway-stripe-eps.php 26%
includes/payment-methods/class-wc-gateway-stripe-giropay.php 32%
includes/payment-methods/class-wc-gateway-stripe-ideal.php 26%
includes/payment-methods/class-wc-gateway-stripe-multibanco.php 20%
includes/payment-methods/class-wc-gateway-stripe-oxxo.php 13%
includes/payment-methods/class-wc-gateway-stripe-p24.php 26%
includes/payment-methods/class-wc-gateway-stripe-sepa.php 21%
includes/payment-methods/class-wc-gateway-stripe-sofort.php 24%
includes/payment-methods/class-wc-stripe-express-checkout-helper.php 20%
includes/payment-methods/class-wc-stripe-upe-payment-gateway.php 49%
includes/payment-methods/class-wc-stripe-upe-payment-method-becs-debit.php 100%
includes/payment-methods/class-wc-stripe-upe-payment-method-blik.php 38%
includes/payment-methods/class-wc-stripe-upe-payment-method-cc.php 86%
includes/payment-methods/class-wc-stripe-upe-payment-method-klarna.php 56%
includes/payment-methods/class-wc-stripe-upe-payment-method-sepa.php 91%
includes/payment-methods/class-wc-stripe-upe-payment-method.php 55%
includes/payment-tokens/class-wc-stripe-payment-tokens.php 18%
Summary 44% (7010 / 16002)

Base automatically changed from add/hook-up-enabled-payment-methods to add/settings-synchronization April 8, 2025 14:11
Base automatically changed from add/settings-synchronization to develop April 16, 2025 18:29
@diegocurbelo
Copy link
Member

Closing in favor of #4241

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.

Settings Synchronization: Cache enabled payment methods for non-admin pages
3 participants