CreditCardView


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

CreditCardView

A real life simulation of a credit card for android.

Screenshots:

CreditCardView



CreditCardFragment ![screenshot 2]( https://raw.githubusercontent.com/Movile/CreditCardView/master/screenshoots/screen2.png)

###Watch:

You can use just the representation of credit card with CreditCardView, or you can use the entire solution to collect user's credit card data with CreditCardFragment.

##Usage

In your build.gradle file:

dependencies {

  compile 'com.movile:creditcardguide:1.2-beta' 
}

###CreditCardView

In your layout xml:

<movile.com.creditcardguide.view.CreditCardView

  android:id="@+id/creditCardView"

  android:layout_width="match_parent"

  android:layout_height="match_parent" />

In your activity/fragment class:

final CreditCardView creditCardView = (CreditCardView) findViewById(R.id.creditCardView);
  creditCardView.chooseFlag(IssuerCode.VISACREDITO);
 creditCardView.setTextExpDate("12/19");
 creditCardView.setTextNumber("5555 4444 3333 1111");
 creditCardView.setTextOwner("Felipe Silvestre");
 creditCardView.setTextCVV("432");

To flip the card, you can call:

creditCardView.flipToBack();
 // To show the back side creditCardView.flipToFront();
 // To show the front side

If you want to configure the label texts of owner name and valid thru:

<movile.com.creditcardguide.view.CreditCardView

  xmlns:app="http://schemas.android.com/apk/res-auto"

  android:id="@+id/creditCardView"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  app:labelOwner="@string/label_owner"

  app:labelDateExp="@string/valid_thru">

###CreditCardFragment

In your layout xml:

<fragment

  android:id="@+id/frgCreditCard"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:name="movile.com.creditcardguide.CreditCardFragment" />

In your activity class:

CreditCardFragment inputCardFragment = (CreditCardFragment) getFragmentManager().findFragmentById(R.id.frgCreditCard);
  // YOU MUST set the pages order (Set a order that makes sense to the user) inputCardFragment.setPagesOrder(CreditCardFragment.Step.FLAG, CreditCardFragment.Step.NUMBER,

CreditCardFragment.Step.EXPIRE_DATE, CreditCardFragment.Step.CVV, CreditCardFragment.Step.NAME);
  // YOU MUST provide a purchase options list inputCardFragment.setListPurchaseOptions(getList(), 230.0);

You must set the pages order and provide a purchase options list, to test you can create a fake list like the sample app:

private List<PurchaseOption> getStubList() {

List<PurchaseOption> list = new ArrayList<>();

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.MASTERCARD, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.VISACREDITO, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.AMEX, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.PAYPAL, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.DINERS, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.NUBANK, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.AURA, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.ELO, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.HIPERCARD, 6));

list.add(new PurchaseOption(PaymentMethod.Type.CREDIT_CARD, IssuerCode.OTHER, 6));

 return list;
  
}

And your activity needs to implement ActionOnPayListener interface to listen:

 @Override
  public void onChangedPage(CreditCardFragment.Step page) {

}

@Override
  public void onComplete(CreditCardPaymentMethod purchaseOption, boolean saveCard) {

Toast.makeText(this, purchaseOption.toString(), Toast.LENGTH_LONG).show();

  
}

There are some attributes that you can provide configure the fragment/view:

<fragment

  xmlns:app="http://schemas.android.com/apk/res-auto"

  android:id="@+id/frgCreditCard"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:name="movile.com.creditcardguide.CreditCardFragment"

  app:labelCardOwner="string"

  app:labelCardDateExp="string"

  app:labelButtonPay="string"

  app:buttonPayBackground="@color/color"

  app:buttonPayTextColor="@color/color"

  app:labelNumber="string"

  app:labelExpireDate="string"

  app:labelCVV="string"

  app:labelOwnerName="string"

  app:labelTotal="string"

  app:installments="false|true"

  app:saveCard="false|true"

  />

There are equivalent methods to set it on code.

Please for further information look at the sample app code.

Open source libraries

CreditCardView uses the following open source files:

Copyright and license

Code and documentation copyright 2016 Movile. Code released under the MIT license.

Felipe Silvestre (Dev) & Victor Namba (Designer)

Design Credits

Resources

A library to create StepsView for Android.

This plugin integrates TestFairy platform with the Gradle build system. With this plugin, you can upload signed builds directly via command line, IntelliJ, Android Studio and other IDEs.

An Android Pinterest client.

This project intends to solve the problem of concurrent write attempts from different threads to an Android SQLite database.

DBTools for Android is an Android ORM library that makes it easy to work with SQLite Databases.

DBTools Gen is a ORM Java class file generator and SQL Schema file generator library. DBTools Gen makes it easy to create databases schema files and create JPA ORM Mapping or Android ORM Mapping files.

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