Creditcardview

A Credit or Debit card view for Android

View the Project on GitHub VineshRaju/CreditCardView

CreditCardView

Intro

CreditCardView is a simple custom view for displaying Credit / Debit Cards with automatic card type identification and ability to learn user defined card types.

Adding to your project

Download

Add the following configuration in your build.gradle file.

dependencies {
    compile 'xyz.vinesh:creditcardview:1.1.+’
}

Creating a CreditCardView

in XML
  <xyz.vinesh.creditcardview.CreditCardView
                android:id="@+id/cvCreditCardView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:cardForegroundColor="@color/cardview_dark_background"
                app:cardBackgroundColor="@color/colorAccent"
                app:cardHolderName="Vinesh Raju"
                app:expiry="06/16"
                app:cvv="654"
                app:cardNumber="4242424242424242"/>
in Code
   CreditCardView creditCardView = new CreditCardView(context);

   String name =VINESH RAJU”;
   String cvv =000”;
   String expiry = "06/16”;
   String cardNumber = "1234567891234567";

   creditCardView.setCvv(cvv);
   creditCardView.setCardHolderName(name);
   creditCardView.setExpiry(expiry);
   creditCardView.setCardNumber(cardNumber);
   creditCardView.(cardNumber);
   cardView.setCardForegroundColor(getResources().getColor(android.R.color.holo_orange_dark));

Getting card info

To get the information displayed on the card

   String name = creditCardView.getCardHolderName();
   String cvv = creditCardView.getCvv();
   String expiry = creditCardView.getExpiry();
   String cardNumber = creditCardView.getCardNumber();
   int color = creditCardView.getCardForegroundColor();

Learning new Card Types

CreditCardView automatically detects and displays appropriate logos for Visa,Master Card and American Express. In addition to these new types can be taught to CreditCardView by using the learn method

Syntax

    CardType.learn(String regEx,Drawable logoResource);

where regEx is the regular expression defining the pattern for the new card

Example

    CardType cardType=new CardType();
    cardType.learn("^3[47][0-9]{13}$", getContext().getResource().getDrawable(R.drawable.am_ex_logo));
    creditCardView.setCardTypes(cardType);

Designed and Developed By

License

Copyright 2016 Vinesh Raju

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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 NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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.