Search in sources :

Example 1 with CreditCard

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());
}
Also used : Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) CreditCard(com.fitpay.android.api.models.card.CreditCard) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with CreditCard

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());
}
Also used : Device(com.fitpay.android.api.models.device.Device) VerificationMethod(com.fitpay.android.api.models.card.VerificationMethod) Collections(com.fitpay.android.api.models.collection.Collections) CreditCard(com.fitpay.android.api.models.card.CreditCard) Reason(com.fitpay.android.api.models.card.Reason) Test(org.junit.Test)

Example 3 with CreditCard

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());
}
Also used : Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) CreditCard(com.fitpay.android.api.models.card.CreditCard) Test(org.junit.Test)

Example 4 with CreditCard

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());
}
Also used : Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) CreditCard(com.fitpay.android.api.models.card.CreditCard) Test(org.junit.Test)

Example 5 with CreditCard

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());
}
Also used : Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) CreditCard(com.fitpay.android.api.models.card.CreditCard) Test(org.junit.Test)

Aggregations

CreditCard (com.fitpay.android.api.models.card.CreditCard)39 Test (org.junit.Test)21 CountDownLatch (java.util.concurrent.CountDownLatch)20 Device (com.fitpay.android.api.models.device.Device)19 Collections (com.fitpay.android.api.models.collection.Collections)18 ResultProvidingCallback (com.fitpay.android.api.callbacks.ResultProvidingCallback)8 ArrayList (java.util.ArrayList)5 Address (com.fitpay.android.api.models.card.Address)3 Reason (com.fitpay.android.api.models.card.Reason)3 Commit (com.fitpay.android.api.models.device.Commit)3 UserStreamEvent (com.fitpay.android.api.models.UserStreamEvent)2 UserEventStreamListener (com.fitpay.android.api.sse.UserEventStreamListener)2 MockPaymentDeviceConnector (com.fitpay.android.paymentdevice.impl.mock.MockPaymentDeviceConnector)2 SyncRequest (com.fitpay.android.paymentdevice.models.SyncRequest)2 Activity (android.app.Activity)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 Image (android.media.Image)1 ApiManager (com.fitpay.android.api.ApiManager)1 ApiCallback (com.fitpay.android.api.callbacks.ApiCallback)1