Aggregating Payment Information
Payment information (Initiation, Instruction and Transaction details) is initially stored by a processing flow. Any subsequent cancellations/changes of payment details won’t update the original entry, but instead, inserts a new one with the updated details. This means that storage doesn’t hold a singular version of an up-to-date payment information entry, with all the adjustments applied. Merging of related information is performed on the read-side, when fetching the stored payment information.
| Payment Datasource implementation is responsible for applying any additional adjustments being made to the initially stored payment information. |
Payment Warehouse Datasource information aggregation
Default Payment Datasource implementation reads the data from the Payment Warehouse. To observe how the merging works, we can use an Instruction Payment Entry example.
When a processing flow initially stores details about a Payment Instruction, it will create a PaymentEntry object and store it the Warehouse.
{
"_id" : "BatchInitiation|6e6cf57a-7201-43db-b9db-a8c33e3a0b19|0",
"unitOfWorkId" : "f4c5d646-fe8e-4586-bf32-496ce8814344",
"relatedUnitOfWork" : "63051ca7-3592-40b1-a5d2-b7e69e602b8d",
"clientRequestId" : "ac541cde-00fc-427f-be5f-23c2f091718e-filehappy",
"associationId" : "BatchInitiation|6e6cf57a-7201-43db-b9db-a8c33e3a0b19",
"processingEntity" : "BANK_ENTITY_1",
"sequence" : 0,
"globalState" : "PENDING",
"type" : BULK
"data" : [
{
"objectId" : "5945909f-0cfc-43f8-a28d-b92d1823e6a9",
"parentObjectId" : "2c235f35-b6b2-414a-a298-caf86f1e4e45",
"name" : "Pain001Instruction",
"category" : "MDS",
"contentType" : "com.iconsolutions.iso20022.message.components.payment_instruction.payment_instruction30.PaymentInstruction30",
"content" : "{.......}"
}
],
"_class" : "com.iconsolutions.ipf.warehouse.port.mongo.repository.MongoPaymentEntry"
}
Any subsequent change (data adjustment or cancellation) will result in storing an additional PaymentEntry object, which will have the identical unitOfWorkId value as the initial PaymentEntry object, and will have its sequence value increased by one.
{
"_id" : "BatchInitiation|6e6cf57a-7201-43db-b9db-a8c33e3a0b19|1",
"unitOfWorkId" : "f4c5d646-fe8e-4586-bf32-496ce8814344",
........
"sequence" : 1,
"globalState" : "CANCELLED"
}
PaymentWarehouseDataSource encapsulates the logic for applying additional Instruction PaymentEntry adjustments in a functional interface defined as:
Function<List<PaymentEntry>, PaymentWarehouseInstruction> instructionAggregatorFunction
In a similar fashion, there are also functional interfaces for Initiation and Transaction information aggregation:
-
Function<List<PaymentEntry>, PaymentWarehouseInitiation> initationAggregatorFunction, and -
Function<List<PaymentEntry>, PaymentWarehouseTransaction> transactionAggregatorFunction