Describe the bug
The plugin fetches the grouped payment provider list live from services.paytrail.com on every render, no caching, 10s timeout. WooCommerce Blocks asks every gateway for its script data whenever the cart/checkout block assets load, so it fires outside checkout — in the header mini-cart on regular pages and in the block editor preload. 3 live HTTP calls per request.
Steps to Reproduce
- Have the Paytrail gateway enabled with provider selection on
- Open any page in the block editor (e.g. a normal Page), or load a front-end page that renders a mini-cart
- Watch the request — it blocks on 3 GET requests to services.paytrail.com/merchants/grouped-payment-providers
Expected behaviour
The provider list should only be fetched when it's actually needed (checkout), and it should be cached. Editing a page or loading a normal front-end page shouldn't make blocking calls to Paytrail.
Actual behaviour
Every render that enqueues the cart/checkout block assets triggers a live, uncached HTTPS round-trip per gateway. Profiling a page-editor load:
- GuzzleHttp\Handler\CurlHandler::__invoke — 2.0s, 3 calls (~20% of the request)
- 10s loads when Paytrail responds slowly (SDK default timeout)
Call chain:
PaymentMethodRegistry::get_all_registered_script_data
-> Paytrail_Blocks_Support::get_payment_method_data (src/PaytrailBlocks.php:239)
-> Gateway::get_grouped_payment_providers (src/Gateway.php:2120)
-> SDK Client::getGroupedPaymentProviders (vendor/paytrail/paytrail-php-sdk/src/Client.php:138)
-> Guzzle -> curl -> services.paytrail.com
The SDK client is constructed with no cache layer (src/Gateway.php:187), so there's nothing between the gateway and the network.
Screenshots
N/A
Additional context
Found via xhprof profiling. Same pattern shows up in production APM (3 services.paytrail.com calls per affected request).
Describe the bug
The plugin fetches the grouped payment provider list live from services.paytrail.com on every render, no caching, 10s timeout. WooCommerce Blocks asks every gateway for its script data whenever the cart/checkout block assets load, so it fires outside checkout — in the header mini-cart on regular pages and in the block editor preload. 3 live HTTP calls per request.
Steps to Reproduce
Expected behaviour
The provider list should only be fetched when it's actually needed (checkout), and it should be cached. Editing a page or loading a normal front-end page shouldn't make blocking calls to Paytrail.
Actual behaviour
Every render that enqueues the cart/checkout block assets triggers a live, uncached HTTPS round-trip per gateway. Profiling a page-editor load:
Call chain:
The SDK client is constructed with no cache layer (src/Gateway.php:187), so there's nothing between the gateway and the network.
Screenshots
N/A
Additional context
Found via xhprof profiling. Same pattern shows up in production APM (3 services.paytrail.com calls per affected request).