Search in sources :

Example 1 with AuthorisationStatusResponse

use of net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse in project styx by petafuel.

the class ConsentAuthorisationResource method getScaStatus.

@AcceptsPreStepAuth
@GET
@Path("/consents/{consentId}/authorisations/{authorisationId}")
public Response getScaStatus(@NotEmpty @NotBlank @PathParam("consentId") String consentId, @NotEmpty @NotBlank @PathParam("authorisationId") String authorisationId) throws BankRequestFailedException {
    consentId = Sanitizer.replaceEscSeq(consentId);
    authorisationId = Sanitizer.replaceEscSeq(authorisationId);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setConsentId(consentId);
    xs2AFactoryInput.setAuthorisationId(authorisationId);
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCARequest getAuthorisationStatusRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStatus(), xs2AFactoryInput);
    getAuthorisationStatusRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(getAuthorisationStatusRequest, xs2AFactoryInput);
    SCA.Status authorisationStatus = getXS2AStandard().getCs().getSCAStatus(getAuthorisationStatusRequest);
    AuthorisationStatusResponse response = new AuthorisationStatusResponse();
    response.setScaStatus(authorisationStatus.getValue());
    LOG.info("Consent Authorisation Status requested for consentId={} authorisationId={} scaStatus={}", consentId, authorisationId, authorisationStatus.getValue());
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : SCA(net.petafuel.styx.core.xs2a.entities.SCA) SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) GET(javax.ws.rs.GET)

Example 2 with AuthorisationStatusResponse

use of net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse in project styx by petafuel.

the class PaymentAuthorisationResource method getScaStatus.

/**
 * PIS - Get authorisation SCA status
 *
 * @param paymentTypeBean
 * @param paymentId
 * @param authorisationId
 * @return
 * @throws BankRequestFailedException
 */
@AcceptsPreStepAuth
@GET
@Path("/{paymentService}/{paymentProduct}/{paymentId}/authorisations/{authorisationId}")
public Response getScaStatus(@BeanParam PaymentTypeBean paymentTypeBean, @NotEmpty @NotBlank @PathParam("paymentId") String paymentId, @NotEmpty @NotBlank @PathParam("authorisationId") String authorisationId) throws BankRequestFailedException {
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPaymentService(paymentTypeBean.getPaymentService());
    xs2AFactoryInput.setPaymentProduct(paymentTypeBean.getPaymentProduct());
    xs2AFactoryInput.setPaymentId(paymentId);
    xs2AFactoryInput.setAuthorisationId(authorisationId);
    xs2AFactoryInput.setPsu(getPsu());
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCARequest getAuthorisationStatusRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStatus(), xs2AFactoryInput);
    getAuthorisationStatusRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(getAuthorisationStatusRequest, xs2AFactoryInput);
    SCA.Status authorisationStatus = getXS2AStandard().getPis().getSCAStatus(getAuthorisationStatusRequest);
    AuthorisationStatusResponse response = new AuthorisationStatusResponse();
    response.setScaStatus(authorisationStatus.getValue());
    LOG.info("Successfully fetched Authorisation status for payment={}, authorisationId={}", paymentId, authorisationId);
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : SCA(net.petafuel.styx.core.xs2a.entities.SCA) SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 3 with AuthorisationStatusResponse

use of net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse in project styx by petafuel.

the class ConsentResourcesFiduciaTest method E_checkScaStatus.

/**
 * SCA Status request for fiducia can only be made before the sca is finalised, afterwards this results in a 404 unknown resource
 *
 * @throws IOException
 */
@Test
@Category(IntegrationTest.class)
public void E_checkScaStatus() throws IOException {
    AuthorisationStatusResponse response = getStatusAuthorisation();
    Assertions.assertEquals(SCA.Status.PSUAUTHENTICATED.getValue(), response.getScaStatus());
}
Also used : AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 4 with AuthorisationStatusResponse

use of net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse in project styx by petafuel.

the class ConsentResourcesTargoTest method H_checkScaStatus.

@Test
@Category(IntegrationTest.class)
public void H_checkScaStatus() throws IOException {
    AuthorisationStatusResponse response = getStatusAuthorisation();
    Assertions.assertEquals(SCA.Status.FINALISED.getValue(), response.getScaStatus());
}
Also used : AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 5 with AuthorisationStatusResponse

use of net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse in project styx by petafuel.

the class SinglePaymentAuthorisationResourceTargoTest method F_getAuthorisationStatus_Targo.

@Test
@Category(IntegrationTest.class)
public void F_getAuthorisationStatus_Targo() {
    Invocation.Builder invocationBuilder = target("/v1/payments/sepa-credit-transfers/" + paymentId + "/authorisations/" + authorisationId).request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSD2TEST2");
    invocationBuilder.header("PSU-BIC", "CMCIDEDD");
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    invocationBuilder.header("X-STYX-X-bvpsd2-test-apikey", "tUfZ5KOHRTFrikZUsmSMUabKw09UIzGE");
    Invocation invocation = invocationBuilder.buildGet();
    AuthorisationStatusResponse response = invocation.invoke(AuthorisationStatusResponse.class);
    Assertions.assertNotNull(response.getScaStatus());
    Assertions.assertEquals(SCA.Status.FINALISED.getValue(), response.getScaStatus());
}
Also used : AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) Invocation(javax.ws.rs.client.Invocation) Category(org.junit.experimental.categories.Category) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Aggregations

AuthorisationStatusResponse (net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse)5 IntegrationTest (net.petafuel.styx.api.IntegrationTest)3 Test (org.junit.Test)3 Category (org.junit.experimental.categories.Category)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)2 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)2 SCARequest (net.petafuel.styx.core.xs2a.contracts.SCARequest)2 SCA (net.petafuel.styx.core.xs2a.entities.SCA)2 SCARequestFactory (net.petafuel.styx.core.xs2a.factory.SCARequestFactory)2 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)2 ApplicationPath (javax.ws.rs.ApplicationPath)1 Invocation (javax.ws.rs.client.Invocation)1 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)1