use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class TokenTest method test.
/**
* Smoke test for token calls.
*/
@Test
public void test() throws URISyntaxException, IOException {
CreateTokenRequest createTokenRequest = new CreateTokenRequest();
createTokenRequest.setPaymentProductId(1);
TokenCard card = new TokenCard();
createTokenRequest.setCard(card);
CustomerToken customer = new CustomerToken();
card.setCustomer(customer);
Address billingAddress = new Address();
customer.setBillingAddress(billingAddress);
billingAddress.setCountryCode("NL");
TokenCardData mandate = new TokenCardData();
card.setData(mandate);
CardWithoutCvv cardWithoutCvv = new CardWithoutCvv();
mandate.setCardWithoutCvv(cardWithoutCvv);
cardWithoutCvv.setCardholderName("Jan");
cardWithoutCvv.setIssueNumber("12");
cardWithoutCvv.setCardNumber("4567350000427977");
cardWithoutCvv.setExpiryDate("0820");
Client client = getClient();
try {
CreateTokenResponse createTokenResponse = client.merchant("9991").tokens().create(createTokenRequest);
Assert.assertNotNull(createTokenResponse.getToken());
DeleteTokenParams deleteTokenRequest = new DeleteTokenParams();
client.merchant("9991").tokens().delete(createTokenResponse.getToken(), deleteTokenRequest);
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class CreateHostedCheckoutExample method example.
@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
Client client = getClient();
try {
HostedCheckoutSpecificInput hostedCheckoutSpecificInput = new HostedCheckoutSpecificInput();
hostedCheckoutSpecificInput.setLocale("en_GB");
hostedCheckoutSpecificInput.setVariant("testVariant");
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setAmount(2345L);
amountOfMoney.setCurrencyCode("USD");
Address billingAddress = new Address();
billingAddress.setCountryCode("US");
Customer customer = new Customer();
customer.setBillingAddress(billingAddress);
Order order = new Order();
order.setAmountOfMoney(amountOfMoney);
order.setCustomer(customer);
CreateHostedCheckoutRequest body = new CreateHostedCheckoutRequest();
body.setHostedCheckoutSpecificInput(hostedCheckoutSpecificInput);
body.setOrder(order);
CreateHostedCheckoutResponse response = client.merchant("merchantId").hostedcheckouts().create(body);
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method testCreatePaymentRejected.
@Test
public void testCreatePaymentRejected() throws Exception {
// an exception is thrown after logging the response
serverBootstrap.registerHandler("/v1/1234/payments", requestHandler);
HttpHost host = start();
Client client = createClient(host);
TestLogger logger = new TestLogger();
client.enableLogging(logger);
setupRequestHandler(setJsonResponse("createPayment.failure.rejected.json", 402));
try {
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setCurrencyCode("CAD");
amountOfMoney.setAmount(2345L);
Address billingAddress = new Address();
billingAddress.setCountryCode("CA");
Customer customer = new Customer();
customer.setBillingAddress(billingAddress);
Order order = new Order();
order.setAmountOfMoney(amountOfMoney);
order.setCustomer(customer);
Card card = new Card();
card.setCvv("123");
card.setCardNumber("1234567890123452");
card.setExpiryDate("1220");
CardPaymentMethodSpecificInput paymentMethodSpecificInput = new CardPaymentMethodSpecificInput();
paymentMethodSpecificInput.setPaymentProductId(1);
paymentMethodSpecificInput.setCard(card);
CreatePaymentRequest request = new CreatePaymentRequest();
request.setOrder(order);
request.setCardPaymentMethodSpecificInput(paymentMethodSpecificInput);
client.merchant("1234").payments().create(request);
Assert.fail("expected DeclinedPaymentException");
} catch (DeclinedPaymentException e) {
// expected
Assert.assertNotNull(e.getCreatePaymentResult());
Assert.assertNotNull(e.getCreatePaymentResult().getPayment());
Assert.assertNotNull(e.getCreatePaymentResult().getPayment().getId());
} finally {
client.close();
}
Assert.assertEquals(2, logger.entries.size());
TestLoggerEntry requestEntry = logger.entries.get(0);
Assert.assertNotNull(requestEntry.message);
Assert.assertNull(requestEntry.thrown);
TestLoggerEntry responseEntry = logger.entries.get(1);
Assert.assertNotNull(responseEntry.message);
Assert.assertNull(responseEntry.thrown);
assertRequestAndResponse(requestEntry.message, responseEntry.message, "createPayment.failure.rejected");
}
use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class DefaultMarshallerTest method testUnmarshalWithExtraFields.
@Test
public void testUnmarshalWithExtraFields() {
TokenResponseWithExtraField original = new TokenResponseWithExtraField();
Address billingAddress = new Address();
billingAddress.setCountryCode("NL");
CustomerToken customer = new CustomerToken();
customer.setBillingAddress(billingAddress);
TokenCardData data = new TokenCardData();
TokenCard card = new TokenCard();
card.setCustomer(customer);
card.setData(data);
original.setCard(card);
original.setExtraField("extra-field-value");
String json = DefaultMarshaller.INSTANCE.marshal(original);
TokenResponse unmarshalled = DefaultMarshaller.INSTANCE.unmarshal(json, TokenResponse.class);
Assert.assertNotNull(unmarshalled.getCard());
Assert.assertNotNull(unmarshalled.getCard().getCustomer());
Assert.assertNotNull(unmarshalled.getCard().getCustomer().getBillingAddress());
Assert.assertEquals("NL", unmarshalled.getCard().getCustomer().getBillingAddress().getCountryCode());
Assert.assertNotNull(unmarshalled.getCard().getData());
}
use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class PaymentsClientTest method createRequest.
private CreatePaymentRequest createRequest() {
CreatePaymentRequest body = new CreatePaymentRequest();
Order order = new Order();
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setAmount(2345L);
amountOfMoney.setCurrencyCode("CAD");
order.setAmountOfMoney(amountOfMoney);
Customer customer = new Customer();
Address billingAddress = new Address();
billingAddress.setCountryCode("CA");
customer.setBillingAddress(billingAddress);
order.setCustomer(customer);
CardPaymentMethodSpecificInput cardPaymentMethodSpecificInput = new CardPaymentMethodSpecificInput();
cardPaymentMethodSpecificInput.setPaymentProductId(1);
Card card = new Card();
card.setCvv("123");
card.setCardNumber("4567350000427977");
card.setExpiryDate("1220");
cardPaymentMethodSpecificInput.setCard(card);
body.setCardPaymentMethodSpecificInput(cardPaymentMethodSpecificInput);
return body;
}
Aggregations