Client Library
This section will guide you through how to connect to an external Payment Warehouse via HTTP. The guide for setting up your Java application with the Payment Warehouse exposed as an HTTP API is here.
Only the save operation is currently accessible via the Client Library.
|
Step 1: Add dependency
Add the payment-warehouse-api-client-connector-http artefact to your pom.xml dependencies.
<dependency>
<groupId>com.iconsolutions.ipf.core.warehouse</groupId>
<artifactId>payment-warehouse-api-client-connector-http</artifactId>
</dependency>
Step 2: Configure
The API operations have configurable properties, namely the host and the port.
The reference configuration provides these as localhost and 8080 respectively.
For your implementation you will have to override these properties.
ipf.payment-warehouse-api.http.client {
host = "localhost"
port = "8080"
}
Step 3: Wire In Mandatory Spring Beans
You are required to have a Spring Bean present in your Java application of:
-
com.iconsolutions.ipf.core.messagelogger.MessageLogger -
akka.actor.ClassicActorSystemProvider
Step 4: Save a Payment Entry via the Client Library
Your application is now ready to call the external HTTP API using the Client Library.
You can do this by using the paymentWarehouseClientPort Spring Bean that was introduced by the Maven dependency in Step 1 and calling the respective methods in the class.
These methods are documented in the paymentWarehouseClientPort interface.
package com.iconsolutions.ipf.warehouse.client.port;
import com.iconsolutions.ipf.core.connector.api.Response;
import com.iconsolutions.ipf.core.shared.domain.context.ProcessingContext;
import com.iconsolutions.ipf.core.warehouse.model.PaymentEntryDto;
import jakarta.validation.constraints.NotNull;
import java.util.concurrent.CompletionStage;
@FunctionalInterface
public interface PaymentWarehouseClientPort {
CompletionStage<Response<PaymentEntryDto>> save(@NotNull ProcessingContext processingContext, @NotNull PaymentEntryDto paymentEntryDto);
}
An example of saving a Payment Entry is provided below:
package com.iconsolutions.ipf.core.warehouse.client.connector.http;
import com.iconsolutions.ipf.core.connector.api.Response;
import com.iconsolutions.ipf.core.shared.domain.context.ProcessingContext;
import com.iconsolutions.ipf.core.warehouse.model.PaymentEntryDto;
import com.iconsolutions.ipf.warehouse.client.port.PaymentWarehouseClientPort;
import lombok.RequiredArgsConstructor;
import java.util.concurrent.CompletionStage;
@RequiredArgsConstructor
public class ExampleSaveViaConnector {
private final PaymentWarehouseClientPort paymentWarehouseClientPort;
public CompletionStage<Response<PaymentEntryDto>> save(ProcessingContext processingContext, PaymentEntryDto paymentEntryDto) {
return paymentWarehouseClientPort.save(processingContext, paymentEntryDto);
}
}