> 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/java.md).

# Java

Iestatiet Java SDK, uzsāciet smilškastes maksājumu un konfigurējiet klientu.

## Priekšnosacījumi

* Java 11 vai jaunāka versija, Maven vai Gradle.
* 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-java-sdk-<version>.zip` un tam atbilstošo `.sha256` failu, pārbaudiet lejupielādi, pēc tam atarhivējiet to un instalējiet JAR failus savā lokālajā Maven repozitorijā:

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

unzip egw-java-sdk-<version>.zip -d egw-sdk
cd egw-sdk

mvn install:install-file \
  -Dfile=egw-java-core-<version>.jar \
  -DpomFile=egw-java-core-<version>.pom \
  -Dsources=egw-java-core-<version>-sources.jar
```

Instalējot ar `-DpomFile` ir tas, kas ļauj SDK paša atkarībām (Jackson, Nimbus JOSE+JWT, SLF4J API) atrisināties automātiski. Bez tā katra no tām jādeklarē pašam.

Pēc tam izmantojiet to kā parasti:

```xml
<dependency>
    <groupId>com.tieto.banking.egw</groupId>
    <artifactId>egw-java-core</artifactId>
    <version><!-- the version you installed --></version>
</dependency>
```

Kopīgai komandas iestatīšanai izvietojiet to pašu artefaktu vienu reizi savas organizācijas iekšējā repozitorijā (`mvn deploy:deploy-file`) nevis lieciet katram izstrādātājam to instalēt lokāli.

## Izveidojiet klientu un veiciet savu pirmo izsaukumu

Šajā piemērā akreditācijas dati tiek nolasīti no vides mainīgajiem — nekad neuzglabājiet vai nerādiet reālus akreditācijas datus.

```java
import com.tieto.banking.egw.merchantapi.sdk.application.EgwClient;
import com.tieto.banking.egw.merchantapi.sdk.application.bootstrap.DefaultEgwClientFactory;
import com.tieto.banking.egw.merchantapi.sdk.application.dto.CitPaymentChannel;
import com.tieto.banking.egw.merchantapi.sdk.application.dto.InitiatePaymentResponse;
import java.net.URI;

try (EgwClient client = new DefaultEgwClientFactory()
        .connectingTo(URI.create("https://sandbox.api.ecommerce.sebgroup.com"))
        .authorizingAs(System.getenv("EGW_CLIENT_ID"), System.getenv("EGW_CLIENT_SECRET"))
        .createEgwClient()) {

    InitiatePaymentResponse response = client.payments().initiateCitPayment(b -> b
            .channel(CitPaymentChannel.BROWSER)
            .instructedAmount(a -> a.amount("100.00").currency("EUR"))
            .orderNumber("ORD-001")
            .participantId(System.getenv("EGW_PARTICIPANT_ID"))
            .shopAgreementId(System.getenv("EGW_SHOP_AGREEMENT_ID"))
            .shopRedirectUrl("https://shop.example.com/return")
            .description("First sandbox payment"));

    System.out.println("Payment created: " + response.getPaymentId());
}
```

Kas notika automātiski: rūpnīca no bāzes URL noteica OAuth marķiera galapunktu un JWE atslēgas galapunktu; klients pirms izsaukuma izgūla un kešēja OAuth 2.0 piekļuves marķieri; unikāla `X-Request-ID` galvene tika ģenerēta pieprasījumam.

`EgwClient` ir nemaināms un droši koplietojams; izveidojiet to vienreiz un izmantojiet atkārtoti (OAuth marķiera kešatmiņa ir droša darbam ar vairākiem pavedieniem). `close()` ir svarīgs tikai tad, ja esat iespējojis tīmekļa āķa klausītāju.

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

Rūpnīca pirms tam pieņem papildu aizvietotājus `createEgwClient()`:

* `connectingWith(ApiClient)` — varat norādīt savu HTTP klienta implementāciju.
* `loggingWith(EgwLogger)` — pieslēdziet savu žurnalēšanu; noklusējuma logētājs ir kluss. Skatiet brīdinājumu sadaļā [Drošības mehānismi](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/drosibas-mehanismi.md#logging) pirms žurnalēšanas ieslēgšanas ražošanas vidē.
* `listeningAt(URI)` / `listeningWith(ApiServer)` — iespējojiet tīmekļa āķa klausītāju; skatiet [Drošības mehānismi](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/drosibas-mehanismi.md#webhook-notifications).

Infrastruktūras adapterus (HTTP, serializētāju, šifrētāju) var arī aizstāt visā lietotnē, izmantojot Java `ServiceLoader` nodrošinātājus (`ApiClientProvider`, `SerializerProvider`, `DataEncrypterProvider`, `EgwLoggerProvider` iekš `…bootstrap.spi`). Skatiet [SDK adapteru pārrakstīšana](/seb-docs-draft/seb-docs-public-lv/integracija/api-klienta-sdk/celvezi/sdk-adapteru-aizstasana.md) pilnam soli pa solim aprakstam.

## 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/java.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.
