Documentation for a newer release is available. View Latest
Esta página no está disponible actualmente en Español. Si lo necesita, póngase en contacto con el servicio de asistencia de Icon (correo electrónico)

Payment Adjustment

The Payment Adjustment artefacts contain a set of Connectors to enable a sending application to connect with your payment adjustment processing applications, as well as performing configurable validation on the adjustment requests.

The Payment Adjustment artefacts alone are not enough to have a functioning payment adjustment service. The artefacts provide connectivity and validation; however, the implementation is not defined. Once you’ve got set up (see Getting Started), you’ll need to consider how you will implement a Payment Adjustment service.

An interface of PaymentAdjustmentPort is provided by all Server Connectors. This has a sole method of process(PaymentCancellationRequest). You’ll have to implement this interface, and in the implementation hook-in the entrypoint to your Payment Adjustment flow.

An example implementation of PaymentAdjustmentPort is below, with fictional MPS-generated objects InitiateCancelTransactionInput and PaymentAdjustmentDomain to illustrate how you could hook this into a flow.

import com.iconsolutions.ipf.payments.adjustment.server.common.PaymentAdjustmentPort;
import com.iconsolutions.ipf.payments.api.model.PaymentCancellationRequest;
import lombok.extern.slf4j.Slf4j;
import paymentadjustment.domain.PaymentAdjustmentDomain;
import paymentadjustment.inputs.InitiateCancelTransactionInput;

import java.util.concurrent.CompletionStage;

@Slf4j
public class PaymentAdjustmentAdapter implements PaymentAdjustmentPort {

    @Override
    public CompletionStage<Void> process(PaymentCancellationRequest paymentCancellationRequest) {
        var processingContext = paymentCancellationRequest.getProcessingContext();

        var cancelTransactionInput = new InitiateCancelTransactionInput
                .Builder(processingContext.getUnitOfWorkId().getValue())
                .withCustomerPaymentCancellationRequest(paymentCancellationRequest.getPayload().getContent())
                .withProcessingContext(paymentCancellationRequest.getProcessingContext())
                .build();

        return PaymentAdjustmentDomain.initiation()
                .handle(cancelTransactionInput)
                .thenAccept(done -> log.info("Completed cancel transaction flow with id: {}", cancelTransactionInput.getId()));

    }
}