use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCanAcceptTerms.
@Test
public void testCanAcceptTerms() throws Exception {
Device device = getTestDevice();
Device createdDevice = createDevice(user, device);
assertNotNull("created device", createdDevice);
Collections.DeviceCollection devices = getDevices(user);
assertNotNull("devices collection should not be null", devices);
assertEquals("should have one device", 1, devices.getTotalResults());
String pan = "9999545454545454";
CreditCard creditCard = getTestCreditCard(pan);
CreditCard createdCard = createCreditCard(user, creditCard);
assertNotNull("card not created", createdCard);
assertEquals("card not in expected state", "ELIGIBLE", createdCard.getState());
createdCard = acceptTerms(createdCard);
assertNotNull("card not successfully updated by accept terms", createdCard);
assertEquals("card state", "PENDING_VERIFICATION", createdCard.getState());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCanAddCreditCard.
@Test
public void testCanAddCreditCard() throws Exception {
Device device = getTestDevice();
Device createdDevice = createDevice(user, device);
assertNotNull("created device", createdDevice);
Collections.DeviceCollection devices = getDevices(user);
assertNotNull("devices collection should not be null", devices);
assertEquals("should have one device", 1, devices.getTotalResults());
String pan = "9999504454545450";
CreditCard creditCard = getTestCreditCard(pan);
CreditCard createdCard = createCreditCard(user, creditCard);
verifyCardContents(creditCard, createdCard);
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<Image> callback = new ResultProvidingCallback<>(latch);
createdCard.getCardMetaData().getBrandLogo().get(0).self(callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
// TODO enable test for image retrieval
// assertEquals(-1, callback.getErrorCode());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class Steps method acceptTerms.
public void acceptTerms() throws InterruptedException {
getDevices();
Assert.assertNotNull(currentUser);
Assert.assertNotNull(currentCard);
Assert.assertNotNull(currentDevice);
final CountDownLatch latch = new CountDownLatch(2);
final boolean[] isRequestSuccess = { false };
ApiManager.getInstance().createRelationship(currentUser.getId(), currentCard.getCreditCardId(), currentDevice.getDeviceIdentifier(), new ApiCallback<Relationship>() {
@Override
public void onSuccess(Relationship result) {
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
currentCard.acceptTerms(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) {
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
Assert.assertNotNull(currentCard);
Assert.assertTrue(isRequestSuccess[0]);
Assert.assertEquals("PENDING_VERIFICATION", currentCard.getState());
}
use of com.fitpay.android.api.models.card.CreditCard 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;
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class Steps method reactivateCard.
public void reactivateCard() throws InterruptedException {
Assert.assertNotNull(currentCard);
final CountDownLatch latch = new CountDownLatch(1);
final boolean[] isRequestSuccess = { false };
final List<String> errors = new ArrayList<>();
Reason reason = new Reason();
reason.setReason("found");
reason.setCausedBy(CardInitiators.INITIATOR_CARDHOLDER);
currentCard.reactivate(reason, 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.add("error code: " + errorCode + ", message: " + errorMessage);
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
Assert.assertTrue("failed reactivate request: " + errors, isRequestSuccess[0]);
Assert.assertNotNull(currentCard);
}
Aggregations