Search in sources :

Example 1 with PaymentItemCacheKey

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

the class GcSession method cachePaymentItem.

private void cachePaymentItem(PaymentItem paymentItem) {
    // Add paymentItem to the paymentItemMapping cache
    if (paymentItem != null) {
        // Create the cache key for this retrieved PaymentItem
        PaymentItemCacheKey key = createPaymentItemCacheKey(paymentContext, paymentItem.getId());
        paymentItemMapping.put(key, paymentItem);
    }
}
Also used : PaymentItemCacheKey(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey)

Example 2 with PaymentItemCacheKey

use of com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey 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();
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) PaymentItemCacheKey(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey) PaymentProductGroupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductGroupAsyncTask) ArrayList(java.util.ArrayList) OnPaymentProductGroupCallCompleteListener(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductGroupAsyncTask.OnPaymentProductGroupCallCompleteListener) BasicPaymentProductGroup(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProductGroup) PaymentProductGroup(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductGroup)

Example 3 with PaymentItemCacheKey

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

the class GcSession method getPaymentProduct.

/**
 * Gets PaymentProduct with fields from the GC gateway
 *
 * @param context, used for reading device metada which is send to the GC gateway
 * @param productId, the productId of the product which needs to be retrieved from the GC gateway
 * @param paymentContext, PaymentContext which contains all neccesary data for doing call to the GC gateway to retrieve BasicPaymentProducts
 * @param listener, listener which will be called by the AsyncTask when the PaymentProduct with fields is retrieved
 */
public void getPaymentProduct(Context context, String productId, PaymentContext paymentContext, OnPaymentProductCallCompleteListener listener) {
    if (context == null) {
        throw new InvalidParameterException("Error getting paymentproduct, context may not be null");
    }
    if (productId == 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 paymentProduct
    PaymentItemCacheKey key = createPaymentItemCacheKey(paymentContext, productId);
    // If the paymentProduct is already in the cache, call the listener with that paymentproduct
    if (paymentItemMapping.containsKey(key)) {
        PaymentProduct cachedPP = (PaymentProduct) paymentItemMapping.get(key);
        listener.onPaymentProductCallComplete(cachedPP);
    } else {
        // Add OnPaymentProductsCallComplete listener and this class to list of listeners so we can store the paymentproduct here
        List<OnPaymentProductCallCompleteListener> listeners = new ArrayList<OnPaymentProductCallCompleteListener>();
        listeners.add(this);
        listeners.add(listener);
        // Do the call to the GC gateway
        PaymentProductAsyncTask task = new PaymentProductAsyncTask(context, productId, paymentContext, communicator, listeners);
        task.execute();
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) BasicPaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct) PaymentItemCacheKey(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey) ArrayList(java.util.ArrayList) PaymentProductAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask) OnPaymentProductCallCompleteListener(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask.OnPaymentProductCallCompleteListener)

Example 4 with PaymentItemCacheKey

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

the class GcSession method cacheBasicPaymentItem.

private void cacheBasicPaymentItem(BasicPaymentItem basicPaymentItem) {
    // Add basicPaymentItem to the basicPaymentItemMapping cache
    if (basicPaymentItem != null) {
        // Create the cache key for and put it in the cache
        PaymentItemCacheKey key = createPaymentItemCacheKey(paymentContext, basicPaymentItem.getId());
        basicPaymentItemMapping.put(key, basicPaymentItem);
    }
}
Also used : PaymentItemCacheKey(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey)

Aggregations

PaymentItemCacheKey (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey)4 InvalidParameterException (java.security.InvalidParameterException)2 ArrayList (java.util.ArrayList)2 PaymentProductAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask)1 OnPaymentProductCallCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask.OnPaymentProductCallCompleteListener)1 PaymentProductGroupAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductGroupAsyncTask)1 OnPaymentProductGroupCallCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductGroupAsyncTask.OnPaymentProductGroupCallCompleteListener)1 BasicPaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct)1 BasicPaymentProductGroup (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProductGroup)1 PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)1 PaymentProductGroup (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductGroup)1