Search in sources :

Example 1 with PeriodicPaymentInitiation

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

the class SinglePaymentInitiationResourceTest method initiatePeriodicPayment_Consors.

@Test
@Category(IntegrationTest.class)
public void initiatePeriodicPayment_Consors() {
    Jsonb jsonb = JsonbBuilder.create();
    PeriodicPaymentInitiation periodicPaymentInitiation = jsonb.fromJson("{\"startDate\":\"" + currentDate + "\",\"dayOfExecution\":31,\"frequency\":\"MNTH\",\"executionRule\":\"following\",\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE60760300800500123456\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE15500105172295759744\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\",\"requestedExecutionDate\":\"" + currentDate + "\"}]}", PeriodicPaymentInitiation.class);
    Invocation.Builder invocationBuilder = target("/v1/periodic-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSU-Successful");
    invocationBuilder.header("PSU-BIC", "CSDBDE71");
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(periodicPaymentInitiation, MediaType.APPLICATION_JSON));
    Response response = invocation.invoke(Response.class);
    Assert.assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Jsonb(javax.json.bind.Jsonb) PeriodicPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.PeriodicPaymentInitiation) Invocation(javax.ws.rs.client.Invocation) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Example 2 with PeriodicPaymentInitiation

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

the class FetchSinglePaymentResourceTest method fetchPeriodicPayment.

@Test
@Category(IntegrationTest.class)
public void fetchPeriodicPayment() throws IOException {
    Invocation.Builder invocationBuilder = target("/v1/periodic-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSU-Successful");
    invocationBuilder.header("PSU-BIC", "CSDBDE71");
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    Jsonb jsonb = JsonbBuilder.create();
    PeriodicPaymentInitiation periodicPaymentInitiation = jsonb.fromJson("{\"startDate\":\"" + currentDate + "\",\"dayOfExecution\":31,\"frequency\":\"MNTH\",\"executionRule\":\"following\",\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE60760300800500123456\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE15500105172295759744\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\",\"requestedExecutionDate\":\"" + currentDate + "\"}]}", PeriodicPaymentInitiation.class);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(periodicPaymentInitiation, MediaType.APPLICATION_JSON));
    Response response = invocation.invoke(Response.class);
    Assertions.assertEquals(201, response.getStatus());
    PaymentResponse paymentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), PaymentResponse.class);
    Invocation getPayment = target("/v1/periodic-payments/sepa-credit-transfers/" + paymentResponse.getPaymentId()).request().header("token", pisAccessToken).header("PSU-ID", "PSU-Successful").header("PSU-BIC", "CSDBDE71").header("PSU-IP-Address", "192.168.8.78").header("redirectPreferred", true).buildGet();
    response = getPayment.invoke(Response.class);
    Assertions.assertEquals(200, response.getStatus());
}
Also used : PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse) Response(javax.ws.rs.core.Response) Jsonb(javax.json.bind.Jsonb) Invocation(javax.ws.rs.client.Invocation) PeriodicPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.PeriodicPaymentInitiation) InputStream(java.io.InputStream) PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse) Category(org.junit.experimental.categories.Category) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 3 with PeriodicPaymentInitiation

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

the class SinglePaymentStatusResourceTest method getSparkassePeriodicPaymentId.

private String getSparkassePeriodicPaymentId() {
    if (sparkassePeriodicPaymentId == null) {
        Jsonb jsonb = JsonbBuilder.create();
        PeriodicPaymentInitiation periodicPaymentInitiation = jsonb.fromJson("{\"endToEndIdentification\": \"endToEndId\", \"startDate\":\"" + currentDate + "\",\"dayOfExecution\":31,\"frequency\":\"MNTH\",\"executionRule\":\"following\",\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE86999999990000001000\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE75999999990000001004\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"}]}", PeriodicPaymentInitiation.class);
        Invocation.Builder invocationBuilder = target("/v1/periodic-payments/sepa-credit-transfers").request();
        invocationBuilder.header("token", pisAccessToken);
        invocationBuilder.header("PSU-ID", "PSU-1234");
        invocationBuilder.header("PSU-BIC", SPARKASSE_BIC);
        invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
        invocationBuilder.header("redirectPreferred", true);
        Invocation invocation = invocationBuilder.buildPost(Entity.entity(periodicPaymentInitiation, MediaType.APPLICATION_JSON));
        Response response = invocation.invoke(Response.class);
        try {
            PaymentResponse paymentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), PaymentResponse.class);
            sparkassePeriodicPaymentId = paymentResponse.getPaymentId();
        } catch (IOException e) {
            return "";
        }
    }
    return sparkassePeriodicPaymentId;
}
Also used : PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse) Response(javax.ws.rs.core.Response) Jsonb(javax.json.bind.Jsonb) PeriodicPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.PeriodicPaymentInitiation) Invocation(javax.ws.rs.client.Invocation) InputStream(java.io.InputStream) IOException(java.io.IOException) PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse)

