Processing Request Creator
Processing Request Creator is a part of the Payment Entries Processor whose role is to build a valid request, ready for processing. Request implementation could be either a Payment Request (used for sending to Execution) or a Cancel Request (used for ensuring a Payment is marked as cancelled).
The Processing Request Creator has the following data points on which to build a Request:
-
Initiation
-
Instruction
-
Transaction
-
Supporting data required for the execution service
The ProcessingRequestCreator interface does not specify how the Request being built should look.
It is left to the implementation class to define how the Request should look and what data it should contain.
Example Request Creator implementations
It is possible to consider how an implementation might look, when releasing or cancelling a payment.
Example Payment Request Creator
If we are releasing a payment, we might define something similar to this:
package com.iconsolutions.ipf.core.releaser;
import com.iconsolutions.ipf.core.releaser.service.release.ProcessingRequestCreator;
import com.iconsolutions.ipf.core.shared.api.Payload;
import com.iconsolutions.ipf.core.shared.api.Version;
import com.iconsolutions.ipf.core.shared.domain.context.SupportingContext;
import com.iconsolutions.ipf.payments.credittransfer.executepayment.api.ExecutePaymentRequest;
import com.iconsolutions.iso20022.message.components.credit_transfer.credit_transfer_transaction34.CreditTransferTransaction34;
import com.iconsolutions.iso20022.message.components.payment_instruction.payment_instruction30.PaymentInstruction30;
import com.iconsolutions.iso20022.message.definitions.payments_clearing_and_settlement.pacs008.FIToFICustomerCreditTransferV08;
import com.iconsolutions.iso20022.message.definitions.payments_initiation.pain001.CustomerCreditTransferInitiationV09;
import java.time.Instant;
public class ExamplePaymentRequestCreator implements ProcessingRequestCreator<ExamplePaymentInitiation, ExamplePaymentInstruction, ExamplePaymentTransaction, ExecutePaymentRequest> {
private static final Version VERSION = new Version(1, 0, 0);
@Override
public ExecutePaymentRequest create(ExamplePaymentInitiation paymentInitiation, ExamplePaymentInstruction paymentInstruction, ExamplePaymentTransaction transaction, SupportingContext supportingDataForExecutionOperation) {
var processingContext = transaction.getProcessingContext();
var requestId = processingContext.getClientRequestId().getValue();
var customBusinessData = SupportingContext.empty();
FIToFICustomerCreditTransferV08 fiToFICustomerCreditTransferV08 = preparePayload(paymentInitiation.getPayload(), paymentInstruction.getPayload(), transaction.getPayload());
return ExecutePaymentRequest.builder()
.requestId(requestId)
.processingContext(processingContext)
.version(VERSION)
.createdAt(Instant.now())
.customBusinessData(customBusinessData)
.payload(new Payload<>(fiToFICustomerCreditTransferV08, VERSION))
.build();
}
private FIToFICustomerCreditTransferV08 preparePayload(CustomerCreditTransferInitiationV09 customerCreditTransferInitiation,
PaymentInstruction30 paymentInstruction,
CreditTransferTransaction34 transaction) {
// payload preparation here, using the parameters supplied for execution
return FIToFICustomerCreditTransferV08.builder()
.build();
}
}
This example represents creating a valid ISO 20022 ExecutePaymentRequest class (Pacs008 message).
Example Payment Cancel Creator
If we are cancelling a payment, we might define something similar to this:
package com.iconsolutions.ipf.core.releaser;
import com.iconsolutions.ipf.core.releaser.service.release.ProcessingRequestCreator;
import com.iconsolutions.ipf.core.shared.domain.context.SupportingContext;
public class ExampleCancelRequestCreator implements ProcessingRequestCreator<ExamplePaymentInitiation, ExamplePaymentInstruction, ExamplePaymentTransaction, InitCancellationFlowRequest> {
@Override
public InitCancellationFlowRequest create(ExamplePaymentInitiation paymentInitiation, ExamplePaymentInstruction paymentInstruction, ExamplePaymentTransaction transaction, SupportingContext supportingDataForExecutionOperation) {
return InitCancellationFlowRequest.builder()
.unitOfWorkId(UnitOfWorkId.createRandom())
.build();
}
}
package com.iconsolutions.ipf.core.releaser;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
@Getter
@Builder
public class InitCancellationFlowRequest {
private UnitOfWorkId unitOfWorkId;
}
This example represents an ExampleCancelRequestCreator creator, which is supplied with a InitCancellationFlowRequest payload.