use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductGroupAsyncTask.OnPaymentProductGroupCallCompleteListener in project connect-sdk-client-android by Ingenico-ePayments.
the class GcSession method getPaymentProductGroup.
/**
* Gets PaymentProductGroup with fields from the GC gateway
*
* @param context, used for reading device metada which is send to the GC gateway
* @param groupId, the productId of the group which needs to be retrieved from the GC gateway
* @param paymentContext, PaymentContext which contains all necessary data for doing call to the GC gateway to retrieve PaymentProductGroup
* @param listener, listener which will be called by the AsyncTask when the PaymentProductGroup with fields is retrieved
*/
public void getPaymentProductGroup(Context context, String groupId, PaymentContext paymentContext, OnPaymentProductGroupCallCompleteListener listener) {
if (context == null) {
throw new InvalidParameterException("Error getting paymentproduct, context may not be null");
}
if (groupId == null) {
throw new InvalidParameterException("Error getting paymentproduct, groupId may not be null");
}
if (paymentContext == null) {
throw new InvalidParameterException(("Error getting paymentproduct, paymentContext may not be null"));
}
if (listener == null) {
throw new InvalidParameterException("Error getting paymentproduct, listener may not be null");
}
this.paymentContext = paymentContext;
// Create the cache key for this paymentProductGroup
PaymentItemCacheKey key = createPaymentItemCacheKey(paymentContext, groupId);
// If the paymentProductGroup is already in the cache, call the listener with that paymentProductGroup
if (paymentItemMapping.containsKey(key)) {
PaymentProductGroup cachedPPG = (PaymentProductGroup) paymentItemMapping.get(key);
listener.onPaymentProductGroupCallComplete(cachedPPG);
} else {
// Add OnPaymentProductsCallComplete listener and this class to list of listeners so we can store the paymentproduct here
List<OnPaymentProductGroupCallCompleteListener> listeners = new ArrayList<>();
listeners.add(this);
listeners.add(listener);
// Do the call to the GC gateway
PaymentProductGroupAsyncTask task = new PaymentProductGroupAsyncTask(context, groupId, paymentContext, communicator, listeners);
task.execute();
}
}
Aggregations