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;
}
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());
}
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);
}
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;
}
Aggregations