use of com.ingenico.connect.gateway.sdk.java.Client in project connect-sdk-java by Ingenico-ePayments.
the class PaymentProductsTest method test.
/**
* Smoke test for products service.
*/
@Test
public void test() throws URISyntaxException, IOException {
DirectoryParams params = new DirectoryParams();
params.setCountryCode("NL");
params.setCurrencyCode("EUR");
Client client = getClient();
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.Client in project connect-sdk-java by Ingenico-ePayments.
the class CreateTokenExample method example.
@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
Client client = getClient();
try {
Address billingAddress = new Address();
billingAddress.setAdditionalInfo("Suite II");
billingAddress.setCity("Monument Valley");
billingAddress.setCountryCode("US");
billingAddress.setHouseNumber("1");
billingAddress.setState("Utah");
billingAddress.setStreet("Desertroad");
billingAddress.setZip("84536");
CompanyInformation companyInformation = new CompanyInformation();
companyInformation.setName("Acme Labs");
PersonalNameToken name = new PersonalNameToken();
name.setFirstName("Wile");
name.setSurname("Coyote");
name.setSurnamePrefix("E.");
PersonalInformationToken personalInformation = new PersonalInformationToken();
personalInformation.setName(name);
CustomerToken customer = new CustomerToken();
customer.setBillingAddress(billingAddress);
customer.setCompanyInformation(companyInformation);
customer.setMerchantCustomerId("1234");
customer.setPersonalInformation(personalInformation);
BankAccountBban bankAccountBban = new BankAccountBban();
bankAccountBban.setAccountNumber("000000123456");
bankAccountBban.setBankCode("05428");
bankAccountBban.setBranchCode("11101");
bankAccountBban.setCheckDigit("X");
bankAccountBban.setCountryCode("IT");
TokenNonSepaDirectDebitPaymentProduct705SpecificData paymentProduct705SpecificData = new TokenNonSepaDirectDebitPaymentProduct705SpecificData();
paymentProduct705SpecificData.setAuthorisationId("123456");
paymentProduct705SpecificData.setBankAccountBban(bankAccountBban);
MandateNonSepaDirectDebit mandate = new MandateNonSepaDirectDebit();
mandate.setPaymentProduct705SpecificData(paymentProduct705SpecificData);
TokenNonSepaDirectDebit nonSepaDirectDebit = new TokenNonSepaDirectDebit();
nonSepaDirectDebit.setCustomer(customer);
nonSepaDirectDebit.setMandate(mandate);
CreateTokenRequest body = new CreateTokenRequest();
body.setNonSepaDirectDebit(nonSepaDirectDebit);
body.setPaymentProductId(705);
CreateTokenResponse response = client.merchant("merchantId").tokens().create(body);
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.Client in project connect-sdk-java by Ingenico-ePayments.
the class SystemProxyTest method test.
/**
* Smoke test for using a proxy configured through system properties.
*/
@Test
public void test() throws URISyntaxException, IOException {
final boolean[] authenticationCalled = { false };
final String username = System.getProperty("http.proxyUser");
final String password = System.getProperty("http.proxyPass");
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
authenticationCalled[0] = true;
return new PasswordAuthentication(username, password.toCharArray());
}
});
ConvertAmountParams request = new ConvertAmountParams();
request.setAmount(123L);
request.setSource("USD");
request.setTarget("EUR");
CommunicatorConfiguration configuration = getCommunicatorConfiguration().withProxyConfiguration(null);
Client client = Factory.createClient(configuration);
try {
ConvertAmount response = client.merchant("9991").services().convertAmount(request);
Assert.assertNotNull(response.getConvertedAmount());
} finally {
client.close();
}
// for https, authentication may not be required
if ("http".equalsIgnoreCase(configuration.getApiEndpoint().getScheme())) {
Assert.assertTrue("getPasswordAuthentication() should have been called", authenticationCalled[0]);
}
}
use of com.ingenico.connect.gateway.sdk.java.Client in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method testLogRequestOnly.
@Test
public void testLogRequestOnly() throws Exception {
// logging is disabled after the request is logged but before the response is logged
serverBootstrap.registerHandler("/v1/1234/services/testconnection", requestHandler);
HttpHost host = start();
Client client = createClient(host);
TestLogger logger = new TestLogger();
client.enableLogging(logger);
setupRequestHandler(disableLogging(setOKJsonResponse("testConnection.json"), client));
try {
TestConnection response = client.merchant("1234").services().testconnection();
Assert.assertNotNull(response);
Assert.assertEquals("OK", response.getResult());
} finally {
client.close();
}
Assert.assertEquals(1, logger.entries.size());
TestLoggerEntry requestEntry = logger.entries.get(0);
Assert.assertNotNull(requestEntry.message);
Assert.assertNull(requestEntry.thrown);
assertRequest(requestEntry.message, "testConnection");
}
use of com.ingenico.connect.gateway.sdk.java.Client in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method testLogResponseOnly.
@Test
public void testLogResponseOnly() throws Exception {
// logging is enabled after the request is logged but before the response is logged
serverBootstrap.registerHandler("/v1/1234/services/testconnection", requestHandler);
HttpHost host = start();
Client client = createClient(host);
TestLogger logger = new TestLogger();
setupRequestHandler(enableLogging(setOKJsonResponse("testConnection.json"), client, logger));
try {
TestConnection response = client.merchant("1234").services().testconnection();
Assert.assertNotNull(response);
Assert.assertEquals("OK", response.getResult());
} finally {
client.close();
}
Assert.assertEquals(1, logger.entries.size());
TestLoggerEntry responseEntry = logger.entries.get(0);
Assert.assertNotNull(responseEntry.message);
Assert.assertNull(responseEntry.thrown);
assertResponse(responseEntry.message, "testConnection");
}
Aggregations