Search in sources :

Example 1 with PaymentProductField

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

the class DetailInputActivityAfterpay method onCustomerDetailsCallComplete.

@Override
public void onCustomerDetailsCallComplete(CustomerDetailsResponse customerDetailsResponse) {
    if (customerDetailsResponse != null) {
        fieldView.hideSearchErrorMessage();
        searchErrorMessageShowing = false;
        hideTooltipAndErrorViews();
        // Retrieve the results and fill in the fields with the values
        customerDetailsResponseMap = customerDetailsResponse.getFieldsAsMap();
        for (PaymentProductField field : inputDataPersister.getPaymentItem().getPaymentProductFields()) {
            String value = customerDetailsResponseMap.get(field.getId());
            if (value != null) {
                fieldView.setSearchResultValue(field.getId(), value);
            }
        }
        // Determine whether the search result was complete or that more details are required
        inputValidationPersister.storeAndValidateInput(inputDataPersister);
        if (searchResultComplete()) {
            fieldView.hideSearchSection();
            searchSectionShowing = false;
            fieldView.hideDetailInputFields();
            detailInputFieldsShowing = false;
            fieldView.renderSearchResultsSection(createSearchResultsText());
            searchResultSectionShowing = true;
        } else {
            fieldView.renderDetailInputFields();
            detailInputFieldsShowing = true;
            // Render the validation messages on the fields that should still be entered
            fieldView.renderValidationMessages(inputValidationPersister, inputDataPersister.getPaymentItem());
        }
    } else {
        fieldView.renderSearchErrorMessage();
        searchErrorMessageShowing = true;
    }
}
Also used : PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Example 2 with PaymentProductField

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

the class RenderValidationHelper method renderValidationMessageOnScreen.

private void renderValidationMessageOnScreen(ValidationErrorMessage validationResult, PaymentItem paymentItem) {
    String fieldId = validationResult.getPaymentProductFieldId();
    // Get the correct view of the invalid inputfield
    View view = parentView.findViewWithTag(fieldId);
    if (!canErrorMessageBeRendered(view, fieldId)) {
        return;
    }
    String validationMessage;
    if ("length".equals(validationResult.getErrorMessage()) && validationResult.getRule() instanceof ValidationRuleLength) {
        validationMessage = getCorrectMessageForLength(validationResult);
    } else {
        validationMessage = translator.getValidationMessage(validationResult.getErrorMessage());
    }
    if (validationResult.getRule() != null && paymentItem != null) {
        // Find the correct validationRule and format its message with variables attributes
        for (PaymentProductField field : paymentItem.getPaymentProductFields()) {
            if (field.getId().equals(validationResult.getPaymentProductFieldId())) {
                ValidationRule rule = validationResult.getRule();
                // if ValidationRuleLength, then add extra information to the errormessage
                if (rule instanceof ValidationRuleLength) {
                    // Replace the generic placeholders with Java specific placeholders, e.g. {maxlength} becomes {0}
                    validationMessage = formatMessagePlaceHolders(validationMessage);
                    // Show only the maxlength message if there is only one placeholder, else show minlenght and maxlength
                    if (validationMessage.split("\\{").length == 2) {
                        validationMessage = MessageFormat.format(validationMessage, ((ValidationRuleLength) rule).getMaxLength());
                    } else if (validationMessage.split("\\{").length == 3) {
                        validationMessage = MessageFormat.format(validationMessage, ((ValidationRuleLength) rule).getMinLength(), ((ValidationRuleLength) rule).getMaxLength());
                    }
                }
                // if ValidationRuleRange,then add extra information to the errormessage
                if (rule instanceof ValidationRuleRange) {
                    // Replace the generic placeholders with Java specific placeholders, e.g. {maxlength} becomes {0}
                    validationMessage = formatMessagePlaceHolders(validationMessage);
                    // Show only the maxvalue if there is only one placeholder, else show minvalue and maxvalue
                    if (validationMessage.split("\\{").length == 2) {
                        validationMessage = MessageFormat.format(validationMessage, ((ValidationRuleRange) rule).getMaxValue());
                    } else if (validationMessage.split("\\{").length == 3) {
                        validationMessage = MessageFormat.format(validationMessage, ((ValidationRuleRange) rule).getMinValue(), ((ValidationRuleRange) rule).getMaxValue());
                    }
                }
            }
        }
    }
    validationMessageRenderer.renderValidationMessage(validationMessage, (ViewGroup) view.getParent(), validationResult.getPaymentProductFieldId());
}
Also used : ValidationRuleLength(com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLength) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField) ValidationRuleRange(com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleRange) View(android.view.View) ValidationRule(com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRule)

Example 3 with PaymentProductField

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

the class BaseAsyncTaskTest method validatePaymentProductFields.

/*
     * Validates that a list of PaymentProductFields is not empty and that the first
     * element of the list at least contains the minimal possible fields
     */
private void validatePaymentProductFields(List<PaymentProductField> ppfs) {
    assertNotNull(ppfs);
    assertNotNull(ppfs.get(0));
    PaymentProductField ppf = ppfs.get(0);
    assertNotNull(ppf.getId());
    assertNotNull(ppf.getDataRestrictions());
    assertNotNull(ppf.getDisplayHints());
    validateDisplayHintsProductFields(ppf.getDisplayHints());
}
Also used : PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Example 4 with PaymentProductField

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

the class PaymentRequest method getMaskedValues.

/**
 * Gets the map with all masked fieldvalues
 */
public Map<String, String> getMaskedValues() {
    Map<String, String> maskedFieldValues = new HashMap<String, String>();
    // Loop through all the fieldValues
    for (Entry<String, String> entry : fieldValues.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        // Loop through all fields and format the matching field value.
        for (PaymentProductField field : paymentProduct.getPaymentProductFields()) {
            if (field.getId().equals(key)) {
                // retrieve value from fieldFormatter
                value = field.applyMask(value);
                // put the value in the new hashmap
                maskedFieldValues.put(key, value);
                break;
            }
        }
    }
    return maskedFieldValues;
}
Also used : HashMap(java.util.HashMap) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Example 5 with PaymentProductField

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

the class PaymentRequest method getUnmaskedValues.

/**
 * Gets the map with all unmasked fieldvalues
 */
public Map<String, String> getUnmaskedValues() {
    Map<String, String> unMaskedFieldValues = new HashMap<String, String>();
    // Loop through all the fieldValues
    for (Entry<String, String> entry : fieldValues.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        // Loop through all fields and format the matching field value.
        for (PaymentProductField field : paymentProduct.getPaymentProductFields()) {
            if (field.getId().equals(key)) {
                // retrieve value from fieldFormatter
                value = field.removeMask(value);
                // put the value in the new hashmap
                unMaskedFieldValues.put(key, value);
                break;
            }
        }
    }
    return unMaskedFieldValues;
}
Also used : HashMap(java.util.HashMap) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Aggregations

PaymentProductField (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)9 HashMap (java.util.HashMap)4 View (android.view.View)1 EncryptData (com.globalcollect.gateway.sdk.client.android.sdk.encryption.EncryptData)1 Encryptor (com.globalcollect.gateway.sdk.client.android.sdk.encryption.Encryptor)1 KeyValuePair (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair)1 PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)1 ValidationRule (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRule)1 ValidationRuleLength (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLength)1 ValidationRuleRange (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleRange)1 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1