Search in sources :

Example 6 with BasicPaymentItemsAsyncTask

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

the class GcSession method getBasicPaymentItems.

/**
 * Gets all basitPaymentItems for a given payment context
 *
 * @param context Used for reading device metadata which is send to the GC gateway
 * @param paymentContext PaymentContext which contains all neccessary payment info to retrieve the allowed payment items
 * @param listener Listener that will be called when the lookup is done
 * @param groupPaymentProducts boolean that controls whether the basicPaymentItem call will group the retrieved payment items; true for grouping, false otherwise
 */
public void getBasicPaymentItems(Context context, PaymentContext paymentContext, OnBasicPaymentItemsCallCompleteListener listener, boolean groupPaymentProducts) {
    if (context == null) {
        throw new InvalidParameterException("Error getting paymentproduct, context may not be null");
    }
    if (paymentContext == null) {
        throw new InvalidParameterException("Error getting paymentproducts, paymentContext may not be null");
    }
    if (listener == null) {
        throw new InvalidParameterException("Error getting paymentproducts, listener may not be null");
    }
    this.paymentContext = paymentContext;
    // Add OnBasicPaymentItemsCallCompleteListener and this class to list of listeners so we can store the paymentproducts here
    List<OnBasicPaymentItemsCallCompleteListener> listeners = new ArrayList<>();
    listeners.add(this);
    listeners.add(listener);
    // Start the task which gets paymentproducts
    BasicPaymentItemsAsyncTask task = new BasicPaymentItemsAsyncTask(context, paymentContext, communicator, listeners, groupPaymentProducts);
    task.execute();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) OnBasicPaymentItemsCallCompleteListener(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener) ArrayList(java.util.ArrayList) BasicPaymentItemsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask)

Aggregations

BasicPaymentItemsAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask)6 ArrayList (java.util.ArrayList)6 BasicPaymentItems (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Test (org.junit.Test)5 OnBasicPaymentItemsCallCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener)1 InvalidParameterException (java.security.InvalidParameterException)1