Client Library
This section will guide you through how to connect to an external Payment Releaser via HTTP. The guide for setting up your Java application with the Payment Releaser exposed as an HTTP API is here.
Step 1: Add dependency
Add the ipf-payment-releaser-api-client-connector-http artefact to your pom.xml dependencies.
<dependency>
<groupId>com.iconsolutions.ipf.core.releaser</groupId>
<artifactId>ipf-payment-releaser-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.
Additionally, you can override the resiliency-settings.
These are the standard Connector resiliency settings found in Connector Configuration.
ipf.payment-releaser-api.connector {
http.client {
host = "localhost"
port = "8080"
}
resiliency-settings {
minimum-number-of-calls = 100
reroute-messages-on-failure = false
}
}
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: Release an Instruction(/Batch) via the Client Library
Your application is now ready to call the external HTTP API using the Client Library.
You can release a payment Instruction(/Batch) by using the releaseInstructionClientPort Spring Bean that was introduced by the Maven dependency in Step 1 and calling the respective methods in the class.
| Releasing a payment Instruction will only work if you have already saved the payment Instruction into your Payment Data Source, as the application can only release what it can retrieve. |
These methods are documented in the releaseInstructionClientPort interface.
package com.iconsolutions.ipf.releaser.api.client.port;
import com.iconsolutions.ipf.core.connector.api.Response;
import com.iconsolutions.ipf.core.shared.domain.context.ProcessingContext;
import com.iconsolutions.ipf.core.shared.domain.context.SupportingContext;
import jakarta.validation.constraints.NotNull;
import java.util.concurrent.CompletionStage;
public interface ReleaseInstructionClientPort {
default CompletionStage<Response<Void>> releaseInstruction(
@NotNull ProcessingContext processingContext,
@NotNull String instructionUnitOfWorkID) {
return releaseInstruction(processingContext, SupportingContext.empty(), SupportingContext.empty(), instructionUnitOfWorkID);
}
CompletionStage<Response<Void>> releaseInstruction(
@NotNull ProcessingContext processingContext,
@NotNull SupportingContext supportingContext,
@NotNull SupportingContext supportingDataForReleaseOperation,
@NotNull String instructionUnitOfWorkID);
}
An example of saving a Payment Entry is provided below:
package com.iconsolutions.ipf.releaser.api.client.connector.http;
import com.iconsolutions.ipf.core.connector.api.Response;
import com.iconsolutions.ipf.core.releaser.model.SupportingBusinessDataMapForReleaseOperation;
import com.iconsolutions.ipf.core.shared.domain.context.ProcessingContext;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
import com.iconsolutions.ipf.releaser.api.client.port.ReleaseInstructionClientPort;
import lombok.RequiredArgsConstructor;
import java.util.concurrent.CompletionStage;
@RequiredArgsConstructor
public class ExampleReleaseViaConnector {
private final ReleaseInstructionClientPort releaseInstructionClientPort;
public CompletionStage<Response<Void>> releaseInstructionViaHttp(
ProcessingContext processingContext,
SupportingContext supportingContext,
SupportingContext supportingDataForReleaseOperation,
UnitOfWorkId instructionUnitOfWorkID) {
return releaseInstructionClientPort
.releaseInstruction(processingContext, supportingContext, supportingDataForReleaseOperation, instructionUnitOfWorkID.getValue());
}
}