Skip to content

mollie/mollie-api-java

Repository files navigation

mollie-api-java

Developer-friendly & type-safe Java SDK specifically catered to leverage mollie-api-java API.

Migration

This documentation is for the new Mollie's SDK. You can find more details on how to migrate from the old version to the new one here.

Summary

Table of Contents

SDK Installation

Getting started

JDK 11 or later is required.

The samples below show how a published SDK artifact is used:

Gradle:

implementation 'com.mollie:mollie:0.13.3'

Maven:

<dependency>
    <groupId>com.mollie</groupId>
    <artifactId>mollie</artifactId>
    <version>0.13.3</version>
</dependency>

How to build

After cloning the git repository to your file system you can build the SDK artifact from source to the build directory by running ./gradlew build on *nix systems or gradlew.bat on Windows systems.

If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):

On *nix:

./gradlew publishToMavenLocal -Pskip.signing

On Windows:

gradlew.bat publishToMavenLocal -Pskip.signing

SDK Example Usage

Example

package hello.world;

import com.mollie.mollie.Client;
import com.mollie.mollie.models.components.Security;
import com.mollie.mollie.models.errors.CreatePaymentPaymentsResponseBody;
import com.mollie.mollie.models.errors.CreatePaymentResponseBody;
import com.mollie.mollie.models.operations.*;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws CreatePaymentResponseBody, CreatePaymentPaymentsResponseBody, Exception {

        Client sdk = Client.builder()
                .security(Security.builder()
                    .apiKey(System.getenv().getOrDefault("API_KEY", ""))
                    .build())
            .build();

        CreatePaymentResponse res = sdk.payments().create()
                .include(Include.DETAILS_QR_CODE)
                .requestBody(CreatePaymentRequestBody.builder()
                    .description("Chess Board")
                    .amount(Amount.builder()
                        .currency("EUR")
                        .value("10.00")
                        .build())
                    .redirectUrl("https://example.org/redirect")
                    .cancelUrl("https://example.org/cancel")
                    .webhookUrl("https://example.org/webhooks")
                    .lines(List.of(
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build()))
                    .billingAddress(BillingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .shippingAddress(ShippingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .locale("en_US")
                    .method("ideal")
                    .issuer("ideal_INGBNL2A")
                    .restrictPaymentMethodsToCountry("NL")
                    .captureMode("manual")
                    .captureDelay("8 hours")
                    .applicationFee(ApplicationFee.builder()
                        .amount(CreatePaymentPaymentsAmount.builder()
                            .currency("EUR")
                            .value("10.00")
                            .build())
                        .description("10")
                        .build())
                    .routing(List.of(
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build(),
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build()))
                    .sequenceType("oneoff")
                    .mandateId("mdt_5B8cwPMGnU")
                    .customerId("cst_5B8cwPMGnU")
                    .profileId("pfl_5B8cwPMGnU")
                    .dueDate("2025-01-01")
                    .testmode(false)
                    .build())
                .call();

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

Name Type Scheme
apiKey http HTTP Bearer
oAuth oauth2 OAuth2 token

You can set the security parameters through the security builder method when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:

package hello.world;

import com.mollie.mollie.Client;
import com.mollie.mollie.models.components.Security;
import com.mollie.mollie.models.errors.CreatePaymentPaymentsResponseBody;
import com.mollie.mollie.models.errors.CreatePaymentResponseBody;
import com.mollie.mollie.models.operations.*;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws CreatePaymentResponseBody, CreatePaymentPaymentsResponseBody, Exception {

        Client sdk = Client.builder()
                .security(Security.builder()
                    .apiKey(System.getenv().getOrDefault("API_KEY", ""))
                    .build())
            .build();

        CreatePaymentResponse res = sdk.payments().create()
                .include(Include.DETAILS_QR_CODE)
                .requestBody(CreatePaymentRequestBody.builder()
                    .description("Chess Board")
                    .amount(Amount.builder()
                        .currency("EUR")
                        .value("10.00")
                        .build())
                    .redirectUrl("https://example.org/redirect")
                    .cancelUrl("https://example.org/cancel")
                    .webhookUrl("https://example.org/webhooks")
                    .lines(List.of(
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build()))
                    .billingAddress(BillingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .shippingAddress(ShippingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .locale("en_US")
                    .method("ideal")
                    .issuer("ideal_INGBNL2A")
                    .restrictPaymentMethodsToCountry("NL")
                    .captureMode("manual")
                    .captureDelay("8 hours")
                    .applicationFee(ApplicationFee.builder()
                        .amount(CreatePaymentPaymentsAmount.builder()
                            .currency("EUR")
                            .value("10.00")
                            .build())
                        .description("10")
                        .build())
                    .routing(List.of(
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build(),
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build()))
                    .sequenceType("oneoff")
                    .mandateId("mdt_5B8cwPMGnU")
                    .customerId("cst_5B8cwPMGnU")
                    .profileId("pfl_5B8cwPMGnU")
                    .dueDate("2025-01-01")
                    .testmode(false)
                    .build())
                .call();

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Available Resources and Operations

Available methods
  • list - List capabilities
  • list - List payment chargebacks
  • get - Get payment chargeback
  • all - List all chargebacks
  • list - List clients
  • get - Get client
  • create - Create a delayed route
  • list - List payment routes
  • list - List invoices
  • get - Get invoice
  • list - List payment methods
  • all - List all payment methods
  • get - Get payment method
  • get - Get onboarding status
  • submit - Submit onboarding data
  • list - List permissions
  • get - Get permission
  • create - Create payment refund
  • list - List payment refunds
  • get - Get payment refund
  • cancel - Cancel payment refund
  • all - List all refunds
  • create - Create sales invoice
  • list - List sales invoices
  • get - Get sales invoice
  • update - Update sales invoice
  • delete - Delete sales invoice
  • create - Create subscription
  • list - List customer subscriptions
  • get - Get subscription
  • update - Update subscription
  • cancel - Cancel subscription
  • all - List all subscriptions
  • listPayments - List subscription payments
  • list - List terminals
  • get - Get terminal
  • get - Get a Webhook Event
  • create - Create a webhook
  • list - List all webhooks
  • update - Update a webhook
  • get - Get a webhook
  • delete - Delete a webhook
  • test - Test a webhook

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, you can provide a RetryConfig object through the retryConfig builder method:

package hello.world;

import com.mollie.mollie.Client;
import com.mollie.mollie.models.components.Security;
import com.mollie.mollie.models.errors.CreatePaymentPaymentsResponseBody;
import com.mollie.mollie.models.errors.CreatePaymentResponseBody;
import com.mollie.mollie.models.operations.*;
import com.mollie.mollie.utils.BackoffStrategy;
import com.mollie.mollie.utils.RetryConfig;
import java.lang.Exception;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class Application {

    public static void main(String[] args) throws CreatePaymentResponseBody, CreatePaymentPaymentsResponseBody, Exception {

        Client sdk = Client.builder()
                .security(Security.builder()
                    .apiKey(System.getenv().getOrDefault("API_KEY", ""))
                    .build())
            .build();

        CreatePaymentResponse res = sdk.payments().create()
                .retryConfig(RetryConfig.builder()
                    .backoff(BackoffStrategy.builder()
                        .initialInterval(1L, TimeUnit.MILLISECONDS)
                        .maxInterval(50L, TimeUnit.MILLISECONDS)
                        .maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
                        .baseFactor(1.1)
                        .jitterFactor(0.15)
                        .retryConnectError(false)
                        .build())
                    .build())
                .include(Include.DETAILS_QR_CODE)
                .requestBody(CreatePaymentRequestBody.builder()
                    .description("Chess Board")
                    .amount(Amount.builder()
                        .currency("EUR")
                        .value("10.00")
                        .build())
                    .redirectUrl("https://example.org/redirect")
                    .cancelUrl("https://example.org/cancel")
                    .webhookUrl("https://example.org/webhooks")
                    .lines(List.of(
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build()))
                    .billingAddress(BillingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .shippingAddress(ShippingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .locale("en_US")
                    .method("ideal")
                    .issuer("ideal_INGBNL2A")
                    .restrictPaymentMethodsToCountry("NL")
                    .captureMode("manual")
                    .captureDelay("8 hours")
                    .applicationFee(ApplicationFee.builder()
                        .amount(CreatePaymentPaymentsAmount.builder()
                            .currency("EUR")
                            .value("10.00")
                            .build())
                        .description("10")
                        .build())
                    .routing(List.of(
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build(),
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build()))
                    .sequenceType("oneoff")
                    .mandateId("mdt_5B8cwPMGnU")
                    .customerId("cst_5B8cwPMGnU")
                    .profileId("pfl_5B8cwPMGnU")
                    .dueDate("2025-01-01")
                    .testmode(false)
                    .build())
                .call();

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

If you'd like to override the default retry strategy for all operations that support retries, you can provide a configuration at SDK initialization:

package hello.world;

import com.mollie.mollie.Client;
import com.mollie.mollie.models.components.Security;
import com.mollie.mollie.models.errors.CreatePaymentPaymentsResponseBody;
import com.mollie.mollie.models.errors.CreatePaymentResponseBody;
import com.mollie.mollie.models.operations.*;
import com.mollie.mollie.utils.BackoffStrategy;
import com.mollie.mollie.utils.RetryConfig;
import java.lang.Exception;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class Application {

    public static void main(String[] args) throws CreatePaymentResponseBody, CreatePaymentPaymentsResponseBody, Exception {

        Client sdk = Client.builder()
                .retryConfig(RetryConfig.builder()
                    .backoff(BackoffStrategy.builder()
                        .initialInterval(1L, TimeUnit.MILLISECONDS)
                        .maxInterval(50L, TimeUnit.MILLISECONDS)
                        .maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
                        .baseFactor(1.1)
                        .jitterFactor(0.15)
                        .retryConnectError(false)
                        .build())
                    .build())
                .security(Security.builder()
                    .apiKey(System.getenv().getOrDefault("API_KEY", ""))
                    .build())
            .build();

        CreatePaymentResponse res = sdk.payments().create()
                .include(Include.DETAILS_QR_CODE)
                .requestBody(CreatePaymentRequestBody.builder()
                    .description("Chess Board")
                    .amount(Amount.builder()
                        .currency("EUR")
                        .value("10.00")
                        .build())
                    .redirectUrl("https://example.org/redirect")
                    .cancelUrl("https://example.org/cancel")
                    .webhookUrl("https://example.org/webhooks")
                    .lines(List.of(
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build()))
                    .billingAddress(BillingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .shippingAddress(ShippingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .locale("en_US")
                    .method("ideal")
                    .issuer("ideal_INGBNL2A")
                    .restrictPaymentMethodsToCountry("NL")
                    .captureMode("manual")
                    .captureDelay("8 hours")
                    .applicationFee(ApplicationFee.builder()
                        .amount(CreatePaymentPaymentsAmount.builder()
                            .currency("EUR")
                            .value("10.00")
                            .build())
                        .description("10")
                        .build())
                    .routing(List.of(
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build(),
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build()))
                    .sequenceType("oneoff")
                    .mandateId("mdt_5B8cwPMGnU")
                    .customerId("cst_5B8cwPMGnU")
                    .profileId("pfl_5B8cwPMGnU")
                    .dueDate("2025-01-01")
                    .testmode(false)
                    .build())
                .call();

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.

By default, an API error will throw a models/errors/APIException exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the create method throws the following exceptions:

Error Type Status Code Content Type
models/errors/CreatePaymentResponseBody 422 application/hal+json
models/errors/CreatePaymentPaymentsResponseBody 503 application/hal+json
models/errors/APIException 4XX, 5XX */*

Example

package hello.world;

import com.mollie.mollie.Client;
import com.mollie.mollie.models.components.Security;
import com.mollie.mollie.models.errors.CreatePaymentPaymentsResponseBody;
import com.mollie.mollie.models.errors.CreatePaymentResponseBody;
import com.mollie.mollie.models.operations.*;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws CreatePaymentResponseBody, CreatePaymentPaymentsResponseBody, Exception {

        Client sdk = Client.builder()
                .security(Security.builder()
                    .apiKey(System.getenv().getOrDefault("API_KEY", ""))
                    .build())
            .build();

        CreatePaymentResponse res = sdk.payments().create()
                .include(Include.DETAILS_QR_CODE)
                .requestBody(CreatePaymentRequestBody.builder()
                    .description("Chess Board")
                    .amount(Amount.builder()
                        .currency("EUR")
                        .value("10.00")
                        .build())
                    .redirectUrl("https://example.org/redirect")
                    .cancelUrl("https://example.org/cancel")
                    .webhookUrl("https://example.org/webhooks")
                    .lines(List.of(
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build()))
                    .billingAddress(BillingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .shippingAddress(ShippingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .locale("en_US")
                    .method("ideal")
                    .issuer("ideal_INGBNL2A")
                    .restrictPaymentMethodsToCountry("NL")
                    .captureMode("manual")
                    .captureDelay("8 hours")
                    .applicationFee(ApplicationFee.builder()
                        .amount(CreatePaymentPaymentsAmount.builder()
                            .currency("EUR")
                            .value("10.00")
                            .build())
                        .description("10")
                        .build())
                    .routing(List.of(
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build(),
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build()))
                    .sequenceType("oneoff")
                    .mandateId("mdt_5B8cwPMGnU")
                    .customerId("cst_5B8cwPMGnU")
                    .profileId("pfl_5B8cwPMGnU")
                    .dueDate("2025-01-01")
                    .testmode(false)
                    .build())
                .call();

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Server Selection

Override Server URL Per-Client

The default server can be overridden globally using the .serverURL(String serverUrl) builder method when initializing the SDK client instance. For example:

package hello.world;

import com.mollie.mollie.Client;
import com.mollie.mollie.models.components.Security;
import com.mollie.mollie.models.errors.CreatePaymentPaymentsResponseBody;
import com.mollie.mollie.models.errors.CreatePaymentResponseBody;
import com.mollie.mollie.models.operations.*;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws CreatePaymentResponseBody, CreatePaymentPaymentsResponseBody, Exception {

        Client sdk = Client.builder()
                .serverURL("https://api.mollie.com/v2")
                .security(Security.builder()
                    .apiKey(System.getenv().getOrDefault("API_KEY", ""))
                    .build())
            .build();

        CreatePaymentResponse res = sdk.payments().create()
                .include(Include.DETAILS_QR_CODE)
                .requestBody(CreatePaymentRequestBody.builder()
                    .description("Chess Board")
                    .amount(Amount.builder()
                        .currency("EUR")
                        .value("10.00")
                        .build())
                    .redirectUrl("https://example.org/redirect")
                    .cancelUrl("https://example.org/cancel")
                    .webhookUrl("https://example.org/webhooks")
                    .lines(List.of(
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build(),
                        Lines.builder()
                            .description("LEGO 4440 Forest Police Station")
                            .quantity(1L)
                            .unitPrice(UnitPrice.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .totalAmount(TotalAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .quantityUnit("pcs")
                            .discountAmount(DiscountAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .vatRate("21.00")
                            .vatAmount(VatAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .sku("9780241661628")
                            .categories(List.of(
                                Categories.MEAL,
                                Categories.ECO))
                            .imageUrl("https://...")
                            .productUrl("https://...")
                            .recurring(Recurring.builder()
                                .interval("12 months")
                                .description("Gym subscription")
                                .amount(CreatePaymentAmount.builder()
                                    .currency("EUR")
                                    .value("10.00")
                                    .build())
                                .times(1L)
                                .startDate("2024-12-12")
                                .build())
                            .build()))
                    .billingAddress(BillingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .shippingAddress(ShippingAddress.builder()
                        .title("Mr.")
                        .givenName("Piet")
                        .familyName("Mondriaan")
                        .organizationName("Mollie B.V.")
                        .streetAndNumber("Keizersgracht 126")
                        .streetAdditional("Apt. 1")
                        .postalCode("1234AB")
                        .email("[email protected]")
                        .phone("31208202070")
                        .city("Amsterdam")
                        .region("Noord-Holland")
                        .country("NL")
                        .build())
                    .locale("en_US")
                    .method("ideal")
                    .issuer("ideal_INGBNL2A")
                    .restrictPaymentMethodsToCountry("NL")
                    .captureMode("manual")
                    .captureDelay("8 hours")
                    .applicationFee(ApplicationFee.builder()
                        .amount(CreatePaymentPaymentsAmount.builder()
                            .currency("EUR")
                            .value("10.00")
                            .build())
                        .description("10")
                        .build())
                    .routing(List.of(
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build(),
                        Routing.builder()
                            .amount(CreatePaymentPaymentsRequestAmount.builder()
                                .currency("EUR")
                                .value("10.00")
                                .build())
                            .destination(Destination.builder()
                                .type("organization")
                                .organizationId("org_1234567")
                                .build())
                            .links(Links.builder()
                                .self(Self.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .payment(Payment.builder()
                                    .href("https://...")
                                    .type("application/hal+json")
                                    .build())
                                .build())
                            .releaseDate("2024-12-12")
                            .build()))
                    .sequenceType("oneoff")
                    .mandateId("mdt_5B8cwPMGnU")
                    .customerId("cst_5B8cwPMGnU")
                    .profileId("pfl_5B8cwPMGnU")
                    .dueDate("2025-01-01")
                    .testmode(false)
                    .build())
                .call();

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Debugging

Debug

You can setup your SDK to emit debug logs for SDK requests and responses.

For request and response logging (especially json bodies), call enableHTTPDebugLogging(boolean) on the SDK builder like so:

SDK.builder()
    .enableHTTPDebugLogging(true)
    .build();

Example output:

Sending request: http://localhost:35123/bearer#global GET
Request headers: {Accept=[application/json], Authorization=[******], Client-Level-Header=[added by client], Idempotency-Key=[some-key], x-speakeasy-user-agent=[speakeasy-sdk/java 0.0.1 internal 0.1.0 org.openapis.openapi]}
Received response: (GET http://localhost:35123/bearer#global) 200
Response headers: {access-control-allow-credentials=[true], access-control-allow-origin=[*], connection=[keep-alive], content-length=[50], content-type=[application/json], date=[Wed, 09 Apr 2025 01:43:29 GMT], server=[gunicorn/19.9.0]}
Response body:
{
  "authenticated": true, 
  "token": "global"
}

WARNING: This should only used for temporary debugging purposes. Leaving this option on in a production system could expose credentials/secrets in logs. Authorization headers are redacted by default and there is the ability to specify redacted header names via SpeakeasyHTTPClient.setRedactedHeaders.

NOTE: This is a convenience method that calls HTTPClient.enableDebugLogging(). The SpeakeasyHTTPClient honors this setting. If you are using a custom HTTP client, it is up to the custom client to honor this setting.

Another option is to set the System property -Djdk.httpclient.HttpClient.log=all. However, this second option does not log bodies.

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

About

Mollie's SDK for Java (beta version)

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages