> For the complete documentation index, see [llms.txt](https://docs.ecommerce.seb.ee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecommerce.seb.ee/seb-docs-draft/seb-docs-public-et/integratsioon/api-kliendi-sdk/kiirstardid/node.js-typescript.md).

# Node.js / TypeScript

Seadistage Node.js / TypeScript SDK, algatage liivakastimakse ja konfigureerige kliendi adapterid.

## Eeltingimused

* Node.js 20 või uuem. Pakett on ainult ESM ning sisaldab TypeScripti tüüpe.
* Sandboxi API mandaadid: **kliendi ID** ja **kliendi saladus**, lisaks teie **osaleja ID** ja **poe lepingu ID**. Registreeruge ja genereerige need ise aadressil **Merchant Portal**: <https://merchantportal.ecommerce.sebgroup.com>.
* SDK **levi ZIP-pakett**, mis on alla laaditud selle dokumentatsioonisaidi kaudu.

## Installi

Laadi alla `egw-js-sdk-<version>.zip` ja selle vastava `.sha256` faili, kontrollige allalaadimist, seejärel pakkige see oma projekti kõrvale lahti:

```bash
sha256sum -c egw-js-sdk-<version>.zip.sha256

unzip egw-js-sdk-<version>.zip -d egw-sdk
```

See annab teile `egw-sdk/tieto-egw-sdk-<version>.tgz` — tavaline npm-paketi tarball — koos `README.txt` ja `SHA256SUMS` manifestiga. Installige see oma projektist:

```bash
npm install ./egw-sdk/tieto-egw-sdk-<version>.tgz
```

Paketi nimi on `@tieto/egw-sdk`, ja selle käitusaja sõltuvused on `axios` ja `jose`. npm lahendab need teie tavalisest registrist, seega vajab paigaldamine sellele võrguühendust.

## Looge klient ja tehke oma esimene päring

Selles näites hangitakse volitused keskkonnamuutujatest — ära kunagi salvesta ega logi päris volitusi. Kõik toimingud on `async`.

```ts
import { DefaultEgwClientFactory, CitPaymentChannel } from "@tieto/egw-sdk";
import { randomUUID } from "node:crypto";

const client = new DefaultEgwClientFactory().create({
  baseUri: new URL("https://sandbox.api.ecommerce.sebgroup.com"),
  authentication: {
    tokenEndpoint: new URL("https://api.ecommerce.sebgroup.com/auth/realms/participants-seb/protocol/openid-connect/token"),
    clientId: process.env.EGW_CLIENT_ID!,
    clientSecret: process.env.EGW_CLIENT_SECRET!,
  },
  jwkUri: new URL("https://checkout.ecommerce.sebgroup.com/api/keys/card-encryption.jwk"),
});

const response = await client.payments().initiateCitPaymentWithBuilder(randomUUID(), (b) =>
  b.channel(CitPaymentChannel.Browser)
   .instructedAmountBuilder((a) => a.amount("100.00").currency("EUR"))
   .orderNumber("ORD-001")
   .participantId(process.env.EGW_PARTICIPANT_ID!)
   .shopAgreementId(process.env.EGW_SHOP_AGREEMENT_ID!)
   .shopRedirectUrl("https://shop.example.com/return")
   .description("First sandbox payment")
);

console.log("Makse loodud:", response.paymentId);
```

Summad on **kümnendstringid** (`"100.00"`), valuutad ISO 4217 alpha-3. Testkaartide ja maagiliste väärtuste kohta vt [Sandboxi testandmed](/seb-docs-draft/seb-docs-public-et/juhendid/liivakast.md).

## Kliendi kohandamine

* Võite kasutada oma HTTP-klienti (adapteri) teostust.
* Veebhookid: Node.js SDK ei käivita kuulajat; tehke oma HTTP-lõpp-punkt kättesaadavaks ja töödelge payload'e kasutades `client.notifications().parseWebhook()` — vt [Turvamehhanismid](/seb-docs-draft/seb-docs-public-et/integratsioon/api-kliendi-sdk/juhendid/turvamehhanismid.md#webhook-notifications).
* Vt [SDK adapterite ülekirjutamine](/seb-docs-draft/seb-docs-public-et/integratsioon/api-kliendi-sdk/juhendid/sdk-adapterite-asendamine.md) täieliku juhendi jaoks adapterite asendamiseks kogu rakenduse ulatuses.

## Järgmised sammud

* [Turvamehhanismid](/seb-docs-draft/seb-docs-public-et/integratsioon/api-kliendi-sdk/juhendid/turvamehhanismid.md) — kaardi krüpteerimine kaardi kassaseansside jaoks, veebikonksud.
* [Vigade käsitlemine](/seb-docs-draft/seb-docs-public-et/integratsioon/api-kliendi-sdk/juhendid/vigade-kasitlemine.md) — erandite hierarhia ja uuesti proovimise juhised.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecommerce.seb.ee/seb-docs-draft/seb-docs-public-et/integratsioon/api-kliendi-sdk/kiirstardid/node.js-typescript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
