From 7a99a2e2cdf81bf42d5a4c4214a8090828c21a74 Mon Sep 17 00:00:00 2001 From: rxp-developers Date: Fri, 10 Nov 2017 16:02:02 +0000 Subject: [PATCH 1/7] Support for HPP Version 2, Base64 encoded or not inputs. --- rxp-hpp-android/build.gradle | 4 +-- .../com/realexpayments/hpp/HPPManager.java | 19 ++++++----- .../hpp/HPPManagerFragment.java | 34 +++++++++++++------ .../com/realexpayments/hpp/HPPResponse.java | 10 ++++++ 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/rxp-hpp-android/build.gradle b/rxp-hpp-android/build.gradle index c39f0e9..b88a204 100644 --- a/rxp-hpp-android/build.gradle +++ b/rxp-hpp-android/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 23 - versionCode 2 - versionName "1.1" + versionCode 3 + versionName "1.2" } buildTypes { release { diff --git a/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java index af7405d..11b7b31 100644 --- a/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManager.java @@ -16,19 +16,14 @@ You set these three URLs as follows; hppManager.setHppRequestProducerURL("https://myserver.com/HPP_Request_Producer.php"); - hppManager.setHppResponseConsumerURL("https://myserver.com/HPP_Response_Consumer.php""); - hppManager.setHppURL("https://pay.sandbox.realexpayments.com/pay"; Set HPP Properties hppManager.setMerchantId("realexsandbox"); - hppManager.setAccount("internet"); - hppManager.setAmount("100"); - hppManager.setCurrency("EUR"); it is also possible to set options by createFromBundle function @@ -50,12 +45,15 @@ public class HPPManager extends HPPResponse { //Supplementary data to be sent to Realex Payments. This will be returned in the HPP response. private HashMap supplementaryData = new HashMap(); + private static boolean isEncoded = false; - public static boolean isLightBox() { - return lightBox; + public static boolean isEncoded() { + return isEncoded; } - private static boolean lightBox = true; + public static void setIsEncoded(boolean isEncoded) { + HPPManager.isEncoded = isEncoded; + } /** * @@ -79,6 +77,7 @@ public void setHppRequestProducerURL(String hppRequestProducerURL) { * @return hpp response consumer url */ public String getHppResponseConsumerURL() { + return hppResponseConsumerURL; } @@ -154,6 +153,8 @@ public static HPPManager createFromBundle(Bundle arg) { hppManager.variableReference = arg.getString(VAR_REF); hppManager.productId = arg.getString(PROD_ID); hppManager.language = arg.getString(HPP_LANG); + hppManager.hppVersion = arg.getString(HPP_VERSION); + hppManager.hppPostResponse = arg.getString(HPP_POST_RESPONSE); hppManager.cardPaymentButtonText = arg.getString(CARD_PAYMENT_BUTTON); hppManager.cardStorageEnable = arg.getString(CARD_STORAGE_ENABLE); hppManager.offerSaveCard = arg.getString(OFFER_SAVE_CARD); @@ -203,6 +204,8 @@ public Fragment newInstance() { args.putString(VAR_REF, variableReference); args.putString(PROD_ID, productId); args.putString(HPP_LANG, language); + args.putString(HPP_VERSION, hppVersion); + args.putString(HPP_POST_RESPONSE, hppPostResponse); args.putString(CARD_PAYMENT_BUTTON, cardPaymentButtonText); args.putString(CARD_STORAGE_ENABLE, cardStorageEnable); args.putString(OFFER_SAVE_CARD, offerSaveCard); diff --git a/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java index 18e1fff..1a20895 100644 --- a/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPManagerFragment.java @@ -38,6 +38,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import android.util.Base64; import retrofit.Callback; import retrofit.RetrofitError; @@ -47,9 +48,9 @@ /** * Payment form fragment. * - Insert the HppManager fragment into your activity as follows; - Fragment hppManagerFragment = hppManager.newInstance();

 - getFragmentManager()
.beginTransaction().add(R.id.container,hppManagerFrament)
.commit(); + Insert the HppManager fragment into your activity as follows; + Fragment hppManagerFragment = hppManager.newInstance();

 + getFragmentManager()
.beginTransaction().add(R.id.container,hppManagerFrament)
.commit(); **/ @@ -215,7 +216,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())) { @@ -265,15 +266,26 @@ public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError e params.put(key, consumer_response_params.get(key)); } - if (hppManager.isLightBox()) { - params.put(HPPManager.HPP_TEMPLATE_TYPE, "LIGHTBOX"); - Uri uri = Uri.parse(hppManager.getHppRequestProducerURL()); - params.put(HPPManager.HPP_ORIGIN, uri.getScheme() + "://" + uri.getHost()); - } + // default to HPP Version 2 + nvps.add(new BasicNameValuePair("HPP_VERSION", "2")); + + // determine the target origin to receive the response + Uri uri = Uri.parse(hppManager.getHppRequestProducerURL()); + nvps.add(new BasicNameValuePair("HPP_POST_RESPONSE", uri.getScheme() + "://" + uri.getHost())); for (String key : params.keySet()) { - if (params.get(key) != null && params.get(key).length() > 0) - nvps.add(new BasicNameValuePair(key, params.get(key))); + if (params.get(key) != null && params.get(key).length() > 0) { + if (hppManager.isEncoded()) { + String encodeValue = new String(params.get(key)); + byte[] decodeValue = Base64.decode(encodeValue.toString(), Base64.DEFAULT); + String decodeValues = new String(decodeValue); + nvps.add(new BasicNameValuePair(key, decodeValues.toString())); + } + + else { + nvps.add(new BasicNameValuePair(key, params.get(key))); + } + } } try { diff --git a/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java index 39da1c3..10cb788 100644 --- a/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java +++ b/rxp-hpp-android/src/main/java/com/realexpayments/hpp/HPPResponse.java @@ -39,6 +39,8 @@ public class HPPResponse { public static final String HPP_TEMPLATE_TYPE = "HPP_TEMPLATE_TYPE"; public static final String HPP_ORIGIN = "HPP_ORIGIN"; public static final String SUPPLEMENTARYDATA = "SUPPLEMENTARYDATA"; + public static final String HPP_VERSION = "HPP_VERSION"; + public static final String HPP_POST_RESPONSE = "HPP_POST_RESPONSE"; /** * Getter for merchant ID. @@ -724,6 +726,12 @@ public void setTemplateType(String templateType) { @SerializedName(HPP_ORIGIN) protected String origin; + @SerializedName(HPP_VERSION) + protected String hppVersion; + + @SerializedName(HPP_POST_RESPONSE) + protected String hppPostResponse; + public HashMap getMap() { HashMap parameters = new HashMap<>(); @@ -756,6 +764,8 @@ public HashMap getMap() { parameters.put(SHA1_HASH, sha1Hash); parameters.put(HPP_TEMPLATE_TYPE, templateType); parameters.put(HPP_ORIGIN, origin); + parameters.put(HPP_VERSION, hppVersion); + parameters.put(HPP_POST_RESPONSE, hppPostResponse); return parameters; } From 9454485139906b6a923ddd1641abe35c3f009a3d Mon Sep 17 00:00:00 2001 From: rxp-developers Date: Fri, 10 Nov 2017 16:09:46 +0000 Subject: [PATCH 2/7] Update readme instructions for hpp sdk 1.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e851c69..15170a8 100755 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You can find more information on how to use this SDK and sign up for a free Real ### Gradle users Add this dependency to your project's build file: ``` -compile "com.realexpayments.hpp.sdk:rxp-hpp-android:1.1" +compile "com.realexpayments.hpp.sdk:rxp-hpp-android:1.2" ``` ### Maven users @@ -20,7 +20,7 @@ Add this dependency to your project's POM: com.realexpayments.hpp.sdk rxp-hpp-android - 1.1 + 1.2 ``` @@ -153,7 +153,7 @@ hppManager.setHppURL("https://pay.sandbox.realexpayments.com/pay"; ### Gradle users Add this dependency to your project's build file: ``` -compile "com.realexpayments.remote.sdk:rxp-remote-android:1.0" +compile "com.realexpayments.remote.sdk:rxp-remote-android:1.1" ``` ### Maven users From fdd95368f053b6de87a2126781e3ad7048f1cb35 Mon Sep 17 00:00:00 2001 From: rxp-developers Date: Fri, 10 Nov 2017 16:13:13 +0000 Subject: [PATCH 3/7] Update readme instructions for hpp sdk 1.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15170a8..c3d07e3 100755 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ Add this dependency to your project's POM: com.realexpayments.remote.sdk rxp-remote-android - 1.0 + 1.1 ``` From 196e1341ffcddb1064a20194ed7bb160ba123a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20MacDomhnall?= Date: Wed, 21 Feb 2018 09:19:57 +0000 Subject: [PATCH 4/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c3d07e3..ba4167d 100755 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ hppManager.setHppURL("https://pay.sandbox.realexpayments.com/pay"; ### Gradle users Add this dependency to your project's build file: ``` -compile "com.realexpayments.remote.sdk:rxp-remote-android:1.1" +compile "com.realexpayments.remote.sdk:rxp-remote-android:1.0" ``` ### Maven users @@ -162,7 +162,7 @@ Add this dependency to your project's POM: com.realexpayments.remote.sdk rxp-remote-android - 1.1 + 1.0 ``` From 2c1867216667f7f5b068bfce8197686e3656b798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20MacDomhnall?= Date: Wed, 21 Feb 2018 09:20:13 +0000 Subject: [PATCH 5/7] Update LICENSE.txt --- LICENSE.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index d2f584d..0b1bfee 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Pay and Shop Ltd t/a Realex Payments +Copyright (c) 2018 Pay and Shop Ltd t/a Realex Payments Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. From cc907d9bac150bae654571c531064bae189ee69b Mon Sep 17 00:00:00 2001 From: rxp-developers Date: Wed, 21 Feb 2018 09:31:29 +0000 Subject: [PATCH 6/7] Revert "Update README.md" This reverts commit 196e1341ffcddb1064a20194ed7bb160ba123a40. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ba4167d..c3d07e3 100755 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ hppManager.setHppURL("https://pay.sandbox.realexpayments.com/pay"; ### Gradle users Add this dependency to your project's build file: ``` -compile "com.realexpayments.remote.sdk:rxp-remote-android:1.0" +compile "com.realexpayments.remote.sdk:rxp-remote-android:1.1" ``` ### Maven users @@ -162,7 +162,7 @@ Add this dependency to your project's POM: com.realexpayments.remote.sdk rxp-remote-android - 1.0 + 1.1 ``` From ff63e8280b1cc6eb964538b270e22a1dd96540d7 Mon Sep 17 00:00:00 2001 From: rxp-developers Date: Wed, 21 Feb 2018 09:36:46 +0000 Subject: [PATCH 7/7] Update build file. --- rxp-remote-android/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rxp-remote-android/build.gradle b/rxp-remote-android/build.gradle index 7c6d2d1..7fbd292 100644 --- a/rxp-remote-android/build.gradle +++ b/rxp-remote-android/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 23 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.1" } buildTypes { release {