use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCantAcceptTermsOnIneligibleCard.
@Test
// TODO Looks like changes for last digit 7 (ineligible) have not been deployed to demo
@Ignore
public void testCantAcceptTermsOnIneligibleCard() 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 = "9999504454545457";
CreditCard creditCard = getTestCreditCard(pan);
CreditCard createdCard = createCreditCard(user, creditCard);
assertNotNull("card not created", createdCard);
assertEquals("card not in expected state", "INELIGIBLE", createdCard.getState());
createdCard = acceptTerms(createdCard);
assertNotNull("card not successfully updated by accept terms", createdCard);
assertEquals("card state", "DECLINED", createdCard.getState());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCanVerifyAndDeactivate.
@Test
public void testCanVerifyAndDeactivate() 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 decline terms", createdCard);
assertEquals("card state", "PENDING_VERIFICATION", createdCard.getState());
assertTrue("no verification methods", createdCard.getVerificationMethods().size() > 0);
assertEquals("verification state", "AVAILABLE_FOR_SELECTION", createdCard.getVerificationMethods().get(0).getState());
VerificationMethod method = selectVerificationMethod(createdCard.getVerificationMethods().get(0));
assertEquals("verification state after selection", "AWAITING_VERIFICATION", method.getState());
CreditCard retrievedCard = getCreditCard(createdCard);
assertEquals("number of verification methods", createdCard.getVerificationMethods().size(), retrievedCard.getVerificationMethods().size());
VerificationMethod selectedMethod = null;
for (VerificationMethod m : retrievedCard.getVerificationMethods()) {
if (m.getMethodType().equals(method.getMethodType()) && m.getState().equals("AWAITING_VERIFICATION")) {
selectedMethod = m;
break;
}
}
assertNotNull("No selected method found", selectedMethod);
selectedMethod = verifyVerificationMethod(selectedMethod, "12345");
assertEquals("post verification state", "VERIFIED", selectedMethod.getState());
retrievedCard = waitForActivation(retrievedCard);
assertEquals("post verification card state", "ACTIVE", retrievedCard.getState());
Reason reason = new Reason();
reason.setCausedBy(CardInitiators.INITIATOR_CARDHOLDER);
reason.setReason("tired of racking up miles");
retrievedCard = deactivateCard(retrievedCard, reason);
assertEquals("post deactivation card state", "DEACTIVATED", retrievedCard.getState());
retrievedCard = getCreditCard(retrievedCard);
assertEquals("post deactivation card state", "DEACTIVATED", retrievedCard.getState());
retrievedCard = reactivateCard(retrievedCard, reason);
assertEquals("post verification card state", "ACTIVE", retrievedCard.getState());
retrievedCard = getCreditCard(retrievedCard);
assertEquals("post reactivation card state", "ACTIVE", retrievedCard.getState());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCanDeclineTerms.
@Test
public void testCanDeclineTerms() 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 = declineTerms(createdCard);
assertNotNull("card not successfully updated by decline terms", createdCard);
assertEquals("card state", "DECLINED_TERMS_AND_CONDITIONS", createdCard.getState());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method canMakeDefault.
@Test
public void canMakeDefault() 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 = "9999545454545450";
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);
createdCard = waitForActivation(createdCard);
assertEquals("post deactivation card state", "ACTIVE", createdCard.getState());
assertTrue("should be default", createdCard.isDefault());
pan = "9999504454545451";
creditCard = getTestCreditCard(pan);
CreditCard secondCard = createCreditCard(user, creditCard);
assertNotNull("card not created", secondCard);
assertEquals("card not in expected state", "ELIGIBLE", secondCard.getState());
secondCard = acceptTerms(secondCard);
secondCard = waitForActivation(secondCard);
assertEquals("post deactivation card state", "ACTIVE", secondCard.getState());
assertFalse("second card should not be default", secondCard.isDefault());
makeDefaultCard(secondCard);
createdCard = getCreditCard(createdCard);
assertFalse("first card should not be default", createdCard.isDefault());
secondCard = getCreditCard(secondCard);
assertTrue("second card should be default", secondCard.isDefault());
makeDefaultCard(createdCard);
createdCard = getCreditCard(createdCard);
assertTrue("first card should be default", createdCard.isDefault());
secondCard = getCreditCard(secondCard);
assertFalse("second card should not be default", secondCard.isDefault());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCanDeleteFromCollection.
@Test
public void testCanDeleteFromCollection() 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);
assertNotNull("card not created", createdCard);
pan = "9999504454545451";
creditCard = getTestCreditCard(pan);
createdCard = createCreditCard(user, creditCard);
assertNotNull("card not created", createdCard);
Collections.CreditCardCollection creditCards = getCreditCards(user);
assertNotNull("credit cards collection", creditCards);
assertEquals("number of credit cards", 2, creditCards.getTotalResults());
deleteCard(createdCard);
creditCards = getCreditCards(user);
assertNotNull("credit cards collection", creditCards);
assertEquals("number of credit cards", 1, creditCards.getTotalResults());
}
Aggregations