Skip to main content

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 executed
  • TokenCache: customize where OAuth tokens are stored

Custom HTTP transport

Implement HttpTransport 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.
Use it in client creation:

Custom token cache

Implement TokenCache for Redis, Memcached, database, or distributed in-memory systems.
Use it in client creation:

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.