Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Release 4.8.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Jun 19, 2019
1 parent 43d6bb7 commit 6f5bfca
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public View renderField(PaymentProductField field, InputDataPersister inputDataP

// get input information from inputDataPersister
String setDate = inputDataPersister.getValue(field.getId());
if (setDate != null && accountOnFile == null) {
if (setDate != null) {
setDateFromString(datePicker, setDate, listener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public View renderField(PaymentProductField field, InputDataPersister inputDataP

// get input information from inputDataPersister
String paymentProductValue = inputDataPersister.getValue(field.getId());
if(paymentProductValue != null && accountOnFile == null){
if(paymentProductValue != null){
editText.setText(paymentProductValue);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.globalcollect.gateway.sdk.client.android.exampleapp.render.persister;

import android.renderscript.ScriptGroup;

import com.globalcollect.gateway.sdk.client.android.sdk.model.FormatResult;
import com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.AccountOnFile;
import com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
import android.support.annotation.NonNull;

import com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest;
import com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.AccountOnFile;
import com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair;
import com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct;
import com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField;
import com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationErrorMessage;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.security.InvalidAlgorithmParameterException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -51,17 +56,52 @@ public List<ValidationErrorMessage> storeAndValidateInput(InputDataPersister inp

private void storeInputFieldDataInPaymentRequest(InputDataPersister inputDataPersister) {
PaymentProduct paymentProduct = (PaymentProduct) inputDataPersister.getPaymentItem();
AccountOnFile accountOnFile = inputDataPersister.getAccountOnFile();
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 = "";
// Don't add the value if it has not changed and is available in the provided Account on File
if (accountOnFile != null && isFieldInAccountOnFile(field.getId(), accountOnFile)
&& valueIsNotAltered(value, field, accountOnFile)) {
// The value was not altered with regards to the accountOnFile, but there may still
// be an altered value in the PaymentRequest, which is not correct
paymentRequest.removeValue(field.getId());
continue;
}

// Don't add empty field values
if (StringUtils.isEmpty(value)) {
// Also remove any data that may possibly have already been added to the Payment Request
paymentRequest.removeValue(field.getId());
continue;
}
paymentRequest.setValue(field.getId(), field.removeMask(value));
}
paymentRequest.setTokenize(inputDataPersister.isRememberMe());
}

private boolean isFieldInAccountOnFile(String fieldId, AccountOnFile accountOnFile) {
for (KeyValuePair keyValuePair : accountOnFile.getAttributes()) {
if (keyValuePair.getKey().equals(fieldId)) {
return true;
}
}
return false;
}

private boolean valueIsNotAltered(String value, PaymentProductField field, AccountOnFile accountOnFile) {
// Assume the value is not altered if it is null in the inputDataPersister
if (value == null) {
return true;
}

for (KeyValuePair keyValuePair : accountOnFile.getAttributes()) {
if (keyValuePair.getKey().equals(field.getId())) {
return field.removeMask(value).equals(keyValuePair.getValue());
}
}
throw new IllegalStateException("No value found in Account on File for the provided FieldId");
}

public PaymentRequest getPaymentRequest() {
return paymentRequest;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class Constants {

/** SDK version **/
public final static String SDK_IDENTIFIER = "AndroidClientSDK/v4.8.0";
public final static String SDK_IDENTIFIER = "AndroidClientSDK/v4.8.1";

/** SDK creator **/
public final static String SDK_CREATOR = "Ingenico";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public List<ValidationErrorMessage> validate() {
}

private boolean isFieldInAccountOnFileAndNotAltered(PaymentProductField field) {
if (accountOnFile != null && paymentProductHasAccountOnFile(paymentProduct.getAccountsOnFile())) {
if (accountOnFile != null && paymentProductHasAccountOnFile()) {
for (KeyValuePair pair : accountOnFile.getAttributes()) {
if (pair.getKey().equals(field.getId()) && // Field is in account on file
(!pair.isEditingAllowed() || // Not altered
Expand All @@ -95,7 +95,7 @@ private boolean isFieldInAccountOnFileAndNotAltered(PaymentProductField field) {
return false;
}

private boolean paymentProductHasAccountOnFile(List<AccountOnFile> accountsOnFile) {
private boolean paymentProductHasAccountOnFile() {
if (paymentProduct != null) {
for (AccountOnFile ppAccountOnFile : paymentProduct.getAccountsOnFile()) {
if (accountOnFile.getId().equals(ppAccountOnFile.getId())) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# org.gradle.parallel=true
POM_GROUP_ID=com.ingenico.connect.gateway
POM_ARTIFACT_ID=connect-sdk-client-android
POM_VERSION=4.8.0
POM_VERSION=4.8.1
POM_NAME=connect-sdk-client-android
POM_DESCRIPTION=SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Client API
POM_URL=https://github.com/Ingenico-ePayments/connect-sdk-client-android
Expand Down

0 comments on commit 6f5bfca

Please sign in to comment.