Search in sources :

Example 1 with CreateTokenRequest

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

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

the class BaseAsyncTaskTest method initializeValidMocksAndSessionWithToken.

/**
 * Create a mocked configuration that produces valid requests and contains an AccountOnFile
 */
void initializeValidMocksAndSessionWithToken() throws CommunicationException {
    CreateTokenRequest body = GsonHelper.fromResourceJson("getTokenJSONCard.json", CreateTokenRequest.class);
    try {
        token = tokenUtil.createToken(testMerchantId, body);
    } catch (ApiException e) {
        throw new CommunicationException("ApiException while creating token. Token is: " + token, e);
    }
    initializeValidMocksAndSession();
}
Also used : CreateTokenRequest(com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenRequest) CommunicationException(com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException) ApiException(com.ingenico.connect.gateway.sdk.java.ApiException)

Example 3 with CreateTokenRequest

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

Aggregations

CreateTokenRequest (com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenRequest)3 Client (com.ingenico.connect.gateway.sdk.java.Client)2 Address (com.ingenico.connect.gateway.sdk.java.domain.definitions.Address)2 CreateTokenResponse (com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenResponse)2 CustomerToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken)2 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)1 ApiException (com.ingenico.connect.gateway.sdk.java.ApiException)1 BankAccountBban (com.ingenico.connect.gateway.sdk.java.domain.definitions.BankAccountBban)1 CardWithoutCvv (com.ingenico.connect.gateway.sdk.java.domain.definitions.CardWithoutCvv)1 CompanyInformation (com.ingenico.connect.gateway.sdk.java.domain.definitions.CompanyInformation)1 MandateNonSepaDirectDebit (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.MandateNonSepaDirectDebit)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 TokenCard (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard)1 TokenCardData (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData)1 TokenNonSepaDirectDebit (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenNonSepaDirectDebit)1 TokenNonSepaDirectDebitPaymentProduct705SpecificData (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenNonSepaDirectDebitPaymentProduct705SpecificData)1 DeleteTokenParams (com.ingenico.connect.gateway.sdk.java.merchant.tokens.DeleteTokenParams)1 Test (org.junit.Test)1