Search in sources :

Example 1 with AuthorisationIdsResponse

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

the class PaymentAuthorisationResource method getAuthorisationIds.

/**
 * PIS - Fetch multiple SCAs for a payment
 *
 * @param paymentTypeBean
 * @param paymentId
 * @return
 * @throws BankRequestFailedException
 */
@AcceptsPreStepAuth
@GET
@Path("/{paymentService}/{paymentProduct}/{paymentId}/authorisations")
public Response getAuthorisationIds(@BeanParam PaymentTypeBean paymentTypeBean, @NotEmpty @NotBlank @PathParam("paymentId") String paymentId) throws BankRequestFailedException {
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPaymentService(paymentTypeBean.getPaymentService());
    xs2AFactoryInput.setPaymentProduct(paymentTypeBean.getPaymentProduct());
    xs2AFactoryInput.setPaymentId(paymentId);
    xs2AFactoryInput.setPsu(getPsu());
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    SCARequest getAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaRetrieval(), xs2AFactoryInput);
    getAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(getAuthorisationRequest, xs2AFactoryInput);
    List<String> authorisationIds = getXS2AStandard().getPis().getAuthorisations(getAuthorisationRequest);
    AuthorisationIdsResponse response = new AuthorisationIdsResponse();
    response.setAuthorisationIds(authorisationIds);
    LOG.info("Successfully fetched Authorisation ids for payment={}", paymentId);
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : SCARequest(net.petafuel.styx.core.xs2a.contracts.SCARequest) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) SCARequestFactory(net.petafuel.styx.core.xs2a.factory.SCARequestFactory) AuthorisationIdsResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationIdsResponse) 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 2 with AuthorisationIdsResponse

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

the class SinglePaymentAuthorisationResourceTargoTest method E_getAuthorisationIds_Targo.

@Test
@Category(IntegrationTest.class)
public void E_getAuthorisationIds_Targo() {
    Invocation.Builder invocationBuilder = target("/v1/payments/sepa-credit-transfers/" + paymentId + "/authorisations").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();
    AuthorisationIdsResponse response = invocation.invoke(AuthorisationIdsResponse.class);
    Assertions.assertNotNull(response.getAuthorisationIds());
    Assertions.assertTrue(response.getAuthorisationIds().size() > 0);
    authorisationId = response.getAuthorisationIds().get(0);
}
Also used : Invocation(javax.ws.rs.client.Invocation) AuthorisationIdsResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationIdsResponse) Category(org.junit.experimental.categories.Category) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Aggregations

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