Search in sources :

Example 6 with Address

use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address 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();
    }
}
Also used : CreateTokenRequest(com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenRequest) TokenNonSepaDirectDebitPaymentProduct705SpecificData(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenNonSepaDirectDebitPaymentProduct705SpecificData) CompanyInformation(com.ingenico.connect.gateway.sdk.java.domain.definitions.CompanyInformation) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) PersonalInformationToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalInformationToken) CustomerToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken) BankAccountBban(com.ingenico.connect.gateway.sdk.java.domain.definitions.BankAccountBban) MandateNonSepaDirectDebit(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.MandateNonSepaDirectDebit) TokenNonSepaDirectDebit(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenNonSepaDirectDebit) Client(com.ingenico.connect.gateway.sdk.java.Client) CreateTokenResponse(com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenResponse) PersonalNameToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalNameToken)

Example 7 with Address

use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.

the class DefaultConnectionLoggerTest method testCreatePayment.

@Test
public void testCreatePayment() throws Exception {
    // POST with a success (201) response
    serverBootstrap.registerHandler("/v1/1234/payments", requestHandler);
    HttpHost host = start();
    Client client = createClient(host);
    TestLogger logger = new TestLogger();
    client.enableLogging(logger);
    setupRequestHandler(setCreatedJsonResponse("createPayment.json", "http://localhost/v1/1234/payments/000000123410000595980000100001"));
    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("1234567890123456");
        card.setExpiryDate("1220");
        CardPaymentMethodSpecificInput paymentMethodSpecificInput = new CardPaymentMethodSpecificInput();
        paymentMethodSpecificInput.setPaymentProductId(1);
        paymentMethodSpecificInput.setCard(card);
        CreatePaymentRequest request = new CreatePaymentRequest();
        request.setOrder(order);
        request.setCardPaymentMethodSpecificInput(paymentMethodSpecificInput);
        CreatePaymentResponse response = client.merchant("1234").payments().create(request);
        Assert.assertNotNull(response);
        Assert.assertNotNull(response.getPayment());
        Assert.assertNotNull(response.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");
}
Also used : Order(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Order) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) Customer(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Customer) HttpHost(org.apache.http.HttpHost) CreatePaymentRequest(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest) Client(com.ingenico.connect.gateway.sdk.java.Client) CreatePaymentResponse(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentResponse) CardPaymentMethodSpecificInput(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.CardPaymentMethodSpecificInput) AmountOfMoney(com.ingenico.connect.gateway.sdk.java.domain.definitions.AmountOfMoney) Card(com.ingenico.connect.gateway.sdk.java.domain.definitions.Card) Test(org.junit.Test)

Example 8 with Address

use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.

the class DefaultConnectionLoggerTest method testCreatePaymentInvalidCardNumber.

@Test
public void testCreatePaymentInvalidCardNumber() 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.invalidCardNumber.json", 400));
    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("1234567890123456");
        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 ValidationException");
    } catch (ValidationException e) {
    // expected
    } 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.invalidCardNumber");
}
Also used : Order(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Order) ValidationException(com.ingenico.connect.gateway.sdk.java.ValidationException) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) Customer(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Customer) HttpHost(org.apache.http.HttpHost) CreatePaymentRequest(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest) Client(com.ingenico.connect.gateway.sdk.java.Client) CardPaymentMethodSpecificInput(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.CardPaymentMethodSpecificInput) AmountOfMoney(com.ingenico.connect.gateway.sdk.java.domain.definitions.AmountOfMoney) Card(com.ingenico.connect.gateway.sdk.java.domain.definitions.Card) Test(org.junit.Test)

Example 9 with Address

use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSessionPreparePaymentRequestTest method constructCreatePaymentRequest.

/**
 * Creates a minimal CreatePaymentRequest object that can still be payed with
 */