Example 4 with PeriodicPaymentInitiation

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

the class PeriodicPaymentResourceRaiffeisenMSTest method A_initiatePeriodicPayment.

@Test
@Category(IntegrationTest.class)
public void A_initiatePeriodicPayment() {
    Invocation.Builder invocationBuilder = target("/v1/periodic-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", PSU_ID);
    invocationBuilder.header("PSU-BIC", BIC);
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    Jsonb jsonb = JsonbBuilder.create();
    String requestBody = "{\"startDate\":\"" + currentDate + "\",\"dayOfExecution\":31,\"frequency\":\"MNTH\",\"executionRule\":\"following\",\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"" + debtorIBAN + "\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"1.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"" + creditorIBAN + "\"},\"creditorName\":\"" + creditorName + "\",\"remittanceInformationUnstructured\":\"Test\",\"requestedExecutionDate\":\"" + currentDate + "\"}]}";
    PeriodicPaymentInitiation periodicPaymentInitiation = jsonb.fromJson(requestBody, PeriodicPaymentInitiation.class);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(periodicPaymentInitiation, MediaType.APPLICATION_JSON));
    PaymentResponse response = invocation.invoke(PaymentResponse.class);
    Assertions.assertNotNull(response.getPaymentId());
    paymentId = response.getPaymentId();
}
Also used : Jsonb(javax.json.bind.Jsonb) Invocation(javax.ws.rs.client.Invocation) PeriodicPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.PeriodicPaymentInitiation) PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Example 5 with PeriodicPaymentInitiation

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

the class SinglePaymentInitiationResourceTest method initiatePeriodicPayment_Targo.

@Test
@Category(IntegrationTest.class)
public void initiatePeriodicPayment_Targo() {
    Jsonb jsonb = JsonbBuilder.create();
    PeriodicPaymentInitiation periodicPaymentInitiation = jsonb.fromJson("{\"startDate\":\"" + currentDate + "\",\"dayOfExecution\":31,\"frequency\":\"MNTH\",\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE60760300800500123456\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE15500105172295759744\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\",\"requestedExecutionDate\":\"" + currentDate + "\"}]}", PeriodicPaymentInitiation.class);
    Invocation.Builder invocationBuilder = target("/v1/periodic-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSD2TEST4");
    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.buildPost(Entity.entity(periodicPaymentInitiation, MediaType.APPLICATION_JSON));
    Response response = invocation.invoke(Response.class);
    Assert.assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Jsonb(javax.json.bind.Jsonb) PeriodicPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.PeriodicPaymentInitiation) Invocation(javax.ws.rs.client.Invocation) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Aggregations

Jsonb (javax.json.bind.Jsonb)8 Invocation (javax.ws.rs.client.Invocation)8 PeriodicPaymentInitiation (net.petafuel.styx.api.v1.payment.entity.PeriodicPaymentInitiation)8 Response (javax.ws.rs.core.Response)6 IntegrationTest (net.petafuel.styx.api.IntegrationTest)6 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)6 PaymentResponse (net.petafuel.styx.api.v1.payment.entity.PaymentResponse)6 Test (org.junit.Test)6 Category (org.junit.experimental.categories.Category)6 InputStream (java.io.InputStream)3 IOException (java.io.IOException)2 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 ResponseEntity (net.petafuel.styx.api.exception.ResponseEntity)1 StyxException (net.petafuel.styx.api.exception.StyxException)1 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)1 AbstractTokenFilter (net.petafuel.styx.api.filter.authentication.control.AbstractTokenFilter)1 RequiresMandatoryHeader (net.petafuel.styx.api.filter.input.boundary.RequiresMandatoryHeader)1 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)1 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)1