Search in sources :

Example 16 with CreditCard

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

the class TestActions method reactivateCard.

protected CreditCard reactivateCard(CreditCard creditCard, Reason reason) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.reactivate(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 17 with CreditCard

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

the class TestActions method waitForActivation.

protected CreditCard waitForActivation(CreditCard card) throws Exception {
    assertNotNull("no card to wait for activation on", card);
    CreditCard retrievedCard = card;
    for (int x = 0; x < 30; x++) {
        retrievedCard = getCreditCard(retrievedCard);
        if ("ACTIVE".equals(retrievedCard.getState())) {
            break;
        }
        Thread.sleep(1000);
    }
    assertEquals("card never transitioned to ACTIVE state", "ACTIVE", retrievedCard.getState());
    return retrievedCard;
}
Also used : CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 18 with CreditCard

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

the class TestActions method acceptTerms.

protected CreditCard acceptTerms(CreditCard creditCard) throws Exception {
    final CountDownLatch latch = new CountDownLatch(2);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.acceptTerms(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    CreditCard acceptedCard = callback.getResult();
    if (acceptedCard == null) {
        return null;
    }
    TestConstants.waitSomeActionsOnServer();
    // getSelf
    ResultProvidingCallback<CreditCard> callbackSelf = new ResultProvidingCallback<>(latch);
    acceptedCard.self(callbackSelf);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callbackSelf.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 19 with CreditCard

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

the class TestActions method getTestCreditCard.

protected CreditCard getTestCreditCard(String pan) {
    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();
    return creditCard;
}
Also used : Address(com.fitpay.android.api.models.card.Address) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 20 with CreditCard

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

the class CreditCardTest3 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 = "9999445454545454";
    CreditCard creditCard = getTestCreditCard(pan);
    creditCard = createCreditCard(user, creditCard);
    assertNotNull("card not created", creditCard);
    assertEquals("card not in expected state", "ELIGIBLE", creditCard.getState());
    // save acceptTerms
    final String acceptTermsUrl = creditCard.getAcceptTermsUrl();
    // get the same card but without sessionData
    creditCard = getCreditCard(creditCard);
    // update acceptTerms url
    creditCard.setAcceptTermsUrl(acceptTermsUrl);
    // accept terms
    creditCard = acceptTerms(creditCard);
    assertNotNull("card not successfully updated by accept terms", creditCard);
    assertEquals("card state", "PENDING_VERIFICATION", creditCard.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)

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