Pular para o conteúdo

Install & initialize

Add the package for your language, then create a single LinaEmbeddedPaymentsClient and reuse it across requests — the client caches the access token internally, so one instance per process is enough.

Install the package

npm install @linainfratech/embedded-payments

Initialize the client

The recommended way to configure the client is environment: 'hml' | 'prd' — the SDK resolves everything else internally, including authentication. Provide your integrator credentials (clientId/clientSecret) and the client fetches, caches, and refreshes the access token for you; you never talk to an auth endpoint directly.

import { LinaEmbeddedPaymentsClient } from '@linainfratech/embedded-payments';

const client = new LinaEmbeddedPaymentsClient({
environment: 'hml', // 'hml' | 'prd' — resolves baseUrl/authBaseUrl for you
clientId: process.env.LINA_CLIENT_ID,
clientSecret: process.env.LINA_CLIENT_SECRET,
// Optional: subTenantId, timeoutMs, maxRetries, logger, fetch, tokenProvider
// Advanced override: baseUrl / authBaseUrl (proxy, mTLS, custom infra)
});

const participants = await client.participants.listRegistered();

Configuration options

The same options exist in every language, with idiomatic names (timeoutMs in Node, timeout/Timeout elsewhere; clientId/ClientId).

OptionRequiredDefaultDescription
environmentNo¹'hml' | 'prd' — the recommended way to configure the client.
baseUrl / authBaseUrlNo¹Advanced override for a proxy, mTLS terminator, or custom infra. Not needed if environment is set — most integrations never touch these.
clientId / clientSecretYes²Your integrator credentials — identify your sub-tenant. Provided when you're onboarded.
subTenantIdNoAdmin/tenant callers only; sent as the subTenantId header.
timeoutNo30000 msPer-request timeout.
maxRetriesNo2Retries on idempotent (GET) calls only.
loggerNono-opStructured log hook (debug/info/warn/error).
tokenProviderNoclient_credentialsPlug in your own token strategy.
HTTP clientNonativeInject a custom HTTP client for mTLS, proxy, or tests (fetch in Node, HttpExecutor in .NET).

¹ Provide environment, or baseUrl+authBaseUrl, or both (explicit values override the environment default per field). Providing neither raises a config error at construction time. ² clientId and clientSecret are required only with the default token strategy. With a custom tokenProvider, the SDK never fetches a token itself and they can be omitted.

Authentication

Authentication is automatic and entirely handled for you: provide clientId/clientSecret, and the SDK fetches, caches, and refreshes the access token behind the scenes — refreshing proactively before it's within 300 seconds of expiry, and sharing a single in-flight refresh across concurrent calls. You never call an auth endpoint or manage a token yourself.

Environments

environment: 'hml' targets the homologation/sandbox infrastructure; environment: 'prd' targets production. Credentials are the only thing that changes between them — paths and payloads are identical, so code written against hml works unchanged in prd.

Next steps