Search in sources :

Example 11 with Address

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();
    }
}
Also used : CreateTokenRequest(com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenRequest) TokenCard(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard) TokenCardData(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData) CardWithoutCvv(com.ingenico.connect.gateway.sdk.java.domain.definitions.CardWithoutCvv) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) CustomerToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken) DeleteTokenParams(com.ingenico.connect.gateway.sdk.java.merchant.tokens.DeleteTokenParams) Client(com.ingenico.connect.gateway.sdk.java.Client) CreateTokenResponse(com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenResponse) Test(org.junit.Test)

Example 12 with Address

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();
    }
}
Also used : Order(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Order) CreateHostedCheckoutRequest(com.ingenico.connect.gateway.sdk.java.domain.hostedcheckout.CreateHostedCheckoutRequest) CreateHostedCheckoutResponse(com.ingenico.connect.gateway.sdk.java.domain.hostedcheckout.CreateHostedCheckoutResponse) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) Customer(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Customer) HostedCheckoutSpecificInput(com.ingenico.connect.gateway.sdk.java.domain.hostedcheckout.definitions.HostedCheckoutSpecificInput) Client(com.ingenico.connect.gateway.sdk.java.Client) AmountOfMoney(com.ingenico.connect.gateway.sdk.java.domain.definitions.AmountOfMoney)

Example 13 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 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");
}
Also used : Order(com.ingenico.connect.gateway.sdk.java.domain.payment.definitions.Order) DeclinedPaymentException(com.ingenico.connect.gateway.sdk.java.DeclinedPaymentException) 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 14 with Address

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());
}
Also used : TokenCard(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard) TokenCardData(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) TokenResponse(com.ingenico.connect.gateway.sdk.java.domain.token.TokenResponse) CustomerToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken) Test(org.junit.Test)

Example 15 with Address

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;
}
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) 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)

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