Search in sources :

Example 1 with TokenCard

use of com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard 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();
    }
}
Also used : TokenCard(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard) CardWithoutCvv(com.ingenico.connect.gateway.sdk.java.domain.definitions.CardWithoutCvv) TokenCardData(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData) UpdateTokenRequest(com.ingenico.connect.gateway.sdk.java.domain.token.UpdateTokenRequest) 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) Client(com.ingenico.connect.gateway.sdk.java.Client) PersonalNameToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalNameToken)

Example 2 with TokenCard

use of com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard 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 3 with TokenCard

use of com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard 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)

Aggregations

Address (com.ingenico.connect.gateway.sdk.java.domain.definitions.Address)3 CustomerToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken)3 TokenCard (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard)3 TokenCardData (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData)3 Client (com.ingenico.connect.gateway.sdk.java.Client)2 CardWithoutCvv (com.ingenico.connect.gateway.sdk.java.domain.definitions.CardWithoutCvv)2 Test (org.junit.Test)2 CompanyInformation (com.ingenico.connect.gateway.sdk.java.domain.definitions.CompanyInformation)1 CreateTokenRequest (com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenRequest)1 CreateTokenResponse (com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenResponse)1 TokenResponse (com.ingenico.connect.gateway.sdk.java.domain.token.TokenResponse)1 UpdateTokenRequest (com.ingenico.connect.gateway.sdk.java.domain.token.UpdateTokenRequest)1 PersonalInformationToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalInformationToken)1 PersonalNameToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.PersonalNameToken)1 DeleteTokenParams (com.ingenico.connect.gateway.sdk.java.merchant.tokens.DeleteTokenParams)1