Skip to content

Reduce PMC API calls #4240

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 4 commits into from
Closed

Reduce PMC API calls #4240

wants to merge 4 commits into from

Conversation

Mayisha
Copy link
Contributor

@Mayisha Mayisha commented Apr 17, 2025

Changes proposed in this Pull Request:

  • Added cache for storing PMC
  • Sending the force_fetch: true only on the plugin settings page. Whenever the settings page is refreshed, PMC will be retrieved.
  • PMC will be retrieved if the cache is empty (i.e, not set initially or after expiration of the transient)
  • Clearing the cache when merchant updates the enabled/disabled methods on the plugin setting page. This ensures that the latest PMC will be fetched on next call.

Testing instructions

  • Smoke test PMC

@Mayisha Mayisha marked this pull request as draft April 17, 2025 11:26
@Mayisha Mayisha requested a review from diegocurbelo April 17, 2025 11:28
Copy link

📈 PHP Unit Code Coverage Report

Package Line Rate Health
includes/class-wc-stripe-payment-method-configurations.php 95%
Summary 45% (7204 / 16185)

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.

Thanks for working on this @Mayisha.

I left two comments, one is just renaming the transient to mention PMC instead of UPE... and the other is moving the transient to get_primary_configuration to also cover the migration flow.

if ( ! $force_refresh && ! empty( get_transient( self::UPE_ENABLED_PAYMENT_METHOD_IDS_TRANSIENT_KEY ) ) ) {
return get_transient( self::UPE_ENABLED_PAYMENT_METHOD_IDS_TRANSIENT_KEY );
}

$enabled_payment_method_ids = [];
$merchant_payment_method_configuration = self::get_primary_configuration();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should move the transient check inside this self::get_primary_configuration() which is the one making the actual API call... as it's also called from self::maybe_migrate_payment_methods_from_db_to_pmc()

*
* @var string
*/
const UPE_ENABLED_PAYMENT_METHOD_IDS_TRANSIENT_KEY = 'wc_stripe_upe_enabled_payment_method_ids';
Copy link
Member

@diegocurbelo diegocurbelo Apr 17, 2025

Choose a reason for hiding this comment

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

Maybe we can rename this tol PMC_CONFIGURATION_TRANSIENT_KEY to indicate it's the PMC configuration better differentiate it from the upe_checkout_experience_accepted_payments option

@Mayisha
Copy link
Contributor Author

Mayisha commented Apr 17, 2025

Closing in favor of #4241

@Mayisha Mayisha closed this Apr 17, 2025
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.

2 participants