Extensibility
Most integrations only need
createGoPayClient defaults. Reach for custom HttpTransport / TokenCache when you need observability, proxies, shared token storage, or non-fetch HTTP clients.gopay-sdk is intentionally extensible through two abstractions:
HttpTransport: customize how requests are executedTokenCache: customize where OAuth tokens are stored
Custom HTTP transport
ImplementHttpTransport to plug in custom fetch behavior (logging, retries, tracing, proxying, etc.).
You can import transport types from the main package or from gopay-sdk/http for narrower imports.
Custom token cache
ImplementTokenCache for Redis, Memcached, database, or distributed in-memory systems.
Design recommendations
- Keep transport retries conservative (network timeouts only).
- Do not blindly retry non-idempotent payment create calls.
- Centralize observability and correlation IDs at transport layer.
- Use a shared token cache when many service instances share the same credentials.
- Keep cache key granularity aligned with
clientId + gatewayUrl + scope.