Search in sources :

Example 11 with SinglePaymentInitiation

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

the class SinglePaymentInitiationResourceTest method initiateSinglePayment_Fiducia.

@Test
@Category(IntegrationTest.class)
@DisplayName("initiateSinglePayment_Fiducia -> Test json to XML conversion of payment initation request within styx to aspsp interface")
public void initiateSinglePayment_Fiducia() {
    Invocation.Builder invocationBuilder = target("/v1/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();
    SinglePaymentInitiation singlePaymentInitiation = jsonb.fromJson("{\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE87200500001234567890\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE23100120020123456789\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"}]}", SinglePaymentInitiation.class);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(singlePaymentInitiation, MediaType.APPLICATION_JSON));
    Response response = invocation.invoke(Response.class);
    Assert.assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) SinglePaymentInitiation(net.petafuel.styx.api.v1.payment.entity.SinglePaymentInitiation) Jsonb(javax.json.bind.Jsonb) 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) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with SinglePaymentInitiation

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

the class SinglePaymentStatusResourceTest method getSparkasseSinglePaymentId.

private String getSparkasseSinglePaymentId() {
    if (sparkasseSinglePaymentId == null) {
        Invocation.Builder invocationBuilder = target("/v1/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();
        SinglePaymentInitiation singlePaymentInitiation = jsonb.fromJson("{\"payments\":[{\"debtorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE86999999990000001000\"},\"instructedAmount\":{\"currency\":\"EUR\",\"amount\":\"520.00\"},\"creditorAccount\":{\"currency\":\"EUR\",\"iban\":\"DE75999999990000001004\"},\"creditorName\":\"WBG\",\"remittanceInformationUnstructured\":\"Ref.NumberWBG-1222\"}]}", SinglePaymentInitiation.class);
        Invocation invocation = invocationBuilder.buildPost(Entity.entity(singlePaymentInitiation, MediaType.APPLICATION_JSON));
        Response response = invocation.invoke(Response.class);
        try {
            PaymentResponse paymentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), PaymentResponse.class);
            sparkasseSinglePaymentId = paymentResponse.getPaymentId();
        } catch (IOException e) {
            return "";
        }
    }
    return sparkasseSinglePaymentId;
}
Also used : PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse) Response(javax.ws.rs.core.Response) SinglePaymentInitiation(net.petafuel.styx.api.v1.payment.entity.SinglePaymentInitiation) Jsonb(javax.json.bind.Jsonb) Invocation(javax.ws.rs.client.Invocation) InputStream(java.io.InputStream) IOException(java.io.IOException) PaymentResponse(net.petafuel.styx.api.v1.payment.entity.PaymentResponse)

Example 13 with SinglePaymentInitiation

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

the class SparkassePISIntegrationTest method test_INIT_SCTSinglePayment_SCA_OAUTH.

@Category(IntegrationTest.class)
@ParameterizedTest
@ArgumentsSource(SparkassePSUProvider.class)
void test_INIT_SCTSinglePayment_SCA_OAUTH(String psuBic, String psuId, String creditorIban, String debtorIban) {
    Assume.assumeNotNull(PIS_TOKEN);
    SinglePayment singlePayment = new SinglePayment();
    singlePayment.setDebtorAccount(new AccountReference(debtorIban, AccountReference.Type.IBAN));
    singlePayment.setCreditorAccount(new AccountReference(creditorIban, AccountReference.Type.IBAN));
    singlePayment.setInstructedAmount(new Amount("0.01"));
    singlePayment.setCreditorName(psuId);
    singlePayment.setRemittanceInformationUnstructured("Styx PIS Test unixstamp: " + new Date().getTime());
    SinglePaymentInitiation singlePaymentInitiation = new SinglePaymentInitiation();
    singlePaymentInitiation.setPayments(Collections.singletonList(singlePayment));
    given().contentType(ContentType.JSON).header("token", PIS_TOKEN).header("psu-id", psuId).header("psu-bic", psuBic).header("redirectPreferred", "true").body(singlePaymentInitiation).post("/v1/payments/sepa-credit-transfers").then().assertThat().header("content-type", Matchers.containsString("application/json")).statusCode(201).body("transactionStatus", Matchers.is(TransactionStatus.RCVD.name())).body("paymentId", Matchers.notNullValue()).body("links.scaOAuth.href", Matchers.notNullValue());
}
Also used : SinglePaymentInitiation(net.petafuel.styx.api.v1.payment.entity.SinglePaymentInitiation) Amount(net.petafuel.styx.core.xs2a.entities.Amount) AccountReference(net.petafuel.styx.core.xs2a.entities.AccountReference) SinglePayment(net.petafuel.styx.core.xs2a.entities.SinglePayment) Date(java.util.Date) Category(org.junit.experimental.categories.Category) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 14 with SinglePaymentInitiation

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

