use of com.fitpay.android.api.models.card.VerificationMethod 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.VerificationMethod in project fitpay-android-sdk by fitpay.
the class Steps method selectCard.
public void selectCard() throws InterruptedException {
Assert.assertNotNull(currentCard);
final CountDownLatch latch = new CountDownLatch(1);
final VerificationMethod[] verificationMethods = { null };
final boolean[] isRequestSuccess = { false };
currentCard.getVerificationMethods().get(0).select(new ApiCallback<VerificationMethod>() {
@Override
public void onSuccess(VerificationMethod result) {
isRequestSuccess[0] = true;
verificationMethods[0] = result;
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
Assert.assertTrue(isRequestSuccess[0]);
Assert.assertNotNull(currentCard);
Assert.assertEquals("AWAITING_VERIFICATION", verificationMethods[0].getState());
}
use of com.fitpay.android.api.models.card.VerificationMethod in project fitpay-android-sdk by fitpay.
the class TestActions method selectVerificationMethod.
protected VerificationMethod selectVerificationMethod(VerificationMethod method) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<VerificationMethod> callback = new ResultProvidingCallback<>(latch);
method.select(callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
return callback.getResult();
}
use of com.fitpay.android.api.models.card.VerificationMethod in project fitpay-android-sdk by fitpay.
the class TestActions method verifyVerificationMethod.
protected VerificationMethod verifyVerificationMethod(VerificationMethod method, String verificationCode) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<VerificationMethod> callback = new ResultProvidingCallback<>(latch);
method.verify(verificationCode, callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
return callback.getResult();
}
use of com.fitpay.android.api.models.card.VerificationMethod in project fitpay-android-sdk by fitpay.
the class Steps method verifyCard.
public void verifyCard() throws InterruptedException {
Assert.assertNotNull(currentCard);
final CountDownLatch latch = new CountDownLatch(1);
final VerificationMethod[] verificationMethods = { null };
final boolean[] isRequestSuccess = { false };
currentCard.getVerificationMethods().get(0).verify("12345", new ApiCallback<VerificationMethod>() {
@Override
public void onSuccess(VerificationMethod result) {
isRequestSuccess[0] = true;
verificationMethods[0] = result;
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
Assert.assertTrue(isRequestSuccess[0]);
Assert.assertNotNull(currentCard);
Assert.assertTrue("VERIFIED".equals(verificationMethods[0].getState()) || "AWAITING_VERIFICATION".equals(verificationMethods[0].getState()));
}
Aggregations