Search in sources :

Example 1 with IinLookupAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSession method getIinDetails.

/**
 * Gets the IinDetails for a given partialCreditCardNumber
 *
 * @param context, used for reading device metada which is send to the GC gateway
 * @param partialCreditCardNumber, entered partial creditcardnumber for which the IinDetails will be retrieved
 * @param listener, listener which will be called by the AsyncTask when the IIN result is retrieved
 * @param paymentContext, payment information for which the IinDetails will be retrieved
 */
public void getIinDetails(Context context, String partialCreditCardNumber, OnIinLookupCompleteListener listener, PaymentContext paymentContext) {
    if (context == null) {
        throw new InvalidParameterException("Error getting iinDetails, context may not be null");
    }
    if (partialCreditCardNumber == null) {
        throw new InvalidParameterException("Error getting iinDetails, productId may not be null");
    }
    if (listener == null) {
        throw new InvalidParameterException("Error getting iinDetails, listener may not be null");
    }
    // Add OnPaymentProductsCallComplete listener and this class to list of listeners so we can reset the iinLookupPending flag
    List<OnIinLookupCompleteListener> listeners = new ArrayList<OnIinLookupCompleteListener>();
    listeners.add(this);
    listeners.add(listener);
    if (!iinLookupPending) {
        IinLookupAsyncTask task = new IinLookupAsyncTask(context, partialCreditCardNumber, communicator, listeners, paymentContext);
        task.execute();
        iinLookupPending = true;
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) OnIinLookupCompleteListener(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask.OnIinLookupCompleteListener) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask)

Example 2 with IinLookupAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskUNKNOWNWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskUNKNOWNWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Invalid number
    "123456", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the IinLookup returns with status UNKNOW within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate its status
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusUNKNOWN(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 3 with IinLookupAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskSUPPORTEDWithInValidRequest.

@Test
public void testGetIinDetailsAsyncTaskSUPPORTEDWithInValidRequest() throws InterruptedException {
    initializeInValidMocksAndSession();
    final CountDownLatch waitForAsyncTaskCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute.
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncTaskCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Visa number
    "401200", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the response is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncTaskCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the iin details response from the listener
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    // Test that the status assigned to response is UNKNOWN as it should be since the lookup failed
    validateResponseStatusUNKNOWN(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 4 with IinLookupAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskEXISTING_BUT_NOT_ALLOWEDWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskEXISTING_BUT_NOT_ALLOWEDWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    PaymentContext customPaymentContext = new PaymentContext(new AmountOfMoney(1000L, CurrencyCode.USD), CountryCode.US, false);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Number that is valid, but not allowed in the customPaymentContext
    "653598", getCommunicator(), listeners, customPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the IinLookup returns with status EXISTING_BUT_NOT_ALLOWED wiithin 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate its status
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusEXISTING_BUT_NOT_ALLOWED(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) PaymentContext(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentContext) AmountOfMoney(com.globalcollect.gateway.sdk.client.android.sdk.model.AmountOfMoney) Test(org.junit.Test)

Example 5 with IinLookupAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskNOT_ENOUGH_DIGITSWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskNOT_ENOUGH_DIGITSWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Number that is too short
    "1", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the IinLookup returns with status NOT_ENOUGH_DIGITS wiithin 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate its status
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusNOT_ENOUGH_DIGITS(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

IinLookupAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask)6 ArrayList (java.util.ArrayList)6 IinDetailsResponse (com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Test (org.junit.Test)5 OnIinLookupCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask.OnIinLookupCompleteListener)1 AmountOfMoney (com.globalcollect.gateway.sdk.client.android.sdk.model.AmountOfMoney)1 PaymentContext (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentContext)1 InvalidParameterException (java.security.InvalidParameterException)1