private CreatePaymentRequest constructCreatePaymentRequest(PreparedPaymentRequest preparedPaymentRequest) {
    CreatePaymentRequest createPaymentRequest = new CreatePaymentRequest();
    AmountOfMoney amountOfMoney = new AmountOfMoney();
    amountOfMoney.setAmount(minimalValidPaymentContext.getAmountOfMoney().getAmount());
    amountOfMoney.setCurrencyCode(minimalValidPaymentContext.getAmountOfMoney().getCurrencyCode().toString());
    Address billingAddress = new Address();
    billingAddress.setCountryCode(minimalValidPaymentContext.getCountryCode().toString());
    Customer customer = new Customer();
    customer.setBillingAddress(billingAddress);
    Order order = new Order();
    order.setAmountOfMoney(amountOfMoney);
    order.setCustomer(customer);
    createPaymentRequest.setOrder(order);
    // Set the encrypted blob in the request
    createPaymentRequest.setEncryptedCustomerInput(preparedPaymentRequest.getEncryptedFields());
    return createPaymentRequest;
}
Also used : Order(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Order) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) Customer(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Customer) CreatePaymentRequest(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest) AmountOfMoney(com.ingenico.connect.gateway.sdk.java.domain.definitions.AmountOfMoney)

Example 10 with Address

use of com.ingenico.connect.gateway.sdk.java.domain.definitions.Address in project connect-sdk-java by Ingenico-ePayments.

the class RiskAssessmentBankAccountExample method example.

@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
    Client client = getClient();
    try {
        BankAccountBban bankAccountBban = new BankAccountBban();
        bankAccountBban.setAccountNumber("0532013000");
        bankAccountBban.setBankCode("37040044");
        bankAccountBban.setCountryCode("DE");
        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.setAmountOfMoney(amountOfMoney);
        order.setCustomer(customer);
        RiskAssessmentBankAccount body = new RiskAssessmentBankAccount();
        body.setBankAccountBban(bankAccountBban);
        body.setOrder(order);
        RiskAssessmentResponse response = client.merchant("merchantId").riskassessments().bankaccounts(body);
    } finally {
        client.close();
    }
}
Also used : Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) RiskAssessmentBankAccount(com.ingenico.connect.gateway.sdk.java.domain.riskassessments.RiskAssessmentBankAccount) BankAccountBban(com.ingenico.connect.gateway.sdk.java.domain.definitions.BankAccountBban) OrderRiskAssessment(com.ingenico.connect.gateway.sdk.java.domain.riskassessments.definitions.OrderRiskAssessment) CustomerRiskAssessment(com.ingenico.connect.gateway.sdk.java.domain.riskassessments.definitions.CustomerRiskAssessment) RiskAssessmentResponse(com.ingenico.connect.gateway.sdk.java.domain.riskassessments.RiskAssessmentResponse) Client(com.ingenico.connect.gateway.sdk.java.Client) AmountOfMoney(com.ingenico.connect.gateway.sdk.java.domain.definitions.AmountOfMoney)

Aggregations

Address (com.ingenico.connect.gateway.sdk.java.domain.definitions.Address)16 Client (com.ingenico.connect.gateway.sdk.java.Client)12 AmountOfMoney (com.ingenico.connect.gateway.sdk.java.domain.definitions.AmountOfMoney)12 Customer (com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Customer)9 Order (com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Order)9 CreatePaymentRequest (com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest)8 Card (com.ingenico.connect.gateway.sdk.java.domain.definitions.Card)7 CardPaymentMethodSpecificInput (com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.CardPaymentMethodSpecificInput)6 Test (org.junit.Test)6 CompanyInformation (com.ingenico.connect.gateway.sdk.java.domain.definitions.CompanyInformation)4 CustomerToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken)4 CreatePaymentResponse (com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentResponse)3 HttpHost (org.apache.http.HttpHost)3 ApiException (com.ingenico.connect.gateway.sdk.java.ApiException)2 DeclinedPaymentException (com.ingenico.connect.gateway.sdk.java.DeclinedPaymentException)2 BankAccountBban (com.ingenico.connect.gateway.sdk.java.domain.definitions.BankAccountBban)2 CardWithoutCvv (com.ingenico.connect.gateway.sdk.java.domain.definitions.CardWithoutCvv)2 PersonalName (com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.PersonalName)2 PersonalInformationToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalInformationToken)2 PersonalNameToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalNameToken)2