From fdcb3eb8d142f02bd30ce3d2f9bb22f344d5b02f Mon Sep 17 00:00:00 2001 From: Nosakhare Belvi Date: Mon, 17 Jul 2017 16:31:20 +0100 Subject: [PATCH] Update README.md --- README.md | 162 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 128 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 61ecf1c..178bca4 100755 --- a/README.md +++ b/README.md @@ -22,6 +22,13 @@ Current Verion [![](https://jitpack.io/v/KingsMentor/Luhn.svg)](https://jitpack. - Fix bug of installing library as a seperate module - gradle dependency build optimisation +#### v2.0 +- Customising CardIo in Luhn +- Interswitch Verve Card Image +- Theming Luhn from .xml resources +- custom dialog integration (you can now use your app loading screen instead of Luhn's progress screen. Just don't call `cardVerifier.startProgress();`. Call your progress implementation instead) +- onFinished Callback. Get call back when luhn has finished, so you can `doSomething();`. + ![Lib Sample](https://github.com/KingsMentor/Luhn/blob/master/screenshots/add_card_collage.jpg) @@ -59,22 +66,28 @@ Add the dependency ```java + /** + * @VisaElectron is listed before + * @Visa for proper card prediction (both start with 4 but + * @VisaElectron has to start with any of 4026, 417500, 4508, 4844, 4913 or 4917) + * + */ AmericanExpress("America Express", R.drawable.payment_ic_amex, "34, 37", "15"), - MasterCard("Master", R.drawable.payment_ic_master_card, "51, 52, 53, 54, 55, 222100-272099", "16"), - VisaElectron("Visa Electron", R.drawable.payment_ic_method, "4026, 417500, 4508, 4844, 4913, 4917", "16"), - Visa("Visa", R.drawable.payment_ic_visa, "4", "13,16,19"), - Maestro("Maestro", R.drawable.payment_ic_maestro_card, "5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763", "12-19"), - JCB("JCB", R.drawable.payment_ic_method, "3528-3589", "16-19"), - InstaPayment("Insta Payment", R.drawable.payment_ic_method, "637, 638, 639", "16"), - Verve("Verve", R.drawable.payment_ic_method, "506099-506198, 650002-650027", "16,19"), + CardGuard("Card Guard", R.drawable.payment_ic_method, "5392", "16"), + ChinaUnionPay("China Union Pay", R.drawable.payment_ic_unionpay, "62", "16-19"), + Dankort("Dankort", R.drawable.payment_ic_method, "5019", "16"), + DinersClub("Diners Club", R.drawable.payment_ic_dinersclub, "300-305, 309, 36, 38, 39", "14,16-19"), Discover("Discover", R.drawable.payment_ic_discover, "6011, 622126 to 622925, 644, 645, 646, 647, 648, 649, 65", "16,19"), - UATP("Universal Air Travel Plan", R.drawable.payment_ic_method, "1", "15"), + InstaPayment("Insta Payment", R.drawable.payment_ic_method, "637, 638, 639", "16"), + JCB("JCB", R.drawable.payment_ic_method, "3528-3589", "16-19"), + Maestro("Maestro", R.drawable.payment_ic_maestro_card, "5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763", "12-19"), + MasterCard("Master", R.drawable.payment_ic_master_card, "51, 52, 53, 54, 55, 222100-272099", "16"), MIR("Mir", R.drawable.payment_ic_method, "2200 - 2204", "16"), - Dankort("Dankort", R.drawable.payment_ic_method, "5019", "16"), Troy("Troy", R.drawable.payment_ic_method, "979200-979289", "16"), - CardGuard("Card Guard", R.drawable.payment_ic_method, "5392", "16"), - DinersClub("Diners Club", R.drawable.payment_ic_dinersclub, "300-305, 309, 36, 38, 39", "14,16-19"), - ChinaUnionPay("China Union Pay", R.drawable.payment_ic_unionpay, "62", "16-19"); + UATP("Universal Air Travel Plan", R.drawable.payment_ic_method, "1", "15"), + Verve("Verve", R.drawable.payment_ic_verve, "506099-506198, 650002-650027", "16,19"), + VisaElectron("Visa Electron", R.drawable.payment_ic_method, "4026, 417500, 4508, 4844, 4913, 4917", "16"), + Visa("Visa", R.drawable.payment_ic_visa, "4", "13,16,19"); CardEnum(String cardName, @DrawableRes int icon, String startWith, String length) { @@ -89,37 +102,68 @@ Add the dependency Using Luhn can be as simple as these few lines of code. ```java -Luhn.startLuhn(MainActivity.this, new LuhnCallback() { +Luhn.startLuhn(this, new LuhnCallback() { @Override - public void cardDetailsRetrieved(LuhnCard creditCard, final LuhnCardVerifier cardVerifier) { - /** - * Request for Otp with: - * - * cardVerifier.requestOTP(4); - * - * or - * do something with card details and return a callback to luhn using - * - * cardVerifier.onCardVerified(false,"error occured","error message"); - * - *cardVerifier.onCardVerified(true, "", ""); - */ - + public void cardDetailsRetrieved(Context luhnContext, LuhnCard creditCard, final LuhnCardVerifier cardVerifier) { + cardVerifier.startProgress(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + cardVerifier.requestOTP(4); + } + }, 2500); + } + @Override + public void otpRetrieved(Context luhnContext, final LuhnCardVerifier cardVerifier, int otp) { + cardVerifier.startProgress(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + cardVerifier.onCardVerified(false, getString(R.string.verification_error), getString(R.string.verification_error)); + } + }, 2500); } @Override - public void otpRetrieved(int otp, final LuhnCardVerifier cardVerifier) { - /** - * otp is retrieved. - * - * do something with otp and return callback to Luhn - */ + public void onFinished() { + // luhn has finished. Do something } }, R.style.LuhnStyle); ``` -##### Styling +#### Customising CardIo in Luhn + +CardIO Scan Screen can also be customise to suit your app requirement. All you have to do is build a `bundle` with CardIO customise settings and pass it when starting Luhn like so : + +``` + Bundle cardIoBundle = new Bundle(); + cardIoBundle.putBoolean(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: false + cardIoBundle.putBoolean(CardIOActivity.EXTRA_SCAN_EXPIRY, true); // default: false + cardIoBundle.putBoolean(CardIOActivity.EXTRA_REQUIRE_CVV, true); // default: false + cardIoBundle.putBoolean(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false + cardIoBundle.putBoolean(CardIOActivity.EXTRA_HIDE_CARDIO_LOGO, true); // default: false + cardIoBundle.putBoolean(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, true); // default: false + + Luhn.startLuhn(MainActivity.this, new LuhnCallback() { + @Override + public void cardDetailsRetrieved(Context luhnContext, LuhnCard creditCard, LuhnCardVerifier cardVerifier) { + // do something + } + + @Override + public void otpRetrieved(Context luhnContext, LuhnCardVerifier cardVerifier, int otp) { + // do something + } + + @Override + public void onFinished() { + // do something + } + }, cardIoBundle); +``` + +#### Styling in `styles.xml` Luhn activity can be style. IF no style is provided, then a default styling is used. ```xml @@ -131,6 +175,56 @@ in `styles.xml` Luhn activity can be style. IF no style is provided, then a defa true ``` +#### Customising CardIO + +CardIo integration can be customised by calling : +``` +/** + * @param context + * @param luhnCallback - callback for Luhn + * @param cardIOBundle - cardIO settings for card scan + */ + public static void startLuhn(Context context, LuhnCallback luhnCallback, Bundle cardIOBundle) { + sLuhnCallback = luhnCallback; + context.startActivity(new Intent(context, Luhn.class) + .putExtra(CARD_IO, cardIOBundle) + ); + } +``` + +#### Theming Luhn + +colors, strings, dimens of views and components in Luhn is controlled from resources. To theme Luhn to suit and blend with your app, you have to overwrite any of these: + +##### in colors.xml + + ``` + #ff000000 + #ff151525 + #aaaaaa + #ffdd0031 + #ffffff + #ff151525 + #ff6b6b76 + #ffffff + #ffffff + #ff000000 + #ff3a3a48 + #ffa4a4ac + +``` +##### in dimens.xml + +``` + 16sp + 18sp + 18sp +``` +##### in strings.xml + +``` + Saving Card +``` #### Credits