CreditCardView


Source link: https://github.com/sharish/CreditCardView

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
  • 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

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. 

Resources

A small library to simplify RecyclerView adapter by using auto mapping item view with model.

Lumberjack - a customisable file/notification/console logger for Timber (each functionality is packed into it's own module)

Smart app rate dialog for Android which takes user rating into consideration. If the user rates the app below the defined threshold rating, the dialog will change into a feedback form. Otherwise, It will take the user to the Google PlayStore.

FloatingView can make the target view floating above the anchor view with cool animation.

Shows a DialogFragment with Camera or Gallery options. The user can choose from where provider wants to pick an image.

This is a library which show how to use Woocommerce using OAuth 1.0a "one-legged" authentication(HTTP).

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes