Giter Site home page Giter Site logo

creditcardview's Introduction

CreditCardView

Intro

CreditCardView is a rich UX custom view to accomodate Credit Cards / Debit Cards while handling payment systems. The library consists of

  • CreditCardView which looks like below
FRONT VIEW BACK VIEW
MASTER FRONT MASTER BACK
  • CardEditActivity which behaves as below.

(GIF from - https://dribbble.com/shots/2177105-Checkout-Flow-Card )

Creating a CreditCardView

XML
<com.cooltechworks.creditcarddesign.CreditCardView
          android:id="@+id/card_5"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:card_number="38056789000000000"
          app:card_holder_name="HARISH SRIDHARAN"
          app:cvv="522"
          app:card_expiration="01/17"
          />
JAVA
   CreditCardView creditCardView = new CreditCardView(getContext());
   
   String name = "HARISH SRIDHARAN";
   String cvv = "522";
   String expiry = "01/17";
   String cardNumber = "38056789000000000";

   creditCardView.setCVV(cvv);
   creditCardView.setCardHolderName(name);
   creditCardView.setCardExpiry(expiry);
   creditCardView.setCardNumber(cardNumber);

Fetch new card info

To get a card information from the user, you can simply start the CardEditActivity as below and get the details of the card from onActivityResult() in your activity.

Starting the activity
final int GET_NEW_CARD = 2;

Intent intent = new Intent(MainActivity.this, CardEditActivity.class);
startActivityForResult(intent,GET_NEW_CARD);
Getting the card details
public void onActivityResult(int reqCode, int resultCode, Intent data) {

        if(resultCode == RESULT_OK) {

                String cardHolderName = data.getStringExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME);
                String cardNumber = data.getStringExtra(CreditCardUtils.EXTRA_CARD_NUMBER);
                String expiry = data.getStringExtra(CreditCardUtils.EXTRA_CARD_EXPIRY);
                String cvv = data.getStringExtra(CreditCardUtils.EXTRA_CARD_CVV);
          
                // Your processing goes here.

            }
        }
    }

Edit existing card

To edit the card details, you can start CardEditActivity passing the extras and get back the edited card information in onActivityResult() method of your activity just like above.

final int EDIT_CARD = 5;
Intent intent = new Intent(MainActivity.this, CardEditActivity.class);
intent.putExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME, cardHolderName);
intent.putExtra(CreditCardUtils.EXTRA_CARD_NUMBER, cardNumber);
intent.putExtra(CreditCardUtils.EXTRA_CARD_EXPIRY, expiry);
intent.putExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_BACK);
intent.putExtra(CreditCardUtils.EXTRA_VALIDATE_EXPIRY_DATE, true); // pass "false" to discard expiry date validation.


startActivityForResult(intent, EDIT_CARD);

Sample Demo Video

Demo Video

Adding to your project

  • Add the following configuration in your build.gradle file.
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.sharish:CreditCardView:v1.0.4'
}
  • Add the following activity to your AndroidManifest.xml
 <activity android:name="com.cooltechworks.creditcarddesign.CardEditActivity"
            android:screenOrientation="portrait"
            />

Design Credits

Developed By

Acknowledgements

License

Copyright 2016 Harish Sridharan

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

creditcardview's People

Contributors

ema987 avatar gilbertorsf avatar kwiky avatar loudenvier avatar michelelacorte avatar ppodgorski avatar sharish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

creditcardview's Issues

Union pay

when does the unipay will be ready?

Translation and modified field

Hello,
How do I modify the size of the card name field?
How can I translate all fields?
fotocard

The buttons i can put
ย 
libcard

Sorry for the english ..

Thanks..

App crashes while starting CardEditActivity while passing the extras

I am starting the activity as:

Intent intent = new Intent(getActivity(), CardEditActivity.class);
                intent.putExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME, "Shajeel Afzal");
                intent.putExtra(CreditCardUtils.EXTRA_CARD_NUMBER, "1234567890123456");
                intent.putExtra(CreditCardUtils.EXTRA_CARD_EXPIRY, "01/17");
                intent.putExtra(CreditCardUtils.EXTRA_CARD_CVV, "234");
                intent.putExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_BACK);

                startActivityForResult(intent, EDIT_CARD_CODE);

