Search in sources :

Example 1 with Transaction

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

the class TestActions method getTransaction.

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

Example 2 with Transaction

use of com.fitpay.android.api.models.Transaction 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)

Aggregations

Transaction (com.fitpay.android.api.models.Transaction)2 ResultProvidingCallback (com.fitpay.android.api.callbacks.ResultProvidingCallback)1 CreditCard (com.fitpay.android.api.models.card.CreditCard)1 Collections (com.fitpay.android.api.models.collection.Collections)1 Device (com.fitpay.android.api.models.device.Device)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1