@Test void resolveRedirectUrl() throws RedirectUrlIsExpiredException { when(referencePolicy.fromRequest(anyString(), anyString(), anyString(), anyBoolean())).thenReturn(getConsentReference()); when(cmsPsuPisService.checkRedirectAndGetPayment(anyString(), anyString())).thenReturn(getCmsPaymentResponse()); when(paymentMapper.toAbstractPayment(anyString(), anyString(), anyString())).thenReturn(getPaymentTO(ACCP)); when(cmsPsuPisService.getAuthorisationByAuthorisationId(anyString(), anyString())).thenReturn(geCmsPsuAuth(ScaStatus.FINALISED)); when(authService.resolveAuthConfirmationCodeRedirectUri(anyString(), anyString())).thenReturn("www.ok.ua"); String result = service.resolveRedirectUrl(ENCRYPTED_ID, AUTH_ID, COOKIE, false, PSU_ID, new BearerTokenTO(), ""); assertEquals(OK_REDIRECT_URI, result); }
@Override public String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode) { PaymentWorkflow workflow = identifyPayment(encryptedPaymentId, authorisationId, true, consentAndAccessTokenCookieString, psuId, tokenTO); CmsPaymentResponse consentResponse = workflow.getPaymentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = consentResponse.getTppNokRedirectUri(); ScaStatusTO scaStatus = loadAuthorization(workflow.authId()); return EnumSet.of(ScaStatusTO.FINALISED, ScaStatusTO.UNCONFIRMED, ScaStatusTO.EXEMPTED).contains(scaStatus) ? tppOkRedirectUri : tppNokRedirectUri; }
CommonPaymentServiceImpl implements CommonPaymentService { @Override public String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode) { PaymentWorkflow workflow = identifyPayment(encryptedPaymentId, authorisationId, true, consentAndAccessTokenCookieString, psuId, tokenTO); CmsPaymentResponse consentResponse = workflow.getPaymentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = consentResponse.getTppNokRedirectUri(); ScaStatusTO scaStatus = loadAuthorization(workflow.authId()); return EnumSet.of(ScaStatusTO.FINALISED, ScaStatusTO.UNCONFIRMED, ScaStatusTO.EXEMPTED).contains(scaStatus) ? tppOkRedirectUri : tppNokRedirectUri; } }
CommonPaymentServiceImpl implements CommonPaymentService { @Override public String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode) { PaymentWorkflow workflow = identifyPayment(encryptedPaymentId, authorisationId, true, consentAndAccessTokenCookieString, psuId, tokenTO); CmsPaymentResponse consentResponse = workflow.getPaymentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = consentResponse.getTppNokRedirectUri(); ScaStatusTO scaStatus = loadAuthorization(workflow.authId()); return EnumSet.of(ScaStatusTO.FINALISED, ScaStatusTO.UNCONFIRMED, ScaStatusTO.EXEMPTED).contains(scaStatus) ? tppOkRedirectUri : tppNokRedirectUri; }  }
CommonPaymentServiceImpl implements CommonPaymentService { @Override public String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode) { PaymentWorkflow workflow = identifyPayment(encryptedPaymentId, authorisationId, true, consentAndAccessTokenCookieString, psuId, tokenTO); CmsPaymentResponse consentResponse = workflow.getPaymentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = consentResponse.getTppNokRedirectUri(); ScaStatusTO scaStatus = loadAuthorization(workflow.authId()); return EnumSet.of(ScaStatusTO.FINALISED, ScaStatusTO.UNCONFIRMED, ScaStatusTO.EXEMPTED).contains(scaStatus) ? tppOkRedirectUri : tppNokRedirectUri; }  @Override PaymentWorkflow selectScaForPayment(String encryptedPaymentId, String authorisationId, String scaMethodId, String consentAndAccessTokenCookieString, boolean isCancellationOperation, String psuId, BearerTokenTO tokenTO); @Override PaymentWorkflow identifyPayment(String encryptedPaymentId, String authorizationId, boolean strict, String consentCookieString, String psuId, BearerTokenTO bearerToken); @Override void updateAspspConsentData(PaymentWorkflow paymentWorkflow); @Override String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode); @Override PaymentWorkflow initiatePayment(PaymentWorkflow paymentWorkflow, String psuId); @Override PaymentWorkflow initiateCancelPayment(PaymentWorkflow paymentWorkflow, String psuId); @Override PaymentWorkflow authorizePayment(PaymentWorkflow paymentWorkflow, String psuId, String authCode); @Override PaymentWorkflow authorizeCancelPayment(PaymentWorkflow paymentWorkflow, String psuId, String authCode); }
CommonPaymentServiceImpl implements CommonPaymentService { @Override public String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode) { PaymentWorkflow workflow = identifyPayment(encryptedPaymentId, authorisationId, true, consentAndAccessTokenCookieString, psuId, tokenTO); CmsPaymentResponse consentResponse = workflow.getPaymentResponse(); authInterceptor.setAccessToken(workflow.getScaResponse().getBearerToken().getAccess_token()); String tppOkRedirectUri = isOauth2Integrated ? oauthRestClient.oauthCode(consentResponse.getTppOkRedirectUri()).getBody().getRedirectUri() : authService.resolveAuthConfirmationCodeRedirectUri(consentResponse.getTppOkRedirectUri(), authConfirmationCode); String tppNokRedirectUri = consentResponse.getTppNokRedirectUri(); ScaStatusTO scaStatus = loadAuthorization(workflow.authId()); return EnumSet.of(ScaStatusTO.FINALISED, ScaStatusTO.UNCONFIRMED, ScaStatusTO.EXEMPTED).contains(scaStatus) ? tppOkRedirectUri : tppNokRedirectUri; }  @Override PaymentWorkflow selectScaForPayment(String encryptedPaymentId, String authorisationId, String scaMethodId, String consentAndAccessTokenCookieString, boolean isCancellationOperation, String psuId, BearerTokenTO tokenTO); @Override PaymentWorkflow identifyPayment(String encryptedPaymentId, String authorizationId, boolean strict, String consentCookieString, String psuId, BearerTokenTO bearerToken); @Override void updateAspspConsentData(PaymentWorkflow paymentWorkflow); @Override String resolveRedirectUrl(String encryptedPaymentId, String authorisationId, String consentAndAccessTokenCookieString, boolean isOauth2Integrated, String psuId, BearerTokenTO tokenTO, String authConfirmationCode); @Override PaymentWorkflow initiatePayment(PaymentWorkflow paymentWorkflow, String psuId); @Override PaymentWorkflow initiateCancelPayment(PaymentWorkflow paymentWorkflow, String psuId); @Override PaymentWorkflow authorizePayment(PaymentWorkflow paymentWorkflow, String psuId, String authCode); @Override PaymentWorkflow authorizeCancelPayment(PaymentWorkflow paymentWorkflow, String psuId, String authCode);  }