Payment Warehouse

The IPF Payment Warehouse is an interface designed for storing and querying data related to scheduled payments. It enables the storage of payments created in the present but scheduled for processing at a later time.

The Payment Warehouse operates as a MongoDB (including support for Azure Cosmos for MongoDB) collection interface, facilitating the storage of payment details in various forms, including Bulk, Batch, and Transaction.

Core Features

  • Storage: Capable of storing detailed payment information.

  • Querying: Provides methods for retrieving and managing stored payments.

  • Purging: Provides configuration for purging stored payment information

API Overview

The Payment Warehouse API includes the following core methods:

package com.iconsolutions.ipf.core.warehouse.port;

import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
import com.iconsolutions.ipf.warehouse.PaymentEntry;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.Optional;

public interface PaymentWarehouse {

    Mono<PaymentEntry> save(PaymentEntry paymentEntry);
    Flux<PaymentEntry> findAllByUnitOfWorkId(UnitOfWorkId unitOfWorkId);
    Mono<Long> countRelatedUnitOfWorkIds(UnitOfWorkId unitOfWorkId);
    Flux<UnitOfWorkId> findRelatedUnitOfWorkIds(UnitOfWorkId unitOfWorkId, Pageable pageable);
    Flux<List<PaymentEntry>> findAllByUnitOfWorkIds(List<UnitOfWorkId> unitOfWorkIds);
    Flux<List<PaymentEntry>> findAllByRelatedUnitOfWorkId(UnitOfWorkId relatedUnitOfWorkId, Optional<UnitOfWorkId> offset);
    Mono<Void> markBatchAsDone(UnitOfWorkId unitOfWorkId);
}

Below is a detailed description of the methods provided by the API:

  • save: Persists payment data into the warehouse. Supports storing data for bulk, batch, and transaction processes.

  • findAllByUnitOfWorkId: Retrieves all payment entries associated with a specific UnitOfWorkId. Used to fetch the complete set of payment instructions for a given unit of work.

  • countRelatedUnitOfWorkIds: Returns the count of unique related unit of work IDs for a specified UnitOfWorkId. Useful for determining the extent of related units of work.

  • findRelatedUnitOfWorkIds: Retrieves a paginated list of related UnitOfWorkIds for a given UnitOfWorkId. Helps in navigating through related units of work, particularly in large datasets.

  • findAllByUnitOfWorkIds: Fetches payment entries corresponding to a list of UnitOfWorkIds. Retrieves transaction details for multiple units of work in a single call.

  • findAllByRelatedUnitOfWorkId: Fetches payment entries which are related to the same UnitOfWorkId. Payment entries with the same UnitOfWorkId are grouped in a List.

  • markBatchAsDone: Marks a specific Batch and it’s association Transactions as 'done'. Triggers any necessary housekeeping operations, such as removing no longer needed payment entries.

Methods findRelatedUnitOfWorkIds, findAllByUnitOfWorkIds, countRelatedUnitOfWorkIds are deprecated.

Payment Entry Structure

The PaymentEntry class represents the documents stored and queried by the Payment Warehouse:

package com.iconsolutions.ipf.core.warehouse;

import com.iconsolutions.ipf.core.shared.domain.context.ProcessingContext;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
import lombok.Builder;
import lombok.Data;

import java.time.Instant;
import java.util.List;

@Data
@Builder
public class PaymentEntry {
    private PaymentEntryId id;
    private ProcessingContext processingContext;
    private UnitOfWorkId relatedUnitOfWorkId;
    private String globalState;
    private PaymentEntryType type;
    private List<BusinessDataEntry> data;
    /**
     * TTL represents time in seconds after which the record will expire.
     * This field is unique to Azure CosmosDB (must be an int named ttl)
     */
    private Integer ttl;
    /**
     * Represents exact instant when this task is eligible for deletion.
     * MongoDB requires field to be date type.
     */
    private Instant expiryDate;
}

The BusinessDataEntry represents client specific business data:

package com.iconsolutions.ipf.core.warehouse;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class BusinessDataEntry {

    private String objectId;
    private String parentObjectId;
    private String name;
    private String version;
    private Category category;
    private Class<?> contentType;
    private String content;

    public enum Category {
        MDS, PDS, DOMAIN_EVENT;
    }
}

MongoDB Representation

The corresponding MongoDB representation of PaymentEntry is defined in the MongoPaymentEntry class:

package com.iconsolutions.ipf.core.warehouse.port.mongo.repository;

import lombok.Builder;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.Instant;
import java.util.List;

@Document(collection = "paymententries")
@Data
@Builder
public class MongoPaymentEntry {
    @Id
    private String id;
    private String unitOfWorkId;
    private String relatedUnitOfWork;
    private String clientRequestId;
    private String associationId;
    private String processingEntity;
    private Integer sequence;
    private String globalState;
    private String type;
    /**
     * TTL represents time in seconds after which the record will expire.
     * This field is unique to Azure CosmosDB (must be an int named "ttl")
     */
    private Integer ttl;
    /**
     * Represents exact instant when this task is eligible for deletion.
     * MongoDB requires field to be date type.
     */
    private Instant expiryDate;
    private List<MongoBusinessDataEntry> data;
}

The corresponding MongoDB representation of BusinessDataEntry is defined in the MongoBusinessDataEntry class:

package com.iconsolutions.ipf.core.warehouse.port.mongo.repository;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class MongoBusinessDataEntry {
    private String objectId;
    private String parentObjectId;
    private String name;
    private String version;
    private String category;
    private String contentType;
    private String content;
}