> 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-lt/integracija/api-kliento-sdk/greitos-pradzios/node.js-typescript.md).

# Node.js / TypeScript

Nustatykite Node.js / TypeScript SDK, inicijuokite Sandbox mokėjimą ir sukonfigūruokite kliento adapterius.

## Būtinos sąlygos

* Node.js 20 ar naujesnė versija. Paketas yra tik ESM ir pateikiamas su TypeScript tipais.
* Sandbox API kredencialai: **kliento ID** ir **kliento slaptasis raktas**, taip pat jūsų **dalyvio ID** ir **parduotuvės sutarties ID**. Užsiregistruokite ir sugeneruokite juos patys **Merchant Portal**: <https://merchantportal.ecommerce.sebgroup.com>.
* SDK **platinimo ZIP archyvas**, atsisiųstą iš šios dokumentacijos svetainės.

## Įdiegimas

Atsisiųsti `egw-js-sdk-<version>.zip` ir jam atitinkamą `.sha256` failą, patikrinkite atsisiuntimą, tada išarchyvuokite jį šalia savo projekto:

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

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

Taip gausite `egw-sdk/tieto-egw-sdk-<version>.tgz` — įprastas npm paketo tarball'as — kartu su `README.txt` ir `SHA256SUMS` manifestu. Įdiekite jį iš savo projekto:

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

Paketo pavadinimas yra `@tieto/egw-sdk`, o jo vykdymo priklausomybės yra `axios` ir `jose`. npm juos paima iš jūsų įprasto registro, todėl diegimui reikia prieigos prie tinklo.

## Sukurkite klientą ir atlikite pirmąjį iškvietimą

Šiame pavyzdyje prisijungimo duomenys paimami iš aplinkos kintamųjų — niekada neįtraukite į saugyklą ir neregistruokite tikrų prisijungimo duomenų. Visos operacijos yra `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("Mokėjimas sukurtas:", response.paymentId);
```

Sumos yra **dešimtainės eilutės** (`"100.00"`), valiutos — ISO 4217 alfa-3. Dėl testinių kortelių ir magiškų reikšmių žr. [Sandbox testiniai duomenys](/seb-docs-draft/seb-docs-public-lt/gaires/sandbox.md).

## Kliento pritaikymas

* Galite pateikti savo HTTP kliento (adapterio) įgyvendinimą.
* Webhookai: Node.js SDK nepaleidžia klausyklės; atidarykite savo HTTP galinį tašką ir analizuokite pranešimų duomenis naudodami `client.notifications().parseWebhook()` — žr. [Saugumo mechanizmuose](/seb-docs-draft/seb-docs-public-lt/integracija/api-kliento-sdk/gaires/saugumo-mechanizmai.md#webhook-notifications).
* Žr. [SDK adapterių perrašymas](/seb-docs-draft/seb-docs-public-lt/integracija/api-kliento-sdk/gaires/sdk-adapteriu-perrasymas.md) visą adapterių keitimo visoje programoje apžvalgą.

## Kiti žingsniai

* [Saugumo mechanizmuose](/seb-docs-draft/seb-docs-public-lt/integracija/api-kliento-sdk/gaires/saugumo-mechanizmai.md) — kortelių šifravimą kortelių atsiskaitymo sesijoms, webhook'ams.
* [Klaidų tvarkymas](/seb-docs-draft/seb-docs-public-lt/integracija/api-kliento-sdk/gaires/klaidu-valdymas.md) — išimčių hierarchiją ir pakartotinio bandymo gaires.


---

# 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-lt/integracija/api-kliento-sdk/greitos-pradzios/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.
