> 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/integration/api-client-sdk/quickstarts/java.md).

# Java

Set up the Java SDK, initiate a sandbox payment, and configure the client.

## Prerequisites

* Java 11 or later, Maven or Gradle.
* Sandbox API credentials: **client ID** and **client secret**, plus your **participant ID** and **shop agreement ID**. Register and generate these yourself at the **Merchant Portal**: <https://merchantportal.ecommerce.sebgroup.com>.
* The SDK **distribution ZIP**, downloaded from this documentation site.

## Install

Download `egw-java-sdk-<version>.zip` and its matching `.sha256` file, verify the download, then unzip it and install the JARs into your local Maven repository:

```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
```

Installing with `-DpomFile` is what makes the SDK's own dependencies (Jackson, Nimbus JOSE+JWT, SLF4J API) resolve automatically. Without it you must declare each of them yourself.

Then depend on it as normal:

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

For a shared team setup, deploy the same artifact once to your organization's internal repository (`mvn deploy:deploy-file`) instead of having every developer install it locally.

## Create a client and make your first call

In this example, the credentials are retrieved from environment variables — never commit or log real credentials.

```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());
}
```

What happened automatically: the factory derived the OAuth token endpoint and the JWE key endpoint from the base URL; the client fetched and cached an OAuth 2.0 access token before the call; a unique `X-Request-ID` header was generated for the request.

`EgwClient` is immutable and safe to share; create it once and reuse it (the OAuth token cache is thread-safe). `close()` only matters if you enabled the webhook listener.

Amounts are **decimal strings** (`"100.00"`), currencies ISO 4217 alpha-3. For test cards and magic values, see [Sandbox test data](/guides/sandbox.md).

## Customizing the client

The factory accepts optional replacements before `createEgwClient()`:

* `connectingWith(ApiClient)` — you may supply your own HTTP client implementation.
* `loggingWith(EgwLogger)` — plug in your logging; the default logger is silent. See the warning in [Security mechanics](/integration/api-client-sdk/guides/security-mechanics.md#logging) before enabling logging in production.
* `listeningAt(URI)` / `listeningWith(ApiServer)` — enable the webhook listener; see [Security mechanics](/integration/api-client-sdk/guides/security-mechanics.md#webhook-notifications).

Infrastructure adapters (HTTP, serializer, encrypter) can also be replaced application-wide via Java `ServiceLoader` providers (`ApiClientProvider`, `SerializerProvider`, `DataEncrypterProvider`, `EgwLoggerProvider` in `…bootstrap.spi`). See [Overriding SDK adapters](/integration/api-client-sdk/guides/overriding-sdk-adapters.md) for a full walkthrough.

## Next steps

* [Security mechanics](/integration/api-client-sdk/guides/security-mechanics.md) — card encryption for card checkout sessions, webhooks.
* [Error handling](/integration/api-client-sdk/guides/error-handling.md) — the exception hierarchy and retry guidance.


---

# 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/integration/api-client-sdk/quickstarts/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.