But the app crashes and shows the following log:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.selectAll()' on a null object reference
                                                                                at com.cooltechworks.creditcarddesign.pager.CardExpiryFragment.focus(CardExpiryFragment.java:122)
                                                                                at com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter.focus(CardFragmentAdapter.java:14)
                                                                                at com.cooltechworks.creditcarddesign.CardEditActivity$3.onPageSelected(CardEditActivity.java:132)
                                                                                at android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1931)
                                                                                at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:662)
                                                                                at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:628)
                                                                                at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:609)
                                                                                at com.cooltechworks.creditcarddesign.CardEditActivity.showNext(CardEditActivity.java:225)
                                                                                at com.cooltechworks.creditcarddesign.CardEditActivity$4.onCardEntryComplete(CardEditActivity.java:156)
                                                                                at com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter.onActionComplete(CardFragmentAdapter.java:75)
                                                                                at com.cooltechworks.creditcarddesign.pager.CreditCardFragment.onComplete(CreditCardFragment.java:39)
                                                                                at com.cooltechworks.creditcarddesign.pager.CardNumberFragment.afterTextChanged(CardNumberFragment.java:71)
                                                                                at android.widget.TextView.sendAfterTextChanged(TextView.java:7738)
                                                                                at android.widget.TextView.setText(TextView.java:4105)
                                                                                at android.widget.TextView.setText(TextView.java:3954)
                                                                                at android.widget.EditText.setText(EditText.java:85)
                                                                                at android.widget.TextView.setText(TextView.java:3929)
                                                                                at com.cooltechworks.creditcarddesign.pager.CardNumberFragment.onCreateView(CardNumberFragment.java:43)
                                                                                at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
                                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
                                                                                at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
                                                                                at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
                                                                                at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1632)
                                                                                at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637)
                                                                                at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
                                                                                at android.support.v4.view.ViewPager.populate(ViewPager.java:1235)
                                                                                at android.support.v4.view.ViewPager.populate(ViewPager.java:1083)
                                                                                at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1609)
                                                                                at android.view.View.measure(View.java:17637)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                                at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                                at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                                at android.view.View.measure(View.java:17637)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                                at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                                at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                                at android.view.View.measure(View.java:17637)
                                                                                at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
                                                                                at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
                                                                                at android.view.View.measure(View.java:17637)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                                at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                                at android.view.View.measure(View.java:17637)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5536)
                                                                                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                                at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                                at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                                at android.view.View.measure(Vie

Null Object Reference

Hi sharish, I'm getting a null object reference error when trying to edit an existing credit card. It appears in your CardExpiryFragment in the focus method when the cardExpiryView calls selectAll().
screen shot 2016-10-23 at 10 31 46 am

Crashing the app due to filter error

Please fix in the code.

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setFilters(android.text.InputFilter[])' on a null object reference
at com.cooltechworks.creditcarddesign.pager.CardCVVFragment.setMaxCVV(CardCVVFragment.java:69)
at com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter.setMaxCVV(CardFragmentAdapter.java:92)
at com.cooltechworks.creditcarddesign.CardEditActivity.checkParams(CardEditActivity.java:102)
at com.cooltechworks.creditcarddesign.CardEditActivity.onRestoreInstanceState(CardEditActivity.java:207)
at android.app.Activity.performRestoreInstanceState(Activity.java:1015)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1175)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2735)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2823)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4655)
at android.app.ActivityThread.-wrap19(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1551)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6349)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

No Shown in Nought OS version

The Very Helpfull Library to draw card same as i want,
working very easy nd efficiently in Device
But for new OS devices CardContainer Not shown there is no any view created in Nought without any exception /Error
Just Gone the view or CreditCard.
Guide me how can i Shown Up My card in Nought nd higher version Devices

CVV code not setting

hey Sharish !! i am setting the cvv code but on clicking the credit card the cvv code field is empty

Field name customization

Possible duplicate of #1.

Hi, I want to customize the texts in the cardview and the edittext labels. Is there any way to do that?

Only show last 4 digits of credit card

Thank for this awesome library ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘
but i would like to request if there is a method to replace all the credit card number to bullet except the last 4 digits will be great.

Thank you very much

Expirating Date validation

Congrats for the library, I really like the idea to bring some reality to android views.

I've been working on mCommerces companies for a while and I'd like to share a situation that I was face in this field.

We, as android developers or client developer, can not block the user to input a expired date in the field. This is a kind of business logic that should be handle in the backend. Sometimes the payment brand (visa, amex, mastercard, etc) will accept the purchase, even if the credit card is already expired.

Next and previous button is missing in creditcard

i m writing another issue cause i m not able to reopen my previous issue.
text half cut in this issue you suggest me use different dependency, but there is no next and previous button.

My text half cut problem is solved but now i m not able to get data from credit card because of missing done button.

screenshot_20170117-101333

How Can I do Error Checking?

How can I check if someone leaves all the fields blank? I would like to make sure a user fills out each field before returning to the calling Activity.

16 character name only

I already did what was recommended here but it still only has 16 possible characters

25

Card Holder Name Length

Investigating I see the max length for card holder name in the library is 16, but I've seen several VISA and MASTERCARD that supports until 21 characters, it could be better if this limit could be parameterizable in an integer resource or increase the limit

Keyboard covers buttons and doesn't scroll

http://i.imgur.com/8Q9yCgw.png
http://i.imgur.com/8Q9yCgw.png

I can't seem to get the activity view to scroll allowing the bottom button to be shown. I tried adding

<activity android:name="com.cooltechworks.creditcarddesign.CardEditActivity" android:screenOrientation="portrait"
            android:configChanges="keyboard|keyboardHidden" />

to the manifest like shown in the sample app but It's still not scrolling. Any ideas what I should try? Thanks mate!

4 digit CVV

I have card with 4 digit CVV, now library doesn't allow me to put 4 digits.can you help me ? is there any function to set dynamic CVV size ?

American Express Cards

American Express card numbers are usually 14 digits long and have a different format for the CVV. The American Express CVV is a 4 digit number, might be good to account for these.

Also, it might be good to conform to the IIN numbers that can be seen at this Wiki page: https://en.wikipedia.org/wiki/Bank_card_number

Great product, keep up the great work. I'll try and fix this myself and sent a PR, wanted to let you know that these exist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.