Skip to content

Commit bf9ca77

Browse files
committed
Add card number validation (Luhn algorithm)
1 parent 6f6593d commit bf9ca77

File tree

1 file changed

+7
-0
lines changed
  • raveandroid/src/main/java/com/flutterwave/raveandroid

1 file changed

+7
-0
lines changed

raveandroid/src/main/java/com/flutterwave/raveandroid/Utils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,13 @@ public static String spacifyCardNumber(String cardNo) {
283283

284284
}
285285

286+
/**
287+
* Checks that a number is valid according to the Luhn algorithm
288+
* https://en.wikipedia.org/wiki/Luhn_algorithm
289+
*
290+
* @param number to be checked
291+
* @return true if valid
292+
*/
286293
public static boolean isValidLuhnNumber(String number) {
287294

288295
try {// Verify that string contains only numbers

0 commit comments

Comments
 (0)