class PaymentAuthorisationCancellationAspectService extends BaseAspectService<PaymentController> {

    public ResponseObject<CancellationAuthorisationResponse> createPisAuthorisationAspect(ResponseObject<CancellationAuthorisationResponse> result,
                                                                                          Xs2aCreatePisAuthorisationRequest request) {
        if (!result.hasError()) {

            CancellationAuthorisationResponse body = result.getBody();
            AuthorisationResponseType authorisationResponseType = body.getAuthorisationResponseType();

            if (authorisationResponseType == AuthorisationResponseType.START) {
                Xs2aCreatePisCancellationAuthorisationResponse response = (Xs2aCreatePisCancellationAuthorisationResponse) result.getBody();
                response.setLinks(new PisAuthorisationCancellationLinks(getHttpUrl(), scaApproachResolver, redirectLinkBuilder,
                                                                        redirectIdService, request.getPaymentService().getValue(),
                                                                        request.getPaymentProduct(), request.getPaymentId(),
                                                                        body.getAuthorisationId(), getScaRedirectFlow(), body.getInternalRequestId(),
                                                                        requestProviderService.getInstanceId()));
            } else if (authorisationResponseType == AuthorisationResponseType.UPDATE) {
                Xs2aUpdatePisCommonPaymentPsuDataResponse response = (Xs2aUpdatePisCommonPaymentPsuDataResponse) result.getBody();
                Xs2aUpdatePisCommonPaymentPsuDataRequest updateRequest = buildXs2aUpdatePisCommonPaymentPsuDataRequest(request.getPaymentId(),
                                                                                                                       response.getAuthorisationId(),
                                                                                                                       request.getPsuData(),
                                                                                                                       request.getPaymentProduct(),
                                                                                                                       request.getPaymentService(),
                                                                                                                       request.getPassword());
                response.setLinks(new UpdatePisCancellationPsuDataLinks(getHttpUrl(), scaApproachResolver, updateRequest,
                                                                        body.getScaStatus(), response.getChosenScaMethod()));
            } else {
                throw new IllegalArgumentException("Unknown authorisation response type: " + authorisationResponseType);
            }
        }
        return result;
    }

    @Autowired public  PaymentAuthorisationCancellationAspectService(ScaApproachResolver scaApproachResolver,
                                                         RedirectLinkBuilder redirectLinkBuilder, AspspProfileServiceWrapper aspspProfileServiceWrapper,
                                                         RedirectIdService redirectIdService, RequestProviderService requestProviderService);

}