use of com.ingenico.connect.gateway.sdk.java.RequestHeader in project connect-sdk-java by Ingenico-ePayments.
the class MultiLineHeaderTest method test.
/**
* Smoke test for products service.
*/
@Test
public void test() throws URISyntaxException, IOException {
CommunicatorConfiguration configuration = getCommunicatorConfiguration();
String multiLineHeader = " some value \r\n \n with some \r\n spaces ";
MetaDataProvider metaDataProvider = new MetaDataProviderBuilder("Ingenico").withAdditionalRequestHeader(new RequestHeader("X-GCS-MultiLineHeader", multiLineHeader)).build();
DirectoryParams params = new DirectoryParams();
params.setCountryCode("NL");
params.setCurrencyCode("EUR");
Session session = Factory.createSessionBuilder(configuration).withMetaDataProvider(metaDataProvider).build();
Client client = Factory.createClient(session);
try {
Directory response = client.merchant("8500").products().directory(809, params);
Assert.assertTrue(response.getEntries().size() > 0);
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.RequestHeader in project connect-sdk-java by Ingenico-ePayments.
the class WebhooksHelperTest method testUnmarshalStringInvalidSignature.
@Test(expected = SignatureValidationException.class)
public void testUnmarshalStringInvalidSignature() throws IOException {
WebhooksHelper helper = createHelper();
InMemorySecretKeyStore.INSTANCE.storeSecretKey(KEY_ID, SECRET_KEY);
String body = new String(readResource("valid-body"), CHARSET);
List<RequestHeader> requestHeaders = Arrays.asList(new RequestHeader(SIGNATURE_HEADER, "1" + SIGNATURE), new RequestHeader(KEY_ID_HEADER, KEY_ID));
helper.unmarshal(body, requestHeaders);
}
use of com.ingenico.connect.gateway.sdk.java.RequestHeader in project connect-sdk-java by Ingenico-ePayments.
the class WebhooksHelperTest method testUnmarshalBytesInvalidSignature.
@Test(expected = SignatureValidationException.class)
public void testUnmarshalBytesInvalidSignature() throws IOException {
WebhooksHelper helper = createHelper();
InMemorySecretKeyStore.INSTANCE.storeSecretKey(KEY_ID, SECRET_KEY);
ByteArrayInputStream bodyStream = new ByteArrayInputStream(readResource("valid-body"));
List<RequestHeader> requestHeaders = Arrays.asList(new RequestHeader(SIGNATURE_HEADER, "1" + SIGNATURE), new RequestHeader(KEY_ID_HEADER, KEY_ID));
helper.unmarshal(bodyStream, requestHeaders);
}
use of com.ingenico.connect.gateway.sdk.java.RequestHeader in project connect-sdk-java by Ingenico-ePayments.
the class WebhooksHelperTest method testUnmarshalStringSuccess.
@Test
public void testUnmarshalStringSuccess() throws IOException {
WebhooksHelper helper = createHelper();
InMemorySecretKeyStore.INSTANCE.storeSecretKey(KEY_ID, SECRET_KEY);
String body = new String(readResource("valid-body"), CHARSET);
List<RequestHeader> requestHeaders = Arrays.asList(new RequestHeader(SIGNATURE_HEADER, SIGNATURE), new RequestHeader(KEY_ID_HEADER, KEY_ID));
WebhooksEvent event = helper.unmarshal(body, requestHeaders);
Assert.assertEquals("v1", event.getApiVersion());
Assert.assertEquals("8ee793f6-4553-4749-85dc-f2ef095c5ab0", event.getId());
Assert.assertEquals("2017-02-02T11:24:14.040+0100", event.getCreated());
Assert.assertEquals("20000", event.getMerchantId());
Assert.assertEquals("payment.paid", event.getType());
Assert.assertNull(event.getRefund());
Assert.assertNull(event.getPayout());
Assert.assertNull(event.getToken());
Assert.assertNotNull(event.getPayment());
Assert.assertEquals("00000200000143570012", event.getPayment().getId());
Assert.assertNotNull(event.getPayment().getPaymentOutput());
Assert.assertNotNull(event.getPayment().getPaymentOutput().getAmountOfMoney());
Assert.assertEquals((Long) 1000L, event.getPayment().getPaymentOutput().getAmountOfMoney().getAmount());
Assert.assertEquals("EUR", event.getPayment().getPaymentOutput().getAmountOfMoney().getCurrencyCode());
Assert.assertNotNull(event.getPayment().getPaymentOutput().getReferences());
Assert.assertEquals("200001681810", event.getPayment().getPaymentOutput().getReferences().getPaymentReference());
Assert.assertEquals("bankTransfer", event.getPayment().getPaymentOutput().getPaymentMethod());
Assert.assertNull(event.getPayment().getPaymentOutput().getCardPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getCashPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getDirectDebitPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getInvoicePaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getRedirectPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getSepaDirectDebitPaymentMethodSpecificOutput());
Assert.assertNotNull(event.getPayment().getPaymentOutput().getBankTransferPaymentMethodSpecificOutput());
Assert.assertEquals((Integer) 11, event.getPayment().getPaymentOutput().getBankTransferPaymentMethodSpecificOutput().getPaymentProductId());
Assert.assertEquals("PAID", event.getPayment().getStatus());
Assert.assertNotNull(event.getPayment().getStatusOutput());
Assert.assertEquals(false, event.getPayment().getStatusOutput().getIsCancellable());
Assert.assertEquals("COMPLETED", event.getPayment().getStatusOutput().getStatusCategory());
Assert.assertEquals((Integer) 1000, event.getPayment().getStatusOutput().getStatusCode());
Assert.assertEquals("20170202112414", event.getPayment().getStatusOutput().getStatusCodeChangeDateTime());
Assert.assertEquals(true, event.getPayment().getStatusOutput().getIsAuthorized());
}
use of com.ingenico.connect.gateway.sdk.java.RequestHeader in project connect-sdk-java by Ingenico-ePayments.
the class WebhooksHelperTest method testUnmarshalBytesSuccess.
@Test
public void testUnmarshalBytesSuccess() throws IOException {
WebhooksHelper helper = createHelper();
InMemorySecretKeyStore.INSTANCE.storeSecretKey(KEY_ID, SECRET_KEY);
ByteArrayInputStream bodyStream = new ByteArrayInputStream(readResource("valid-body"));
List<RequestHeader> requestHeaders = Arrays.asList(new RequestHeader(SIGNATURE_HEADER, SIGNATURE), new RequestHeader(KEY_ID_HEADER, KEY_ID));
WebhooksEvent event = helper.unmarshal(bodyStream, requestHeaders);
Assert.assertEquals("v1", event.getApiVersion());
Assert.assertEquals("8ee793f6-4553-4749-85dc-f2ef095c5ab0", event.getId());
Assert.assertEquals("2017-02-02T11:24:14.040+0100", event.getCreated());
Assert.assertEquals("20000", event.getMerchantId());
Assert.assertEquals("payment.paid", event.getType());
Assert.assertNull(event.getRefund());
Assert.assertNull(event.getPayout());
Assert.assertNull(event.getToken());
Assert.assertNotNull(event.getPayment());
Assert.assertEquals("00000200000143570012", event.getPayment().getId());
Assert.assertNotNull(event.getPayment().getPaymentOutput());
Assert.assertNotNull(event.getPayment().getPaymentOutput().getAmountOfMoney());
Assert.assertEquals((Long) 1000L, event.getPayment().getPaymentOutput().getAmountOfMoney().getAmount());
Assert.assertEquals("EUR", event.getPayment().getPaymentOutput().getAmountOfMoney().getCurrencyCode());
Assert.assertNotNull(event.getPayment().getPaymentOutput().getReferences());
Assert.assertEquals("200001681810", event.getPayment().getPaymentOutput().getReferences().getPaymentReference());
Assert.assertEquals("bankTransfer", event.getPayment().getPaymentOutput().getPaymentMethod());
Assert.assertNull(event.getPayment().getPaymentOutput().getCardPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getCashPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getDirectDebitPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getInvoicePaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getRedirectPaymentMethodSpecificOutput());
Assert.assertNull(event.getPayment().getPaymentOutput().getSepaDirectDebitPaymentMethodSpecificOutput());
Assert.assertNotNull(event.getPayment().getPaymentOutput().getBankTransferPaymentMethodSpecificOutput());
Assert.assertEquals((Integer) 11, event.getPayment().getPaymentOutput().getBankTransferPaymentMethodSpecificOutput().getPaymentProductId());
Assert.assertEquals("PAID", event.getPayment().getStatus());
Assert.assertNotNull(event.getPayment().getStatusOutput());
Assert.assertEquals(false, event.getPayment().getStatusOutput().getIsCancellable());
Assert.assertEquals("COMPLETED", event.getPayment().getStatusOutput().getStatusCategory());
Assert.assertEquals((Integer) 1000, event.getPayment().getStatusOutput().getStatusCode());
Assert.assertEquals("20170202112414", event.getPayment().getStatusOutput().getStatusCodeChangeDateTime());
Assert.assertEquals(true, event.getPayment().getStatusOutput().getIsAuthorized());
}
Aggregations