Search in sources :

Example 26 with CreditCard

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

the class TestActions method deactivateCard.

protected CreditCard deactivateCard(CreditCard creditCard, Reason reason) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.deactivate(reason, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 27 with CreditCard

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

the class TestActions method getCreditCard.

protected CreditCard getCreditCard(CreditCard creditCard) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.self(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertEquals("get credit card had error code.  (message: " + callback.getErrorMessage() + ")", -1, callback.getErrorCode());
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 28 with CreditCard

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

the class CreditCardTest2 method canGetCardTransactions.

@Test
public void canGetCardTransactions() 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 = "9999411111111112";
    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());
    Collections.TransactionCollection transactions = getCardTransactions(createdCard);
    assertNotNull("card should have transactions", transactions);
    assertTrue("card should have at least one transaction", transactions.getResults().size() > 0);
    Transaction transaction = transactions.getResults().get(0);
    Transaction retreivedTransaction = getTransaction(transaction);
    assertEquals("should be the same transaction", transaction.getTransactionId(), retreivedTransaction.getTransactionId());
}
Also used : Transaction(com.fitpay.android.api.models.Transaction) 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 29 with CreditCard

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

the class CreditCardTest2 method testCanGetCards2.

@Test
public void testCanGetCards2() 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());
    assertTrue("credit card id", createdCard.getCreditCardId().equals(creditCards.getResults().get(0).getCreditCardId()) || createdCard.getCreditCardId().equals(creditCards.getResults().get(1).getCreditCardId()));
}
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 30 with CreditCard

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

the class CreditCardTest2 method testAcceptTermsOnDeclinedCardDoesNothing.

@Test
public void testAcceptTermsOnDeclinedCardDoesNothing() 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 = "9999504454545459";
    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", "DECLINED", createdCard.getState());
    createdCard = acceptTerms(createdCard);
    assertNull("no result expected", createdCard);
}
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