Files
cms/tests
libretech 7df72676c9
build / test (pull_request) Successful in 11s
build / build (pull_request) Successful in 9m23s
fix(paypal): replace a broken SDK client and time out after 15 s
The PayPal SDK keeps the promise of its OAuth token for the lifetime of
its Client, also when the token request failed. After one failed token
request, as during the DNS outage, every later call failed with that
same error and without a request until the process restarted: once DNS
was back, the investigators' harness (scenario S7) saw 0 DNS lookups.
The client had no timeout either: the SDK's default of 0 means none.

PayPalApi now reaches PayPal through createPayPalClient
(src/checkout/paypal-client.ts). It creates the SDK's Client and
OrdersController through an injected factory on the first call, and
anew after an error of the token request, an error without an answer
from PayPal (network, DNS, timeout), 401 or 5xx. PayPal's other
answers, such as 422, keep the client. A call that fails on a client
that was replaced meanwhile leaves its successor alone. A replacement
is logged as a warning with the error described.

The client times out after 15 s. paypalClientConfiguration builds its
configuration, with the logging of bodies and headers off.

The tests use a fake factory that, like the SDK, keeps a failed token
request per client, and count constructions and token requests. With
the real SDK in the harness, S7 looks DNS up again and every Client is
created with a timeout of 15000.

Refs libretech/mp#71
Refs libretech/mp#67
2026-10-09 01:55:06 +02:00
..