the class SparkassePISIntegrationTest method test_INIT_SCTSinglePayment_SCA_EMBEDDED.

@Category(IntegrationTest.class)
@ParameterizedTest
@ArgumentsSource(SparkassePSUProvider.class)
void test_INIT_SCTSinglePayment_SCA_EMBEDDED(String psuBic, String psuId, String creditorIban, String debtorIban) {
    Assume.assumeNotNull(PIS_TOKEN);
    SinglePayment singlePayment = new SinglePayment();
    singlePayment.setDebtorAccount(new AccountReference(debtorIban, AccountReference.Type.IBAN));
    singlePayment.setCreditorAccount(new AccountReference(creditorIban, AccountReference.Type.IBAN));
    singlePayment.setInstructedAmount(new Amount("0.01"));
    singlePayment.setCreditorName(psuId);
    singlePayment.setRemittanceInformationUnstructured("Styx PIS Test unixstamp: " + new Date().getTime());
    SinglePaymentInitiation singlePaymentInitiation = new SinglePaymentInitiation();
    singlePaymentInitiation.setPayments(Collections.singletonList(singlePayment));
    given().contentType(ContentType.JSON).header("token", PIS_TOKEN).header("psu-id", psuId).header("psu-bic", psuBic).header("redirectPreferred", "false").body(singlePaymentInitiation).post("/v1/payments/sepa-credit-transfers").then().assertThat().header("content-type", Matchers.containsString("application/json")).statusCode(201).body("transactionStatus", Matchers.is(TransactionStatus.RCVD.name())).body("paymentId", Matchers.notNullValue()).body("links.startAuthorisationWithPsuAuthentication.href", Matchers.notNullValue());
}
Also used : SinglePaymentInitiation(net.petafuel.styx.api.v1.payment.entity.SinglePaymentInitiation) Amount(net.petafuel.styx.core.xs2a.entities.Amount) AccountReference(net.petafuel.styx.core.xs2a.entities.AccountReference) SinglePayment(net.petafuel.styx.core.xs2a.entities.SinglePayment) Date(java.util.Date) Category(org.junit.experimental.categories.Category) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Aggregations

SinglePaymentInitiation (net.petafuel.styx.api.v1.payment.entity.SinglePaymentInitiation)13 Jsonb (javax.json.bind.Jsonb)11 Invocation (javax.ws.rs.client.Invocation)11 Category (org.junit.experimental.categories.Category)11 IntegrationTest (net.petafuel.styx.api.IntegrationTest)9 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)9 Test (org.junit.Test)9 Response (javax.ws.rs.core.Response)8 PaymentResponse (net.petafuel.styx.api.v1.payment.entity.PaymentResponse)8 InputStream (java.io.InputStream)4 SinglePayment (net.petafuel.styx.core.xs2a.entities.SinglePayment)4 IOException (java.io.IOException)3 AccountReference (net.petafuel.styx.core.xs2a.entities.AccountReference)3 Amount (net.petafuel.styx.core.xs2a.entities.Amount)3 Date (java.util.Date)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)2 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 ResponseEntity (net.petafuel.styx.api.exception.ResponseEntity)1