Search in sources :

Example 6 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 mergePaymentRequest.

/**
 * Merges given paymentProduct.fieldvalues map with the current paymentproduct values
 *
 * @param paymentProduct
 */
public void mergePaymentRequest(PaymentProduct paymentProduct) {
    if (paymentProduct == null) {
        throw new InvalidParameterException("Error merging PaymentRequest, paymentProduct may not be null");
    }
    // Create new map which contains all values for fields who are also present in the new paymentproduct
    Map<String, String> newFieldValues = new HashMap<String, String>();
    // Loop trough all new fields and see of they match the fieldvalues id
    if (paymentProduct.getPaymentProductFields() != null) {
        for (PaymentProductField field : paymentProduct.getPaymentProductFields()) {
            for (Entry<String, String> valueEntry : fieldValues.entrySet()) {
                if (field.getId().equals(valueEntry.getKey())) {
                    newFieldValues.put(valueEntry.getKey(), valueEntry.getValue());
                }
            }
        }
    }
    fieldValues = newFieldValues;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) HashMap(java.util.HashMap) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Example 7 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 InputValidationPersister method storeInputFieldDataInPaymentRequest.

private void storeInputFieldDataInPaymentRequest(InputDataPersister inputDataPersister) {
    PaymentProduct paymentProduct = (PaymentProduct) inputDataPersister.getPaymentItem();
    for (PaymentProductField field : paymentProduct.getPaymentProductFields()) {
        String value = inputDataPersister.getValue(field.getId());
        // Null elements should not be stored in the payment request, empty values however can occur
        if (value == null) {
            value = "";
        }
        paymentRequest.setValue(field.getId(), field.removeMask(value));
    }
    paymentRequest.setTokenize(inputDataPersister.isRememberMe());
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Example 8 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 EncryptDataAsyncTask method doInBackground.

@Override
protected String doInBackground(String... params) {
    EncryptData encryptData = new EncryptData();
    // Format all values based on their paymentproductfield.type and them to the encryptedValues
    Map<String, String> formattedPaymentValues = new HashMap<String, String>();
    for (PaymentProductField field : paymentRequest.getPaymentProduct().getPaymentProductFields()) {
        String value = paymentRequest.getValue(field.getId());
        // If the masks given by the GC gateway are correct
        if (field.getType() != null && value != null) {
            if (field.getType().equals(Type.NUMERICSTRING)) {
                formattedPaymentValues.put(field.getId(), value.replaceAll("[^\\d.]", ""));
            } else {
                formattedPaymentValues.put(field.getId(), value);
            }
        }
    }
    encryptData.setPaymentValues(formattedPaymentValues);
    // Add the clientSessionId
    encryptData.setClientSessionId(clientSessionId);
    // Add UUID nonce
    encryptData.setNonce(UUID.randomUUID().toString());
    // Add paymentproductId and accountOnFileId to the encryptData
    if (paymentRequest.getAccountOnFile() != null) {
        encryptData.setAccountOnFileId(paymentRequest.getAccountOnFile().getId());
    }
    encryptData.setPaymentProductId(Integer.parseInt(paymentRequest.getPaymentProduct().getId()));
    // See if the payment must be remembered
    if (paymentRequest.getTokenize()) {
        encryptData.setTokenize(true);
    }
    // Encrypt all the fields in the paymentproduct
    Encryptor encryptor = new Encryptor(publicKeyResponse);
    return encryptor.encrypt(encryptData);
}
Also used : HashMap(java.util.HashMap) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField) Encryptor(com.globalcollect.gateway.sdk.client.android.sdk.encryption.Encryptor) EncryptData(com.globalcollect.gateway.sdk.client.android.sdk.encryption.EncryptData)

Example 9 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 retrieveValuesFromSearchFields.

private List<KeyValuePair> retrieveValuesFromSearchFields() {
    ArrayList<KeyValuePair> values = new ArrayList<>(3);
    for (PaymentProductField searchField : paymentProductFieldsUsedForLookup) {
        String value = inputDataPersister.getValue(searchField.getId());
        KeyValuePair kvp = new KeyValuePair();
        kvp.setKey(searchField.getId());
        kvp.setValue(value);
        values.add(kvp);
    }
    return values;
}
Also used : KeyValuePair(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField) ArrayList(java.util.ArrayList)

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