Skip to content
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

Improve efficiency in refreshing payment method verification with Stripe for ECE #10426

Open
asumaran opened this issue Feb 22, 2025 · 0 comments

Comments

@asumaran
Copy link
Contributor

          This is a good point. I was looking at it but haven't included it into this PR. I think that caching itself is a pretty nice addition because otherwise, like you're mentioning, we will be making unnecessary third-party Stripe requests too often.

There is indeed a potential issue because at the moment, memoize uses the entire cart object for cache key generation, which doesn't work well for object comparison and could lead to improper cache hits/misses.

By making the cache key more specific with only the relevant fields that affect the payment method availability:

export const checkPaymentMethodIsAvailable = memoize(
	( paymentMethod, cart ) => {...},
	( paymentMethod, cart ) => {
		return JSON.stringify({
			paymentMethod,
			total_price: cart.cartTotals.total_price,
			country: cart.billingAddress?.country
		});
	}
);

we will ensure it runs on some specific updates. But for this, we'd need to know what fields are relevant in our context, e.g. if billing country change should trigger reviewing ece availability. I think we can open a follow up issue, if we consider this worth diving into further.

Originally posted by @timur27 in #9927 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants