Search in sources :

Example 1 with Address

use of com.fitpay.android.api.models.card.Address in project fitpay-android-sdk by fitpay.

the class Steps method createCard.

public void createCard(String pan) throws InterruptedException {
    Assert.assertNotNull(currentUser);
    String cardName = "TEST CARD";
    int expYear = 2018;
    int expMonth = 10;
    String city = "Boulder";
    String state = "CO";
    String postalCode = "80302";
    String countryCode = "US";
    String street1 = "1035 Pearl St";
    String cvv = "133";
    Address address = new Address();
    address.setCity(city);
    address.setState(state);
    address.setPostalCode(postalCode);
    address.setCountryCode(countryCode);
    address.setStreet1(street1);
    CreditCard creditCard = new CreditCard.Builder().setCVV(cvv).setPAN(pan).setExpDate(expYear, expMonth).setAddress(address).setName(cardName).build();
    final BlockingQueue<CreditCard> cards = new ArrayBlockingQueue<>(1);
    currentUser.createCreditCard(creditCard, new ApiCallback<CreditCard>() {

        @Override
        public void onSuccess(CreditCard result) {
            cards.add(result);
        }

        @Override
        public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
            fail(errorMessage);
        }
    });
    CreditCard card = cards.poll(TIMEOUT, TimeUnit.SECONDS);
    Assert.assertNotNull(card);
    Assert.assertEquals(cardName, card.getName());
    Assert.assertEquals(city, card.getAddress().getCity());
    Assert.assertEquals(state, card.getAddress().getState());
    Assert.assertEquals(postalCode, card.getAddress().getPostalCode());
    Assert.assertEquals(countryCode, card.getAddress().getCountryCode());
    Assert.assertEquals(street1, card.getAddress().getStreet1());
    Assert.assertNotNull(card.getCVV());
    Assert.assertEquals(card.getPan().substring(12), pan.substring(12));
    Assert.assertTrue(expYear == card.getExpYear());
    Assert.assertTrue(expMonth == card.getExpMonth());
    Assert.assertEquals("ELIGIBLE", card.getState());
    currentCard = card;
}
Also used : Address(com.fitpay.android.api.models.card.Address) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 2 with Address

use of com.fitpay.android.api.models.card.Address in project fitpay-android-sdk by fitpay.

the class Steps method updateCard.

public void updateCard() throws InterruptedException {
    Assert.assertNotNull(currentCard);
    final CountDownLatch latch = new CountDownLatch(1);
    final boolean[] isRequestSuccess = { false };
    String city = "New York";
    String state = "NY";
    Address address = new Address();
    address.setCity(city);
    address.setState(state);
    CreditCard creditCard = new CreditCard.Builder().setName("Hello").build();
    currentCard.updateCard(creditCard, new ApiCallback<CreditCard>() {

        @Override
        public void onSuccess(CreditCard result) {
            isRequestSuccess[0] = true;
            currentCard = result;
            latch.countDown();
        }

        @Override
        public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
            // {"errors":[{"message":"patch request contains unsupported operations: [SecureJsonPatchOperation(op=replace, path=addresscity, value=New York), SecureJsonPatchOperation(op=replace, path=addressstate, value=NY)]"}]}
            latch.countDown();
        }
    });
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    Assert.assertNotNull(currentCard);
    Assert.assertTrue(isRequestSuccess[0]);
    Assert.assertEquals(state, currentCard.getAddress().getState());
    Assert.assertEquals(city, currentCard.getAddress().getCity());
}
Also used : Address(com.fitpay.android.api.models.card.Address) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 3 with Address

use of com.fitpay.android.api.models.card.Address in project fitpay-android-sdk by fitpay.

the class TestActions method getTestCreditCard.

protected CreditCard getTestCreditCard(String pan) {
    String cardName = "TEST CARD";
    int expYear = 2018;
    int expMonth = 10;
    String city = "Boulder";
    String state = "CO";
    String postalCode = "80302";
    String countryCode = "US";
    String street1 = "1035 Pearl St";
    String cvv = "133";
    Address address = new Address();
    address.setCity(city);
    address.setState(state);
    address.setPostalCode(postalCode);
    address.setCountryCode(countryCode);
    address.setStreet1(street1);
    CreditCard creditCard = new CreditCard.Builder().setCVV(cvv).setPAN(pan).setExpDate(expYear, expMonth).setAddress(address).setName(cardName).build();
    return creditCard;
}
Also used : Address(com.fitpay.android.api.models.card.Address) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Aggregations

Address (com.fitpay.android.api.models.card.Address)3 CreditCard (com.fitpay.android.api.models.card.CreditCard)3 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1