Search in sources :

Example 1 with IinDetail

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

the class DetailInputActivityCreditCards method handleIinStatusSupported.

// This function alters the view so that it is compliable with the IinStatus "EXISTING_BUT_NOT_ALLOWED"
private void handleIinStatusSupported(IinDetailsResponse response) {
    fieldView.removeCreditCardValidationMessage(inputValidationPersister);
    fieldView.activatePayButton();
    // Find whether the brand, chosen by the user on the payment product selection screen, is in the IinResponse
    // and whether the chosen product can be payed with in the current paymentcontext
    List<IinDetail> coBrands = response.getCoBrands();
    if (coBrands != null) {
        for (IinDetail coBrand : coBrands) {
            if (coBrand.isAllowedInContext() && inputDataPersister.getPaymentItem().getId().equals(coBrand.getPaymentProductId())) {
                // Show the corresponding logo for the Payement Product
                fieldView.renderPaymentProductLogoInCreditCardField(coBrand.getPaymentProductId());
                // Show the user that he can possibly switch to an other brand with the same card number
                getCoBrandProductsAndRenderNotification(response);
                return;
            }
        }
    }
    // We now know that the user entered a completely different payment product, retrieve this
    // product and then rerender the view from the getPaymentProduct callback
    retrieveNewPaymentProduct(response.getPaymentProductId());
}
Also used : IinDetail(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetail)

Example 2 with IinDetail

use of com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetail 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

IinDetail (com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetail)2 PaymentProductAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask)1 BasicPaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)1 PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1