use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductDirectoryAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GcSession method getDirectoryForPaymentProductId.
/**
* Gets PaymentProductDirectory from the GC gateway
*
* @param productId, for which product must the lookup be done
* @param currencyCode, for which currencyCode must the lookup be done
* @param countryCode, for which countryCode must the lookup be done
* @param context, used for reading device metada which is send to the GC gateway
* @param listener, listener which will be called by the AsyncTask when the PaymentProductDirectory with fields is retrieved
*/
public void getDirectoryForPaymentProductId(String productId, CurrencyCode currencyCode, CountryCode countryCode, Context context, OnPaymentProductDirectoryCallCompleteListener listener) {
if (productId == null) {
throw new InvalidParameterException("Error getting PaymentProductDirectory, productId may not be null");
}
if (currencyCode == null) {
throw new InvalidParameterException("Error getting PaymentProductDirectory, currencyCode may not be null");
}
if (countryCode == null) {
throw new InvalidParameterException("Error getting PaymentProductDirectory, countryCode may not be null");
}
if (listener == null) {
throw new InvalidParameterException("Error getting PaymentProductDirectory, listener may not be null");
}
if (context == null) {
throw new InvalidParameterException("Error getting PaymentProductDirectory, context may not be null");
}
PaymentProductDirectoryAsyncTask task = new PaymentProductDirectoryAsyncTask(productId, currencyCode, countryCode, context, communicator, listener);
task.execute();
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductDirectoryAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetPaymentProductDirectoryTest method testGetPaymentProductDirectoryAsyncTaskWithInvalidRequest.
/**
* Test that an invalid request for a PaymentProductDirectory will return, but will not contain a PaymentProductDirectoryResponse
*/
@Test
public void testGetPaymentProductDirectoryAsyncTaskWithInvalidRequest() throws InterruptedException {
initializeInValidMocksAndSession();
final CountDownLatch waitForAsyncTaskCallBack = new CountDownLatch(1);
Listener listener = new Listener(waitForAsyncTaskCallBack);
// Create the PaymentProductDirectoryAsyncTask and start the test by running execute
PaymentProductDirectoryAsyncTask paymentProductDirectoryAsyncTask = new PaymentProductDirectoryAsyncTask("809", CurrencyCode.EUR, CountryCode.NL, getContext(), getCommunicator(), listener);
paymentProductDirectoryAsyncTask.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 paymentProductDirectoryResponse from the listener and validate it has the correct fields
PaymentProductDirectoryResponse paymentProductDirectoryResponse = listener.getPaymentProductDirectoryResponse();
assertNull(paymentProductDirectoryResponse);
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductDirectoryAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetPaymentProductDirectoryTest method testGetPaymentProductDirectoryAsyncTaskWithValidRequest.
@Test
public void testGetPaymentProductDirectoryAsyncTaskWithValidRequest() throws InterruptedException, CommunicationException {
initializeValidMocksAndSession();
final CountDownLatch waitForAsyncTaskCallBack = new CountDownLatch(1);
Listener listener = new Listener(waitForAsyncTaskCallBack);
// Create the PaymentProductDirectoryAsyncTask and start the test by running execute
PaymentProductDirectoryAsyncTask paymentProductDirectoryAsyncTask = new PaymentProductDirectoryAsyncTask("809", CurrencyCode.EUR, CountryCode.NL, getContext(), getCommunicator(), listener);
paymentProductDirectoryAsyncTask.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 paymentProductDirectoryResponse from the listener and validate it has the correct fields
PaymentProductDirectoryResponse paymentProductDirectoryResponse = listener.getPaymentProductDirectoryResponse();
assertNotNull(paymentProductDirectoryResponse);
assertNotNull(paymentProductDirectoryResponse.getEntries());
assertFalse(paymentProductDirectoryResponse.getEntries().isEmpty());
}
Aggregations