View on GitHub

EditCredit

Android EditText For Credit Card Numbers

Android Arsenal JitPack Playstore Donate


Logo

Custom EditText for entering Credit Card numbers, this EditText will also display the image of the card number type being entered (after entering the second digit). And supports adding a separator (spaces or dashes) after every four digits.
This version supports Visa, MasterCard, American Express and Discover cards.

Installation via Gradle:

Step 1. Add the JitPack repository to your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2. Add the dependency

dependencies {
  ...
  implementation 'com.github.Mostafa-MA-Saleh:EditCredit:3.0.3'
}

Changelog

v 3.0.3

Usage

Java

Public Methods

return Name/Description
Card getCardType()
Returns the current card type.
String getTextWithoutSeparator()
Returns the card number without the separators.
boolean isCardValid()
Validates the entered card number.
void setSeparator(Separator)
Sets the separator style.
Separator getSeparator()
Returns the current separator style.
void setDisabledCards(Card…)
Sets the disabled cards.
void setDrawableGravity(Gravity)
Sets the location of the card drawable.
Gravity getDrawableGravity()
Returns the current location of the card drawable.

Kotlin

Public Methods

return Name/Description
void setDisabledCards(Card…)
Sets the disabled cards.

Public Attributes

Type Name/Description Read Only
Card cardType
The current card type.
*
String textWithoutSeparator
The card number without the separators.
*
Boolean isCardValid
Validates the entered card number.
*
Separator separator
The current separator style.
 
Gravity drawableGravity
The location of the card drawable.
 

XML

Attributes

Name Description values
separator Sets the separator style no_separator
spaces
dashes
drawableGravity Sets the the location of the card drawable start
end
left
right
disabledCards Sets disabled cards
this can be multiple values seperated by “|”
(eg. app:disabledCards=”visa|amex”)
none
visa
mastercard
amex
discover
diners

Example

EditCredit can be used just like a normal EditText

<mostafa.ma.saleh.gmail.com.editcredit.EditCredit
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:disabledCards="visa|amex"
        app:drawableGravity="end"
        app:separator="spaces" />

Donation

If this project helps you, and you wanna buy me a cup of coffee.

PayPal

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>