Search in sources :

Example 1 with BulkPaymentInitiation

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

the class SinglePaymentInitiationResourceTest method initiateBulkPayment_Targo.

@Test
@Category(IntegrationTest.class)
public void initiateBulkPayment_Targo() {
    Jsonb jsonb = JsonbBuilder.create();
    BulkPaymentInitiation bulkPaymentInitiation = jsonb.fromJson("{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE60760300800500123456\"},\"requestedExecutionDate\":\"" + currentDate + "\",\"payments\":[{\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE15500105172295759744\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\",\"requestedExecutionDate\":\"" + currentDate + "\"},{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE60760300800500123456\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE15500105172295759744\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\",\"requestedExecutionDate\":\"" + currentDate + "\"}]}", BulkPaymentInitiation.class);
    Invocation.Builder invocationBuilder = target("/v1/bulk-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSU-Successful");
    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(bulkPaymentInitiation, 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) Invocation(javax.ws.rs.client.Invocation) BulkPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.BulkPaymentInitiation) 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 BulkPaymentInitiation

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

the class FetchSinglePaymentResourceTest method fetchBulkPayment.

@Test
@Category(IntegrationTest.class)
public void fetchBulkPayment() throws IOException {
    Invocation.Builder invocationBuilder = target("/v1/bulk-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSU-1234");
    invocationBuilder.header("PSU-BIC", "GENODEF1M03");
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    Jsonb jsonb = JsonbBuilder.create();
    BulkPaymentInitiation bulkPaymentInitiation = jsonb.fromJson("{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"},\"payments\":[{\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"},{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"32.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"Gimmeyourmoney\",\"remittanceInformationUnstructured\":\"Myothervwz\"}]}", BulkPaymentInitiation.class);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(bulkPaymentInitiation, 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/bulk-payments/sepa-credit-transfers/" + paymentResponse.getPaymentId()).request().header("token", pisAccessToken).header("PSU-ID", "PSU-1234").header("PSU-BIC", "GENODEF1M03").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) InputStream(java.io.InputStream) BulkPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.BulkPaymentInitiation) 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 BulkPaymentInitiation

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

the class SinglePaymentStatusResourceTest method getSparkasseBulkPaymentId.

private String getSparkasseBulkPaymentId() {
    if (sparkasseBulkPaymentId == null) {
        Invocation.Builder invocationBuilder = target("/v1/bulk-payments/sepa-credit-transfers").request();
        invocationBuilder.header("token", pisAccessToken);
        invocationBuilder.header("PSU-ID", "PSU-Successful");
        invocationBuilder.header("PSU-BIC", SPARKASSE_BIC);
        invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
        invocationBuilder.header("redirectPreferred", true);
        Jsonb jsonb = JsonbBuilder.create();
        BulkPaymentInitiation bulkPaymentInitiation = jsonb.fromJson("{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE86999999990000001000\", \"name\":\"NOTPROVIDED\"},\"payments\":[{\"endToEndIdentification\": \"endToEndId\", \"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE75999999990000001004\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"},{\"endToEndIdentification\": \"endToEndId\", \"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE86999999990000001000\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"32.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE75999999990000001004\"},\"creditorName\":\"Gimmeyourmoney\",\"remittanceInformationUnstructured\":\"Myothervwz\"}]}", BulkPaymentInitiation.class);
        Invocation invocation = invocationBuilder.buildPost(Entity.entity(bulkPaymentInitiation, MediaType.APPLICATION_JSON));
        Response response = invocation.invoke(Response.class);
        try {
            PaymentResponse paymentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), PaymentResponse.class);
            sparkasseBulkPaymentId = paymentResponse.getPaymentId();
        } catch (IOException e) {
            return "";
        }
    }
    return sparkasseBulkPaymentId;
}
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) InputStream(java.io.InputStream) BulkPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.BulkPaymentInitiation) IOException(java.io.IOException) PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse)

Example 4 with BulkPaymentInitiation

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

the class FetchSinglePaymentResourceTest method fetchPaymentInvalidPaymentService.

@Test
@Category(IntegrationTest.class)
public void fetchPaymentInvalidPaymentService() throws IOException {
    Invocation.Builder invocationBuilder = target("/v1/bulk-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSU-1234");
    invocationBuilder.header("PSU-BIC", "GENODEF1M03");
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    Jsonb jsonb = JsonbBuilder.create();
    BulkPaymentInitiation bulkPaymentInitiation = jsonb.fromJson("{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"}, \"payments\":[{\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"},{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"32.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"Gimmeyourmoney\",\"remittanceInformationUnstructured\":\"Myothervwz\"}]}", BulkPaymentInitiation.class);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(bulkPaymentInitiation, 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-1234").header("PSU-BIC", "GENODEF1M03").header("PSU-IP-Address", "192.168.8.78").header("redirectPreferred", true).buildGet();
    response = getPayment.invoke(Response.class);
    Assertions.assertEquals(500, 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) InputStream(java.io.InputStream) BulkPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.BulkPaymentInitiation) 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 5 with BulkPaymentInitiation

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

the class SinglePaymentInitiationResourceTest method initiateBulkPayment_Fiducia.

@Test
@Category(IntegrationTest.class)
public void initiateBulkPayment_Fiducia() {
    Invocation.Builder invocationBuilder = target("/v1/bulk-payments/sepa-credit-transfers").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-ID", "PSU-1234");
    invocationBuilder.header("PSU-BIC", "GENODEF1M03");
    invocationBuilder.header("PSU-IP-Address", "192.168.8.78");
    invocationBuilder.header("redirectPreferred", true);
    Jsonb jsonb = JsonbBuilder.create();
    BulkPaymentInitiation bulkPaymentInitiation = jsonb.fromJson("{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"},\"payments\":[{\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"},{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"32.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"Gimmeyourmoney\",\"remittanceInformationUnstructured\":\"Myothervwz\"}]}", BulkPaymentInitiation.class);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(bulkPaymentInitiation, 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) Invocation(javax.ws.rs.client.Invocation) BulkPaymentInitiation(net.petafuel.styx.api.v1.payment.entity.BulkPaymentInitiation) 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)5 Invocation (javax.ws.rs.client.Invocation)5 Response (javax.ws.rs.core.Response)5 BulkPaymentInitiation (net.petafuel.styx.api.v1.payment.entity.BulkPaymentInitiation)5 IntegrationTest (net.petafuel.styx.api.IntegrationTest)4 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)4 PaymentResponse (net.petafuel.styx.api.v1.payment.entity.PaymentResponse)4 Test (org.junit.Test)4 Category (org.junit.experimental.categories.Category)4 InputStream (java.io.InputStream)3 IOException (java.io.IOException)1 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