Skip to content

Commit

Permalink
Merge pull request #117 from xendit/fix/update-jcb-and-date
Browse files Browse the repository at this point in the history
fix expirydate and jcb detection
  • Loading branch information
lordrio authored May 27, 2024
2 parents 11cb3a5 + 5c3b0aa commit 934967e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 4.1.2 (2024-05-27)
- fix JCB card detection and expiry date

## 4.1.1 (20240-01-26)
- Support mid_label in create token and unbundled create authentication

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ Maven:
<dependency>
<groupId>com.xendit</groupId>
<artifactId>xendit-android</artifactId>
<version>4.1.1</version>
<version>4.1.2</version>
<type>pom</type>
</dependency>
```

Gradle:
```
compile 'com.xendit:xendit-android:4.1.1'
compile 'com.xendit:xendit-android:4.1.2'
```

Ivy:
```
<dependency org='com.xendit' name='xendit-android' rev='4.1.1'>
<dependency org='com.xendit' name='xendit-android' rev='4.1.2'>
<artifact name='xendit-android' ext='pom' ></artifact>
</dependency>
```

For more information, visit https://central.sonatype.dev/artifact/com.xendit/xendit-android/4.1.1/versions
For more information, visit https://central.sonatype.dev/artifact/com.xendit/xendit-android/4.1.2/versions

**Note**:

Expand Down
4 changes: 2 additions & 2 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'
apply plugin: 'signing'

group 'com.xendit'
version '4.1.1'
version '4.1.2'

ext {
bintrayOrg = 'xendit'
Expand Down Expand Up @@ -38,7 +38,7 @@ android {
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName '4.1.1'
versionName '4.1.2'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
Expand Down
10 changes: 7 additions & 3 deletions xendit-android/src/main/java/com/xendit/utils/CardValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ public static boolean isExpiryValid(String expirationMonth, String expirationYea
return false;
}

int currentYear = Calendar.getInstance().get(Calendar.YEAR);

String cleanMonth = removeWhitespace(expirationMonth);
String cleanYear = removeWhitespace(expirationYear);

return isNumeric(cleanMonth) && isNumeric(cleanYear) &&
parseNumberSafely(cleanMonth) >= 1 &&
parseNumberSafely(cleanMonth) <= 12 &&
parseNumberSafely(cleanYear) >= 2017 &&
parseNumberSafely(cleanYear) <= 2100 &&
parseNumberSafely(cleanYear) <= (currentYear + 100) &&
isNotInThePast(cleanMonth, cleanYear);
}

Expand Down Expand Up @@ -293,7 +294,10 @@ private static boolean isCardDankort(String cardNumber) {
private static boolean isCardJCB(String cardNumber) {
if (cardNumber != null && cardNumber.length() >= 4) {
int startingNumber = number(cardNumber.substring(0, 4));
return startingNumber >= 3528 && startingNumber <= 3589;
return (startingNumber >= 3528 && startingNumber <= 3589) ||
cardNumber.startsWith("308800") ||
cardNumber.startsWith("333755") ||
cardNumber.startsWith("333700");
} else {
return false;
}
Expand Down

0 comments on commit 934967e

Please sign in to comment.