Search in sources :

Example 11 with PaymentProduct

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

the class DetailInputActivityCreditCards method getCoBrandProductsAndRenderNotification.

private void getCoBrandProductsAndRenderNotification(IinDetailsResponse response) {
    // If the currently known iinDetailsResponse within this activity is not null, check whether cobrand notifications need to be shown.
    if (response != null) {
        // Retrieve the cobrands from the iinDetailsResponse
        final List<IinDetail> coBrands = response.getCoBrands();
        // Remove all cobrands that cannot be payed with
        if (coBrands != null && !coBrands.isEmpty()) {
            // Create a list to store all allowed paymentProducts
            final List<BasicPaymentItem> paymentProductsAllowedInContext = new ArrayList<>(4);
            // Counter
            final AtomicInteger count = new AtomicInteger(coBrands.size());
            // Add the allowed paymentProducts to the list
            for (IinDetail iinDetail : coBrands) {
                if (iinDetail.isAllowedInContext()) {
                    // Load the paymentProducts that are allowed in context, so they can be rendered in the possible coBrand list
                    session.getPaymentProduct(this.getApplicationContext(), iinDetail.getPaymentProductId(), paymentContext, new PaymentProductAsyncTask.OnPaymentProductCallCompleteListener() {

                        @Override
                        public void onPaymentProductCallComplete(PaymentProduct paymentProduct) {
                            if (paymentProduct != null) {
                                paymentProductsAllowedInContext.add(paymentProduct);
                            }
                            if (count.decrementAndGet() < 1) {
                                // All of the payment products have been retrieved
                                fieldView.renderCoBrandNotification(paymentProductsAllowedInContext, DetailInputActivityCreditCards.this);
                            }
                        }
                    });
                }
            }
        }
    }
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) IinDetail(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetail) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) PaymentProductAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask) BasicPaymentItem(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)

Aggregations

PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)11 PaymentProductAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask)5 ArrayList (java.util.ArrayList)5 BasicPaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3 Intent (android.content.Intent)2 InvalidParameterException (java.security.InvalidParameterException)2 MerchantAction (com.globalcollect.gateway.sdk.client.android.exampleapp.model.MerchantAction)1 OnPaymentProductCallCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask.OnPaymentProductCallCompleteListener)1 PaymentItemCacheKey (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey)1 PaymentRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest)1 PreparedPaymentRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.PreparedPaymentRequest)1 IinDetail (com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetail)1 BasicPaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)1 BasicPaymentProductGroup (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProductGroup)1 PaymentProductField (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)1 PaymentProductGroup (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductGroup)1 PaymentMethodToken (com.google.android.gms.wallet.PaymentMethodToken)1 Gson (com.google.gson.Gson)1