use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class CreatePaymentExample method example.
@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
Client client = getClient();
try {
Card card = new Card();
card.setCardNumber("4567350000427977");
card.setCardholderName("Wile E. Coyote");
card.setCvv("123");
card.setExpiryDate("1220");
CardPaymentMethodSpecificInput cardPaymentMethodSpecificInput = new CardPaymentMethodSpecificInput();
cardPaymentMethodSpecificInput.setCard(card);
cardPaymentMethodSpecificInput.setPaymentProductId(1);
cardPaymentMethodSpecificInput.setSkipAuthentication(false);
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setAmount(2980L);
amountOfMoney.setCurrencyCode("EUR");
Address billingAddress = new Address();
billingAddress.setAdditionalInfo("b");
billingAddress.setCity("Monument Valley");
billingAddress.setCountryCode("US");
billingAddress.setHouseNumber("13");
billingAddress.setState("Utah");
billingAddress.setStreet("Desertroad");
billingAddress.setZip("84536");
CompanyInformation companyInformation = new CompanyInformation();
companyInformation.setName("Acme Labs");
ContactDetails contactDetails = new ContactDetails();
contactDetails.setEmailAddress("wile.e.coyote@acmelabs.com");
contactDetails.setEmailMessageType("html");
contactDetails.setFaxNumber("+1234567891");
contactDetails.setPhoneNumber("+1234567890");
PersonalName name = new PersonalName();
name.setFirstName("Wile");
name.setSurname("Coyote");
name.setSurnamePrefix("E.");
name.setTitle("Mr.");
PersonalInformation personalInformation = new PersonalInformation();
personalInformation.setDateOfBirth("19490917");
personalInformation.setGender("M");
personalInformation.setName(name);
PersonalName shippingName = new PersonalName();
shippingName.setFirstName("Road");
shippingName.setSurname("Runner");
shippingName.setTitle("Miss");
AddressPersonal shippingAddress = new AddressPersonal();
shippingAddress.setAdditionalInfo("Suite II");
shippingAddress.setCity("Monument Valley");
shippingAddress.setCountryCode("US");
shippingAddress.setHouseNumber("1");
shippingAddress.setName(shippingName);
shippingAddress.setState("Utah");
shippingAddress.setStreet("Desertroad");
shippingAddress.setZip("84536");
Customer customer = new Customer();
customer.setBillingAddress(billingAddress);
customer.setCompanyInformation(companyInformation);
customer.setContactDetails(contactDetails);
customer.setLocale("en_US");
customer.setMerchantCustomerId("1234");
customer.setPersonalInformation(personalInformation);
customer.setShippingAddress(shippingAddress);
customer.setVatNumber("1234AB5678CD");
OrderInvoiceData invoiceData = new OrderInvoiceData();
invoiceData.setInvoiceDate("20140306191500");
invoiceData.setInvoiceNumber("000000123");
OrderReferences references = new OrderReferences();
references.setDescriptor("Fast and Furry-ous");
references.setInvoiceData(invoiceData);
references.setMerchantOrderId(123456L);
references.setMerchantReference("AcmeOrder0001");
List<LineItem> items = new ArrayList<LineItem>();
AmountOfMoney item1AmountOfMoney = new AmountOfMoney();
item1AmountOfMoney.setAmount(2500L);
item1AmountOfMoney.setCurrencyCode("EUR");
LineItemInvoiceData item1InvoiceData = new LineItemInvoiceData();
item1InvoiceData.setDescription("ACME Super Outfit");
item1InvoiceData.setNrOfItems("1");
item1InvoiceData.setPricePerItem(2500L);
LineItem item1 = new LineItem();
item1.setAmountOfMoney(item1AmountOfMoney);
item1.setInvoiceData(item1InvoiceData);
items.add(item1);
AmountOfMoney item2AmountOfMoney = new AmountOfMoney();
item2AmountOfMoney.setAmount(480L);
item2AmountOfMoney.setCurrencyCode("EUR");
LineItemInvoiceData item2InvoiceData = new LineItemInvoiceData();
item2InvoiceData.setDescription("Aspirin");
item2InvoiceData.setNrOfItems("12");
item2InvoiceData.setPricePerItem(40L);
LineItem item2 = new LineItem();
item2.setAmountOfMoney(item2AmountOfMoney);
item2.setInvoiceData(item2InvoiceData);
items.add(item2);
ShoppingCart shoppingCart = new ShoppingCart();
shoppingCart.setItems(items);
Order order = new Order();
order.setAmountOfMoney(amountOfMoney);
order.setCustomer(customer);
order.setReferences(references);
order.setShoppingCart(shoppingCart);
CreatePaymentRequest body = new CreatePaymentRequest();
body.setCardPaymentMethodSpecificInput(cardPaymentMethodSpecificInput);
body.setOrder(order);
try {
CreatePaymentResponse response = client.merchant("merchantId").payments().create(body);
} catch (DeclinedPaymentException e) {
handleDeclinedPayment(e.getCreatePaymentResult());
} catch (ApiException e) {
handleApiErrors(e.getErrors());
}
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class CreatePayoutExample method example.
@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
Client client = getClient();
try {
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setAmount(2345L);
amountOfMoney.setCurrencyCode("EUR");
BankAccountIban bankAccountIban = new BankAccountIban();
bankAccountIban.setAccountHolderName("Wile E. Coyote");
bankAccountIban.setIban("IT60X0542811101000000123456");
Address address = new Address();
address.setCity("Burbank");
address.setCountryCode("US");
address.setHouseNumber("411");
address.setState("California");
address.setStreet("N Hollywood Way");
address.setZip("91505");
CompanyInformation companyInformation = new CompanyInformation();
companyInformation.setName("Acme Labs");
ContactDetailsBase contactDetails = new ContactDetailsBase();
contactDetails.setEmailAddress("wile.e.coyote@acmelabs.com");
PersonalName name = new PersonalName();
name.setFirstName("Wile");
name.setSurname("Coyote");
name.setSurnamePrefix("E.");
name.setTitle("Mr.");
PayoutCustomer customer = new PayoutCustomer();
customer.setAddress(address);
customer.setCompanyInformation(companyInformation);
customer.setContactDetails(contactDetails);
customer.setName(name);
BankTransferPayoutMethodSpecificInput bankTransferPayoutMethodSpecificInput = new BankTransferPayoutMethodSpecificInput();
bankTransferPayoutMethodSpecificInput.setBankAccountIban(bankAccountIban);
bankTransferPayoutMethodSpecificInput.setCustomer(customer);
bankTransferPayoutMethodSpecificInput.setPayoutDate("20150102");
bankTransferPayoutMethodSpecificInput.setPayoutText("Payout Acme");
bankTransferPayoutMethodSpecificInput.setSwiftCode("swift");
PayoutReferences references = new PayoutReferences();
references.setMerchantReference("AcmeOrder001");
CreatePayoutRequest body = new CreatePayoutRequest();
body.setAmountOfMoney(amountOfMoney);
body.setBankTransferPayoutMethodSpecificInput(bankTransferPayoutMethodSpecificInput);
body.setReferences(references);
try {
PayoutResponse response = client.merchant("merchantId").payouts().create(body);
} catch (DeclinedPayoutException e) {
handleDeclinedPayout(e.getPayoutResult());
} catch (ApiException e) {
handleApiErrors(e.getErrors());
}
} finally {
client.close();
}
}
use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.
the class RiskAssessmentCardsExample method example.
@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
Client client = getClient();
try {
Card card = new Card();
card.setCardNumber("4567350000427977");
card.setCvv("123");
card.setExpiryDate("0820");
List<AirlineFlightLeg> flightLegs = new ArrayList<AirlineFlightLeg>();
AirlineFlightLeg flightLeg1 = new AirlineFlightLeg();
flightLeg1.setAirlineClass("1");
flightLeg1.setArrivalAirport("AMS");
flightLeg1.setCarrierCode("KL");
flightLeg1.setDate("20150102");
flightLeg1.setDepartureTime("17:59");
flightLeg1.setFare("fare");
flightLeg1.setFareBasis("INTERNET");
flightLeg1.setFlightNumber("791");
flightLeg1.setNumber(1);
flightLeg1.setOriginAirport("BCN");
flightLeg1.setStopoverCode("non-permitted");
flightLegs.add(flightLeg1);
AirlineFlightLeg flightLeg2 = new AirlineFlightLeg();
flightLeg2.setAirlineClass("1");
flightLeg2.setArrivalAirport("BCN");
flightLeg2.setCarrierCode("KL");
flightLeg2.setDate("20150102");
flightLeg2.setDepartureTime("23:59");
flightLeg2.setFare("fare");
flightLeg2.setFareBasis("INTERNET");
flightLeg2.setFlightNumber("792");
flightLeg2.setNumber(2);
flightLeg2.setOriginAirport("AMS");
flightLeg2.setStopoverCode("non-permitted");
flightLegs.add(flightLeg2);
AirlineData airlineData = new AirlineData();
airlineData.setAgentNumericCode("123321");
airlineData.setCode("123");
airlineData.setFlightDate("20150102");
airlineData.setFlightLegs(flightLegs);
airlineData.setInvoiceNumber("123456");
airlineData.setIsETicket(true);
airlineData.setIsRegisteredCustomer(true);
airlineData.setIsRestrictedTicket(true);
airlineData.setIsThirdParty(true);
airlineData.setIssueDate("20150101");
airlineData.setMerchantCustomerId("14");
airlineData.setName("Air France KLM");
airlineData.setPassengerName("WECOYOTE");
airlineData.setPlaceOfIssue("Utah");
airlineData.setPnr("4JTGKT");
airlineData.setPointOfSale("IATA point of sale name");
airlineData.setPosCityCode("AMS");
airlineData.setTicketDeliveryMethod("e-ticket");
airlineData.setTicketNumber("KLM20050000");
AdditionalOrderInputAirlineData additionalInput = new AdditionalOrderInputAirlineData();
additionalInput.setAirlineData(airlineData);
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setAmount(100L);
amountOfMoney.setCurrencyCode("EUR");
Address billingAddress = new Address();
billingAddress.setCountryCode("US");
CustomerRiskAssessment customer = new CustomerRiskAssessment();
customer.setBillingAddress(billingAddress);
customer.setLocale("en_US");
OrderRiskAssessment order = new OrderRiskAssessment();
order.setAdditionalInput(additionalInput);
order.setAmountOfMoney(amountOfMoney);
order.setCustomer(customer);
RiskAssessmentCard body = new RiskAssessmentCard();
body.setCard(card);
body.setOrder(order);
RiskAssessmentResponse response = client.merchant("merchantId").riskassessments().cards(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 UpdateTokenExample method example.
public void example() throws URISyntaxException, IOException {
Client client = getClient();
try {
Address billingAddress = new Address();
billingAddress.setAdditionalInfo("b");
billingAddress.setCity("Monument Valley");
billingAddress.setCountryCode("US");
billingAddress.setHouseNumber("13");
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);
CardWithoutCvv cardWithoutCvv = new CardWithoutCvv();
cardWithoutCvv.setCardNumber("4567350000427977");
cardWithoutCvv.setCardholderName("Wile E. Coyote");
cardWithoutCvv.setExpiryDate("0820");
cardWithoutCvv.setIssueNumber("12");
TokenCardData data = new TokenCardData();
data.setCardWithoutCvv(cardWithoutCvv);
TokenCard card = new TokenCard();
card.setCustomer(customer);
card.setData(data);
UpdateTokenRequest body = new UpdateTokenRequest();
body.setCard(card);
body.setPaymentProductId(1);
client.merchant("merchantId").tokens().update("tokenId", 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 IdempotenceTest method test.
/**
* Smoke test for idempotence.
*/
@Test
public void test() throws URISyntaxException, IOException {
CreatePaymentRequest body = new CreatePaymentRequest();
Order order = new Order();
AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setCurrencyCode("EUR");
amountOfMoney.setAmount(100L);
order.setAmountOfMoney(amountOfMoney);
Customer customer = new Customer();
customer.setLocale("en");
Address billingAddress = new Address();
billingAddress.setCountryCode("NL");
customer.setBillingAddress(billingAddress);
order.setCustomer(customer);
body.setOrder(order);
RedirectPaymentMethodSpecificInput paymentMethodSpecificInput = new RedirectPaymentMethodSpecificInput();
paymentMethodSpecificInput.setReturnUrl("http://example.com/");
paymentMethodSpecificInput.setPaymentProductId(809);
RedirectPaymentProduct809SpecificInput paymentProductSpecificInput = new RedirectPaymentProduct809SpecificInput();
paymentProductSpecificInput.setIssuerId("INGBNL2A");
paymentMethodSpecificInput.setPaymentProduct809SpecificInput(paymentProductSpecificInput);
body.setRedirectPaymentMethodSpecificInput(paymentMethodSpecificInput);
String idempotenceKey = UUID.randomUUID().toString();
CallContext context = new CallContext().withIdempotenceKey(idempotenceKey);
Client client = getClient();
try {
CreatePaymentResponse response = client.merchant("20000").payments().create(body, context);
String paymentId = response.getPayment().getId();
Assert.assertEquals(idempotenceKey, context.getIdempotenceKey());
Assert.assertNull(context.getIdempotenceRequestTimestamp());
response = client.merchant("20000").payments().create(body, context);
Assert.assertEquals(paymentId, response.getPayment().getId());
Assert.assertEquals(idempotenceKey, context.getIdempotenceKey());
Assert.assertNotNull(context.getIdempotenceRequestTimestamp());
} finally {
client.close();
}
}
Aggregations