Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/com/adyen/Util/DateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public final class DateUtil {
private DateUtil() {
}

public static Date parseYmdDate(String dateString) {
public static Date parseDateToFormat(String dateString, String format) {
if (dateString == null) {
return null;
}

Date date;
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat fmt = new SimpleDateFormat(format);
try {
date = fmt.parse(dateString);
} catch (ParseException e) {
Expand All @@ -43,4 +43,12 @@ public static Date parseYmdDate(String dateString) {

return date;
}

public static Date parseYmdDate(String dateString) {
return parseDateToFormat(dateString, "yyyy-MM-dd");
}

public static Date parseMYDate(String dateString) {
return parseDateToFormat(dateString, "M/yyyy");
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/adyen/constants/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface AdditionalData {
String PAYMENT_TOKEN = "payment.token";
String FRAUD_RESULT_TYPE = "fraudResultType";
String FRAUD_MANUAL_REVIEW = "fraudManualReview";
String AUTH_CODE = "authCode";

String BOLETO_BARCODE_REFERENCE = "boletobancario.barCodeReference";
String BOLETO_DATA = "boletobancario.data";
Expand All @@ -69,4 +70,25 @@ interface Encrypted {
interface SelectedBrand {
String BOLETO_SANTANDER = "boletobancario_santander";
}

interface PaymentMethod {
String ENCRYPTED_CARD_NUMBER = "encryptedCardNumber";
String ENCRYPTED_EXPIRY_MONTH = "encryptedExpiryMonth";
String ENCRYPTED_EXPIRY_YEAR = "encryptedExpiryYear";
String ENCRYPTED_SECURITY_CODE = "encryptedSecurityCode";
String METHOD_TYPE = "type";
String HOLDER_NAME = "holderName";
String RECURRING_DETAIL_REFERENCE = "recurringDetailReference";
}

interface Redirect {
interface Data {
String MD = "MD";
String PAREQ = "PaReq";
}
}

interface PaymentMethodType {
String TYPE_SCHEME = "scheme";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ public String request(String requestUrl, String requestBody, Config config) thro
@Override
public String request(String requestUrl, String requestBody, Config config, boolean isApiKeyRequired) throws IOException, HTTPClientException {
HttpURLConnection httpConnection = createRequest(requestUrl, config.getApplicationName());
if (isApiKeyRequired) {
setApiKey(httpConnection, config.getApiKey());
String apiKey = config.getApiKey();
// Use Api key if required or if provided
if (isApiKeyRequired || (apiKey != null && !apiKey.isEmpty())) {
setApiKey(httpConnection, apiKey);
} else {
setBasicAuthentication(httpConnection, config.getUsername(), config.getPassword());
}
Expand Down
14 changes: 1 addition & 13 deletions src/main/java/com/adyen/model/PaymentResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,7 @@ public String getAdditionalDataByKey(String key) {

public Date getExpiryDate() {
String expiryDate = getAdditionalDataByKey(EXPIRY_DATE);
if (expiryDate == null) {
return null;
}

Date date;
SimpleDateFormat monthYear = new SimpleDateFormat("M/yyyy");
try {
date = monthYear.parse(expiryDate);
} catch (ParseException e) {
return null;
}

return date;
return DateUtil.parseMYDate(expiryDate);
}

public String getCardBin() {
Expand Down
Loading