From ce11ae8efdc02f155b82692ae25989092d232d7e Mon Sep 17 00:00:00 2001 From: Damian Sullivan Date: Wed, 20 Jan 2016 10:50:45 +0000 Subject: [PATCH 1/5] Correct Android SDK requirement in the read me. It should state ASP level 19, not 14. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4717d6d..48a7c1a 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ You can find more information on how to use this SDK and sign up for a free Real ## Requirements - Android 4.4+ -- Android SDK 14 or later +- Android SDK 19 or later ## Installation From 66ce1046c71df55ccb2c98cbfeb41e03f8c06c9d Mon Sep 17 00:00:00 2001 From: Damian Sullivan Date: Wed, 20 Jan 2016 11:54:19 +0000 Subject: [PATCH 2/5] Suppress New API warning on the two callbacks which are Android 23 callbacks. --- .../main/java/com/realex/hppmanager/HPPManagerFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java b/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java index 8bc9b38..d1fcff7 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java +++ b/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java @@ -1,5 +1,6 @@ package com.realex.hppmanager; +import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.app.Fragment; @@ -212,6 +213,7 @@ public void onReceiveValue(String value) { }, 100); } + @SuppressLint("NewApi") @Override public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { super.onReceivedHttpError(view, request, errorResponse); @@ -224,6 +226,7 @@ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebRes } + @SuppressLint("NewApi") @Override public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { From b7e3c5a188e14e2be5faaf787c4f05d68aaa39bf Mon Sep 17 00:00:00 2001 From: Damian Sullivan Date: Thu, 21 Jan 2016 12:53:58 +0000 Subject: [PATCH 3/5] Refactor to rename "hppmanager" to "rxp-hpp-android", and "realexremote" to "rxp-remote-android" --- README.md | 4 +- {hppmanager => rxp-hpp-android}/.gitignore | 0 {hppmanager => rxp-hpp-android}/build.gradle | 9 +- .../proguard-rules.pro | 2 +- .../realexpayments/hpp/ApplicationTest.java | 14 +++ .../src/main/AndroidManifest.xml | 0 .../com/realexpayments/hpp}/ApiAdapter.java | 2 +- .../com/realexpayments/hpp}/HPPError.java | 2 +- .../com/realexpayments/hpp}/HPPManager.java | 2 +- .../hpp}/HPPManagerFragment.java | 4 +- .../hpp}/HPPManagerListener.java | 2 +- .../com/realexpayments/hpp}/HPPResponse.java | 2 +- .../realexpayments/hpp}/IHPPServerAPI.java | 2 +- .../main/res/layout/hppmanager_fragment.xml | 0 .../src/main/res/values/strings.xml | 0 .../.gitignore | 0 .../build.gradle | 6 +- .../proguard-rules.pro | 2 +- rxp-remote-android/rxp-remote-android.iml | 96 +++++++++++++++++++ .../remote/ValidateAmexCvnTest.java | 47 +++++++++ .../remote/ValidateCardHolderNameTest.java | 73 ++++++++++++++ .../remote/ValidateCardNumberTest.java | 75 +++++++++++++++ .../remote/ValidateCvnTest.java | 53 ++++++++++ .../remote/ValidateExpiryDateFormatTest.java | 71 ++++++++++++++ .../ValidateExpiryDateNotInPastTest.java | 28 ++++++ .../src/main/AndroidManifest.xml | 0 .../realexpayments/remote}/RealexRemote.java | 2 +- .../remote}/ValidateAmexCvn.java | 2 +- .../remote}/ValidateCardHolderName.java | 2 +- .../remote}/ValidateCardNumber.java | 2 +- .../realexpayments/remote}/ValidateCvn.java | 2 +- .../remote}/ValidateExpiryDataFormat.java | 2 +- .../remote}/ValidateExpiryDateNotInPast.java | 2 +- 33 files changed, 484 insertions(+), 26 deletions(-) rename {hppmanager => rxp-hpp-android}/.gitignore (100%) rename {hppmanager => rxp-hpp-android}/build.gradle (66%) rename {hppmanager => rxp-hpp-android}/proguard-rules.pro (85%) create mode 100644 rxp-hpp-android/src/androidTest/java/com/realexpayments/hpp/ApplicationTest.java rename {hppmanager => rxp-hpp-android}/src/main/AndroidManifest.xml (100%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/ApiAdapter.java (93%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/HPPError.java (90%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/HPPManager.java (96%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/HPPManagerFragment.java (96%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/HPPManagerListener.java (96%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/HPPResponse.java (95%) rename {hppmanager/src/main/java/com/realex/hppmanager => rxp-hpp-android/src/main/java/com/realexpayments/hpp}/IHPPServerAPI.java (92%) rename {hppmanager => rxp-hpp-android}/src/main/res/layout/hppmanager_fragment.xml (100%) rename {hppmanager => rxp-hpp-android}/src/main/res/values/strings.xml (100%) rename {realexremote => rxp-remote-android}/.gitignore (100%) rename {realexremote => rxp-remote-android}/build.gradle (77%) rename {realexremote => rxp-remote-android}/proguard-rules.pro (85%) create mode 100644 rxp-remote-android/rxp-remote-android.iml create mode 100644 rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateAmexCvnTest.java create mode 100644 rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardHolderNameTest.java create mode 100644 rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardNumberTest.java create mode 100644 rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCvnTest.java create mode 100644 rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateFormatTest.java create mode 100644 rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateNotInPastTest.java rename {realexremote => rxp-remote-android}/src/main/AndroidManifest.xml (100%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/RealexRemote.java (95%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/ValidateAmexCvn.java (86%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/ValidateCardHolderName.java (91%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/ValidateCardNumber.java (93%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/ValidateCvn.java (86%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/ValidateExpiryDataFormat.java (91%) rename {realexremote/src/main/java/com/realex/realexremote => rxp-remote-android/src/main/java/com/realexpayments/remote}/ValidateExpiryDateNotInPast.java (93%) diff --git a/README.md b/README.md index 57a45c1..a25db50 100755 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ You can integrate the Realex Payments Android SDK into your project manually. https://github.com/realexpayments/rxp-android/releases -- Add module 'hppmanager' into your project to use the HPP SDK. -- If you want to use the card data validation library, add the module 'realexremote' into your project. +- Add module 'rxp-hpp-android' into your project to use the HPP SDK. +- If you want to use the card data validation library, add the module 'rxp-remote-android' into your project. ## Using the HPP SDK diff --git a/hppmanager/.gitignore b/rxp-hpp-android/.gitignore similarity index 100% rename from hppmanager/.gitignore rename to rxp-hpp-android/.gitignore diff --git a/hppmanager/build.gradle b/rxp-hpp-android/build.gradle similarity index 66% rename from hppmanager/build.gradle rename to rxp-hpp-android/build.gradle index 9fcfb1f..2591645 100644 --- a/hppmanager/build.gradle +++ b/rxp-hpp-android/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { - minSdkVersion 14 + minSdkVersion 19 targetSdkVersion 23 versionCode 1 versionName "1.0" @@ -20,7 +20,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.0.1' + compile 'com.google.code.gson:gson:2.5' + compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.squareup.retrofit:retrofit:1.7.1' - compile 'httpcomponents-httpcore:httpcore:4.0-alpha6' + compile 'org.apache.httpcomponents:httpcore:4.4.4' } diff --git a/hppmanager/proguard-rules.pro b/rxp-hpp-android/proguard-rules.pro similarity index 85% rename from hppmanager/proguard-rules.pro rename to rxp-hpp-android/proguard-rules.pro index 1ab18bb..935baf8 100644 --- a/hppmanager/proguard-rules.pro +++ b/rxp-hpp-android/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in C:\Android\sdk/tools/proguard/proguard-android.txt +# in C:\Android\com.realexpayments.hpp.sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # diff --git a/rxp-hpp-android/src/androidTest/java/com/realexpayments/hpp/ApplicationTest.java b/rxp-hpp-android/src/androidTest/java/com/realexpayments/hpp/ApplicationTest.java new file mode 100644 index 0000000..daf302d --- /dev/null +++ b/rxp-hpp-android/src/androidTest/java/com/realexpayments/hpp/ApplicationTest.java @@ -0,0 +1,14 @@ +package hppmanager.realex.com; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/hppmanager/src/main/AndroidManifest.xml b/rxp-hpp-android/src/main/AndroidManifest.xml similarity index 100% rename from hppmanager/src/main/AndroidManifest.xml rename to rxp-hpp-android/src/main/AndroidManifest.xml diff --git a/hppmanager/src/main/java/com/realex/hppmanager/ApiAdapter.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/ApiAdapter.java similarity index 93% rename from hppmanager/src/main/java/com/realex/hppmanager/ApiAdapter.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/ApiAdapter.java index f23c284..be64bcc 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/ApiAdapter.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/ApiAdapter.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; diff --git a/hppmanager/src/main/java/com/realex/hppmanager/HPPError.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPError.java similarity index 90% rename from hppmanager/src/main/java/com/realex/hppmanager/HPPError.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPError.java index e8b54de..4bdcb8a 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/HPPError.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPError.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; /** * HPPError represents runtime exceptions diff --git a/hppmanager/src/main/java/com/realex/hppmanager/HPPManager.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java similarity index 96% rename from hppmanager/src/main/java/com/realex/hppmanager/HPPManager.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java index a800411..72a535d 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/HPPManager.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; import android.app.Fragment; import android.os.Bundle; diff --git a/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java similarity index 96% rename from hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java index d1fcff7..18e1fff 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerFragment.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; import android.annotation.SuppressLint; import android.annotation.TargetApi; @@ -215,7 +215,7 @@ public void onReceiveValue(String value) { @SuppressLint("NewApi") @Override - public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { + public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { super.onReceivedHttpError(view, request, errorResponse); if (this.url.equals(hppManager.getHppURL())) { diff --git a/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerListener.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerListener.java similarity index 96% rename from hppmanager/src/main/java/com/realex/hppmanager/HPPManagerListener.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerListener.java index 084ad44..07c1507 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/HPPManagerListener.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerListener.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; /** * diff --git a/hppmanager/src/main/java/com/realex/hppmanager/HPPResponse.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java similarity index 95% rename from hppmanager/src/main/java/com/realex/hppmanager/HPPResponse.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java index f8a54e4..39da1c3 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/HPPResponse.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; import com.google.gson.annotations.SerializedName; diff --git a/hppmanager/src/main/java/com/realex/hppmanager/IHPPServerAPI.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/IHPPServerAPI.java similarity index 92% rename from hppmanager/src/main/java/com/realex/hppmanager/IHPPServerAPI.java rename to rxp-hpp-android/src/main/java/com/realexpayments/hpp/IHPPServerAPI.java index bfcf941..5bf517f 100644 --- a/hppmanager/src/main/java/com/realex/hppmanager/IHPPServerAPI.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/IHPPServerAPI.java @@ -1,4 +1,4 @@ -package com.realex.hppmanager; +package com.realexpayments.hpp; import java.util.HashMap; diff --git a/hppmanager/src/main/res/layout/hppmanager_fragment.xml b/rxp-hpp-android/src/main/res/layout/hppmanager_fragment.xml similarity index 100% rename from hppmanager/src/main/res/layout/hppmanager_fragment.xml rename to rxp-hpp-android/src/main/res/layout/hppmanager_fragment.xml diff --git a/hppmanager/src/main/res/values/strings.xml b/rxp-hpp-android/src/main/res/values/strings.xml similarity index 100% rename from hppmanager/src/main/res/values/strings.xml rename to rxp-hpp-android/src/main/res/values/strings.xml diff --git a/realexremote/.gitignore b/rxp-remote-android/.gitignore similarity index 100% rename from realexremote/.gitignore rename to rxp-remote-android/.gitignore diff --git a/realexremote/build.gradle b/rxp-remote-android/build.gradle similarity index 77% rename from realexremote/build.gradle rename to rxp-remote-android/build.gradle index 2d4ab23..7c6d2d1 100644 --- a/realexremote/build.gradle +++ b/rxp-remote-android/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { - minSdkVersion 14 + minSdkVersion 19 targetSdkVersion 23 versionCode 1 versionName "1.0" @@ -21,5 +21,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.1.0' + compile 'com.android.support:appcompat-v7:23.1.1' } diff --git a/realexremote/proguard-rules.pro b/rxp-remote-android/proguard-rules.pro similarity index 85% rename from realexremote/proguard-rules.pro rename to rxp-remote-android/proguard-rules.pro index 1ab18bb..935baf8 100644 --- a/realexremote/proguard-rules.pro +++ b/rxp-remote-android/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in C:\Android\sdk/tools/proguard/proguard-android.txt +# in C:\Android\com.realexpayments.hpp.sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # diff --git a/rxp-remote-android/rxp-remote-android.iml b/rxp-remote-android/rxp-remote-android.iml new file mode 100644 index 0000000..7d900b3 --- /dev/null +++ b/rxp-remote-android/rxp-remote-android.iml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateAmexCvnTest.java b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateAmexCvnTest.java new file mode 100644 index 0000000..aa389cf --- /dev/null +++ b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateAmexCvnTest.java @@ -0,0 +1,47 @@ +package com.realexpayments.remote; + +import android.app.Application; +import android.test.ApplicationTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +public class ValidateAmexCvnTest extends ApplicationTestCase { + + public ValidateAmexCvnTest() { + super(Application.class); + } + + @SmallTest + public void testValidAmexCVN() { + assertTrue(RealexRemote.validateAmexCvn("1234")); + } + + @SmallTest + public void testEmptyCVN() { + assertFalse(RealexRemote.validateAmexCvn("")); + } + + @SmallTest + public void testUndefinedCVN() { + assertFalse(RealexRemote.validateAmexCvn(null)); + } + + @SmallTest + public void testWhiteSpaceOnly() { + assertFalse(RealexRemote.validateAmexCvn(" ")); + } + + @SmallTest + public void testAmexCVNof5Numbers() { + assertFalse(RealexRemote.validateAmexCvn("12345")); + } + + @SmallTest + public void testAmexCVNof3Numbers() { + assertFalse(RealexRemote.validateAmexCvn("123")); + } + + @SmallTest + public void testNonNumericAmexCVNof4Characters() { + assertFalse(RealexRemote.validateAmexCvn("123a")); + } +} \ No newline at end of file diff --git a/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardHolderNameTest.java b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardHolderNameTest.java new file mode 100644 index 0000000..8b3b81f --- /dev/null +++ b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardHolderNameTest.java @@ -0,0 +1,73 @@ +package com.realexpayments.remote; + +import android.app.Application; +import android.test.ApplicationTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +/* +* Unit tests for validateCardHolderName +* card holder name validation (validateCardHolderName) +*/ + +public class ValidateCardHolderNameTest extends ApplicationTestCase { + + public ValidateCardHolderNameTest() { + super(Application.class); + } + + @SmallTest + public void testValidName() { + assertTrue(RealexRemote.validateCardHolderName("Joe Smith")); + } + + @SmallTest + public void testEmptyName() { + assertFalse(RealexRemote.validateCardHolderName("")); + } + + @SmallTest + public void testUndefinedName() { + assertFalse(RealexRemote.validateCardHolderName(null)); + } + + @SmallTest + public void testWhiteSpaceOnly() { + assertFalse(RealexRemote.validateCardHolderName(" ")); + } + + @SmallTest + public void testNameOf100Characters() { + assertTrue(RealexRemote.validateCardHolderName("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij")); + } + + @SmallTest + public void testNameOver100Characters() { + assertFalse(RealexRemote.validateCardHolderName("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghija")); + } + + @SmallTest + public void testISO_IEC8859_1Characters1() { + assertTrue(RealexRemote.validateCardHolderName("!\" # $ % & \' ( ) * + - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R")); + } + + @SmallTest + public void testISO_IEC8859_1Characters2() { + assertTrue(RealexRemote.validateCardHolderName("S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ ¡ ¢ £ ¤ ¥")); + } + + @SmallTest + public void testISO_IEC8859_1Characters3() { + assertTrue(RealexRemote.validateCardHolderName("¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö")); + } + + @SmallTest + public void testISO_IEC8859_1Characters4() { + assertTrue(RealexRemote.validateCardHolderName("× Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ")); + } + + @SmallTest + public void testNonISO_IEC8859_1Characters() { + assertFalse(RealexRemote.validateCardHolderName("€")); + } + +} \ No newline at end of file diff --git a/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardNumberTest.java b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardNumberTest.java new file mode 100644 index 0000000..5d1e82f --- /dev/null +++ b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCardNumberTest.java @@ -0,0 +1,75 @@ +package com.realexpayments.remote; + +import android.app.Application; +import android.test.ApplicationTestCase; +import android.test.suitebuilder.annotation.SmallTest; + + +/* + * Unit tests for validateCardNumber + */ + +public class ValidateCardNumberTest extends ApplicationTestCase { + + public ValidateCardNumberTest() { + super(Application.class); + } + + @SmallTest + public void testValidCard() { + assertTrue(RealexRemote.validateCardNumber("424242424242424242")); + } + + @SmallTest + public void testNonNumericCard() { + assertFalse(RealexRemote.validateCardNumber("a24242424242424242")); + } + + @SmallTest + public void testCardWithSpaces() { + assertFalse(RealexRemote.validateCardNumber("4242 424242424242")); + } + + @SmallTest + public void testEmptyCard() { + assertFalse(RealexRemote.validateCardNumber("")); + } + + @SmallTest + public void testUndefinedCard() { + assertFalse(RealexRemote.validateCardNumber(null)); + } + + @SmallTest + public void testWhiteSpaceOnly() { + assertFalse(RealexRemote.validateCardNumber(" ")); + } + + @SmallTest + public void testLengthLt12() { + assertFalse(RealexRemote.validateCardNumber("42424242420")); + } + + @SmallTest + public void testLengthGt19() { + assertFalse(RealexRemote.validateCardNumber("42424242424242424242")); + } + + @SmallTest + public void testLengthEq12() + + { + assertTrue(RealexRemote.validateCardNumber("424242424242")); + } + + @SmallTest + public void testLengthEq19() { + assertTrue(RealexRemote.validateCardNumber("4242424242424242428")); + } + + @SmallTest + public void testLuhnCheck() { + assertFalse(RealexRemote.validateCardNumber("4242424242424242427")); + } + +} \ No newline at end of file diff --git a/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCvnTest.java b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCvnTest.java new file mode 100644 index 0000000..d445181 --- /dev/null +++ b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateCvnTest.java @@ -0,0 +1,53 @@ +package com.realexpayments.remote; + +import android.app.Application; +import android.test.ApplicationTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +/* + * Unit tests for validateCvn + * CVN non-Amex validation (validateCvn) + */ + +public class ValidateCvnTest extends ApplicationTestCase { + + public ValidateCvnTest() { + super(Application.class); + } + + @SmallTest + public void testValidNonAmexCVN() { + assertTrue(RealexRemote.validateCvn("123")); + } + + @SmallTest + public void testEmptyCVN() { + assertFalse(RealexRemote.validateCvn("")); + } + + @SmallTest + public void testUndefinedCVN() { + assertFalse(RealexRemote.validateCvn(null)); + } + + @SmallTest + public void testWhiteSpaceOnly() { + assertFalse(RealexRemote.validateCvn(" ")); + } + + @SmallTest + public void testNonAmexCVNof4Numbers() { + assertFalse(RealexRemote.validateCvn("1234")); + } + + @SmallTest + public void testNonAmexCVNof2Numbers() { + assertFalse(RealexRemote.validateCvn("12")); + } + + @SmallTest + public void testNonNumericNonAmexCVNof3Characters() { + assertFalse(RealexRemote.validateCvn("12a")); + } + +} \ No newline at end of file diff --git a/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateFormatTest.java b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateFormatTest.java new file mode 100644 index 0000000..e2cc050 --- /dev/null +++ b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateFormatTest.java @@ -0,0 +1,71 @@ +package com.realexpayments.remote; + +import android.app.Application; +import android.test.ApplicationTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +/* + * Expiry date format validation (validateExpiryDateFormat) + */ +public class ValidateExpiryDateFormatTest extends ApplicationTestCase { + + public ValidateExpiryDateFormatTest() { + super(Application.class); + } + + @SmallTest + public void testValidDate1299() { + assertTrue(RealexRemote.validateExpiryDateFormat("1299")); + } + + @SmallTest + public void testValidDate0199() { + assertTrue(RealexRemote.validateExpiryDateFormat("0199")); + } + + @SmallTest + public void testNonNumericDate() { + assertFalse(RealexRemote.validateExpiryDateFormat("a199")); + } + + @SmallTest + public void testDateWithSpaces() { + assertFalse(RealexRemote.validateExpiryDateFormat("1 99")); + } + + @SmallTest + public void testEmptyDate() { + assertFalse(RealexRemote.validateExpiryDateFormat("")); + } + + @SmallTest + public void testUndefinedDate() { + assertFalse(RealexRemote.validateExpiryDateFormat(null)); + } + + @SmallTest + public void testWhiteSpaceOnly() { + assertFalse(RealexRemote.validateExpiryDateFormat(" ")); + } + + @SmallTest + public void testLengthGt4() { + assertFalse(RealexRemote.validateExpiryDateFormat("12099")); + } + + @SmallTest + public void testLengthLt4() { + assertFalse(RealexRemote.validateExpiryDateFormat("199")); + } + + @SmallTest + public void testInvalidMonth00() { + assertFalse(RealexRemote.validateExpiryDateFormat("0099")); + } + + @SmallTest + public void testInvalidMonth13() { + assertFalse(RealexRemote.validateExpiryDateFormat("1399")); + } + +} \ No newline at end of file diff --git a/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateNotInPastTest.java b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateNotInPastTest.java new file mode 100644 index 0000000..6714f7c --- /dev/null +++ b/rxp-remote-android/src/androidTest/java/com/realexpayments/remote/ValidateExpiryDateNotInPastTest.java @@ -0,0 +1,28 @@ +package com.realexpayments.remote; + +import android.app.Application; +import android.test.ApplicationTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +import java.text.SimpleDateFormat; +import java.util.Calendar; + +public class ValidateExpiryDateNotInPastTest extends ApplicationTestCase { + + public ValidateExpiryDateNotInPastTest() { + super(Application.class); + } + + @SmallTest + public void testDateInPast() { + assertFalse(RealexRemote.validateExpiryDateNotInPast("0615")); + } + + @SmallTest + public void testCurrentMonth() { + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat format = new SimpleDateFormat("MMyy"); + assertTrue(RealexRemote.validateExpiryDateNotInPast(format.format(calendar.getTime()))); + } + +} \ No newline at end of file diff --git a/realexremote/src/main/AndroidManifest.xml b/rxp-remote-android/src/main/AndroidManifest.xml similarity index 100% rename from realexremote/src/main/AndroidManifest.xml rename to rxp-remote-android/src/main/AndroidManifest.xml diff --git a/realexremote/src/main/java/com/realex/realexremote/RealexRemote.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/RealexRemote.java similarity index 95% rename from realexremote/src/main/java/com/realex/realexremote/RealexRemote.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/RealexRemote.java index 7305b93..aab776d 100644 --- a/realexremote/src/main/java/com/realex/realexremote/RealexRemote.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/RealexRemote.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; public class RealexRemote { diff --git a/realexremote/src/main/java/com/realex/realexremote/ValidateAmexCvn.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateAmexCvn.java similarity index 86% rename from realexremote/src/main/java/com/realex/realexremote/ValidateAmexCvn.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateAmexCvn.java index c0f341a..aaab894 100644 --- a/realexremote/src/main/java/com/realex/realexremote/ValidateAmexCvn.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateAmexCvn.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; /* Validate Amex CVN. Applies to Amex card types. Only allows 4 numeric characters. diff --git a/realexremote/src/main/java/com/realex/realexremote/ValidateCardHolderName.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCardHolderName.java similarity index 91% rename from realexremote/src/main/java/com/realex/realexremote/ValidateCardHolderName.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCardHolderName.java index 73e9eee..d7b6b11 100644 --- a/realexremote/src/main/java/com/realex/realexremote/ValidateCardHolderName.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCardHolderName.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; /* diff --git a/realexremote/src/main/java/com/realex/realexremote/ValidateCardNumber.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCardNumber.java similarity index 93% rename from realexremote/src/main/java/com/realex/realexremote/ValidateCardNumber.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCardNumber.java index 7ac755d..a0ab40e 100644 --- a/realexremote/src/main/java/com/realex/realexremote/ValidateCardNumber.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCardNumber.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; /* Validate Card Number. Returns true if card number valid. Only allows non-empty numeric values between 12 and 19 characters. A Luhn check is also run against the card number. diff --git a/realexremote/src/main/java/com/realex/realexremote/ValidateCvn.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCvn.java similarity index 86% rename from realexremote/src/main/java/com/realex/realexremote/ValidateCvn.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCvn.java index 2b2f918..a145649 100644 --- a/realexremote/src/main/java/com/realex/realexremote/ValidateCvn.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateCvn.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; /* Validate CVN. Applies to non-Amex card types. Only allows 3 numeric characters. diff --git a/realexremote/src/main/java/com/realex/realexremote/ValidateExpiryDataFormat.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateExpiryDataFormat.java similarity index 91% rename from realexremote/src/main/java/com/realex/realexremote/ValidateExpiryDataFormat.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateExpiryDataFormat.java index 0e83da0..fca379b 100644 --- a/realexremote/src/main/java/com/realex/realexremote/ValidateExpiryDataFormat.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateExpiryDataFormat.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; /** * Validate Expiry Date Format. Only allows 4 numeric characters. Month must be between 1 and 12. diff --git a/realexremote/src/main/java/com/realex/realexremote/ValidateExpiryDateNotInPast.java b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateExpiryDateNotInPast.java similarity index 93% rename from realexremote/src/main/java/com/realex/realexremote/ValidateExpiryDateNotInPast.java rename to rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateExpiryDateNotInPast.java index a3aa09f..7965abb 100644 --- a/realexremote/src/main/java/com/realex/realexremote/ValidateExpiryDateNotInPast.java +++ b/rxp-remote-android/src/main/java/com/realexpayments/remote/ValidateExpiryDateNotInPast.java @@ -1,4 +1,4 @@ -package com.realex.realexremote; +package com.realexpayments.remote; /* Validate Expiry Date Not In Past. Also runs checks from validateExpiryDateFormat. From a63c78b921c9f88631c475e7a6a5c5245af92e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20MacDomhnall?= Date: Fri, 22 Jan 2016 11:00:09 +0000 Subject: [PATCH 4/5] Updated readme.md installation instructions --- README.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a25db50..7ca70c1 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,25 @@ You can find more information on how to use this SDK and sign up for a free Real - Android 4.4+ - Android SDK 19 or later -## Installation +## HPP SDK Installation + +### Gradle users +Add this dependency to your project's build file: +``` +compile "com.realexpayments.hpp.sdk:rxp-hpp-android:1.0" +``` + +### Maven users +Add this dependency to your project's POM: +```xml + + com.realexpayments.hpp.sdk + rxp-hpp-android + 1.0 + +``` + +### Manual You can integrate the Realex Payments Android SDK into your project manually. @@ -17,7 +35,6 @@ https://github.com/realexpayments/rxp-android/releases - Add module 'rxp-hpp-android' into your project to use the HPP SDK. - If you want to use the card data validation library, add the module 'rxp-remote-android' into your project. - ## Using the HPP SDK ### Instantiate @@ -131,6 +148,24 @@ Realex Payments maintain separate endpoints for live and test transactions. You hppManager.setHppURL("https://hpp.test.realexpayments.com/pay"; ``` +## Remote API Validation Library Installation + +### Gradle users +Add this dependency to your project's build file: +``` +compile "com.realexpayments.remote.sdk:rxp-remote-android:1.0" +``` + +### Maven users +Add this dependency to your project's POM: +```xml + + com.realexpayments.remote.sdk + rxp-remote-android + 1.0 + +``` + ## License See the LICENSE file. From f57ffd6fe04eed54cb838954e026614e4dcb2210 Mon Sep 17 00:00:00 2001 From: Damian Sullivan Date: Mon, 25 Jan 2016 10:40:38 +0000 Subject: [PATCH 5/5] Update package name in Android Manifest files. --- rxp-hpp-android/src/main/AndroidManifest.xml | 2 +- rxp-remote-android/src/main/AndroidManifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rxp-hpp-android/src/main/AndroidManifest.xml b/rxp-hpp-android/src/main/AndroidManifest.xml index 0839e33..1669d22 100644 --- a/rxp-hpp-android/src/main/AndroidManifest.xml +++ b/rxp-hpp-android/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.realexpayments.hpp"> diff --git a/rxp-remote-android/src/main/AndroidManifest.xml b/rxp-remote-android/src/main/AndroidManifest.xml index 4e373ce..6e7aadf 100644 --- a/rxp-remote-android/src/main/AndroidManifest.xml +++ b/rxp-remote-android/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.realexpayments.remote">