> 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-lv/integracija/api-klienta-sdk/atrie-sakumi/node.js-typescript.md).

# Node.js / TypeScript

Iestatiet Node.js / TypeScript SDK, uzsāciet smilškastes maksājumu un konfigurējiet klienta adapterus.

## Priekšnosacījumi

* Node.js 20 vai jaunāka versija. Pakotne ir tikai ESM formātā un satur TypeScript tipus.
* Sandbox API akreditācijas dati: **klienta ID** un **klienta noslēpums**, kā arī jūsu **dalībnieka ID** un **veikala līguma ID**. Reģistrējieties un ģenerējiet tos paši sadaļā **Tirgotāja portālā**: <https://merchantportal.ecommerce.sebgroup.com>.
* SDK **izplatīšanas ZIP fails**, kas lejupielādēts no šīs dokumentācijas vietnes.

## Instalēt

Lejupielādēt `egw-js-sdk-<version>.zip` un tam atbilstošo `.sha256` failu, pārbaudiet lejupielādi, pēc tam atarhivējiet to blakus savam projektam:

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

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

Tas jums dod `egw-sdk/tieto-egw-sdk-<version>.tgz` — parasts npm pakotnes tarballs — kopā ar `README.txt` un `SHA256SUMS` manifestu. Instalējiet to no sava projekta:

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

Pakotnes nosaukums ir `@tieto/egw-sdk`, un tās izpildlaika atkarības ir `axios` un `jose`. npm tos iegūst no jūsu parastā reģistra, tāpēc instalēšanai nepieciešama piekļuve tīklam.

## Izveidojiet klientu un veiciet savu pirmo izsaukumu

Šajā piemērā akreditācijas dati tiek iegūti no vides mainīgajiem — nekad neielieciet repozitorijā un nelogojiet īstus akreditācijas datus. Visas darbības ir `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("Pirmais testa maksājums smilškastē")
);

console.log("Maksājums izveidots:", response.paymentId);
```

Summas ir **decimālās virknes** (`"100.00"`), valūtas ISO 4217 alpha-3. Testa kartēm un burvju vērtībām skatiet [Sandbox testa datus](/seb-docs-draft/seb-docs-public-lv/celvezi/smilskaste.md).

## Klienta pielāgošana

* Varat nodrošināt savu HTTP klienta (adaptera) implementāciju.
* Tīmekļa āķi: Node.js SDK nesāk klausītāju; publicējiet savu HTTP galapunktu un parsējiet ielādes ar `client.notifications().parseWebhook()` — skatiet [Drošības mehānismi](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/drosibas-mehanismi.md#webhook-notifications).
* Skatiet [SDK adapteru pārrakstīšana](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/sdk-adapteru-aizstasana.md) lai iegūtu pilnu pārskatu par adapteru aizstāšanu visā lietotnē.

## Nākamie soļi

* [Drošības mehānismi](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/drosibas-mehanismi.md) — karšu šifrēšana karšu norēķinu sesijām, webhooks.
* [Kļūdu apstrāde](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/kludu-apstrade.md) — izņēmumu hierarhija un atkārtotu mēģinājumu ieteikumi.


---

# 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-lv/integracija/api-klienta-sdk/atrie-sakumi/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.
