Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nets-in-app committed Sep 1, 2021
1 parent 7a99064 commit c825c6e
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 37 deletions.
4 changes: 4 additions & 0 deletions MiaSample/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ TEST_CHECKOUT_KEY = "YOUR_TEST_CHECKOUT_KEY"
#Production keys
PROD_SECRET_KEY = "YOUR_PROD_SECRET_KEY"
PROD_CHECKOUT_KEY = "YOUR_PROD_CHECKOUT_KEY"
#Pre Prod keys
PRE_PROD_SECRET_KEY = "YOUR_PRE_PROD_SECRET_KEY"
PRE_PROD_CHECKOUT_KEY = "YOUR_PRE_PROD_CHECKOUT_KEY"
```

### MiA Sample Application uses the following 3rd party libraries:
Expand Down
7 changes: 6 additions & 1 deletion MiaSample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ android {
buildConfigField "String", "PROD_CHECKOUT_KEY", PROD_CHECKOUT_KEY
buildConfigField "String", "PROD_BASE_URL", PROD_BASE_URL
buildConfigField "String", "PROD_CHECKOUT_JS", PROD_CHECKOUT_JS

//pre-prod env
buildConfigField "String", "PRE_PROD_SECRET_KEY", PRE_PROD_SECRET_KEY
buildConfigField "String", "PRE_PROD_CHECKOUT_KEY", PRE_PROD_CHECKOUT_KEY
buildConfigField "String", "PRE_PROD_BASE_URL", PRE_PROD_BASE_URL
}


Expand Down Expand Up @@ -61,7 +66,7 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'org.nanohttpd:nanohttpd:2.3.1'

implementation('eu.nets.mia:mia-sdk:1.4.1@aar') { transitive = true; changing=true; }
implementation('eu.nets.mia:mia-sdk:1.5.0@aar') { transitive = true; changing=true; }
}

apply plugin: 'com.google.gms.google-services'
19 changes: 13 additions & 6 deletions MiaSample/app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#Mon Aug 16 12:23:51 EEST 2021
VERSION_NAME=1.5.0
VERSION_CODE=36

PROD_BASE_URL="https\://api.dibspayment.eu/"
VERSION_NAME=1.4.1
TEST_CHECKOUT_JS="https\://test.checkout.dibspayment.eu/v1/checkout.js?v\=1"
VERSION_CODE=35
PROD_CHECKOUT_KEY = "YOUR PROD CHECKOUT KEY HERE"
TEST_BASE_URL="https\://test.api.dibspayment.eu/"
PRE_PROD_BASE_URL="https\://pp-api.dibspayment.eu/"

PROD_CHECKOUT_KEY ="YOUR PROD CHECKOUT KEY HERE"
TEST_CHECKOUT_KEY ="YOUR TEST CHECKOUT KEY HERE"
PRE_PROD_CHECKOUT_KEY = "YOUR PRE PROD CHECKOUT KEY HERE"

PROD_CHECKOUT_JS="https\://checkout.dibspayment.eu/v1/checkout.js?v\=1"
TEST_CHECKOUT_JS="https\://test.checkout.dibspayment.eu/v1/checkout.js?v\=1"

PROD_SECRET_KEY ="YOUR PROD SECRET KEY HERE"
TEST_SECRET_KEY = "YOUR TEST SECRET KEY HERE"
PROD_SECRET_KEY = "YOUR PROD SECRET KEY HERE"
TEST_BASE_URL="https\://test.api.dibspayment.eu/"
PRE_PROD_SECRET_KEY = "YOUR PRE PROD SECRET KEY HERE"
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class MainActivity : AppCompatActivity(), MainActivityView {
//integration types
const val EASY_HOSTED_PAYMENT_WINDOW = "HostedPaymentPage"

//Environment types
const val TEST = "Test Environment"
const val PRE_PROD = "Pre Prod Environment"
const val PROD = "Prod Environment"

//end
//easy hosted payment window helper constants
val RETURN_URL = String.format("%1\$s://miasdk", BuildConfig.APPLICATION_ID)
Expand Down Expand Up @@ -188,6 +193,27 @@ class MainActivity : AppCompatActivity(), MainActivityView {
}
}

//Environment spinner setup for internal use for including Pre-Prod environment

//Environment type spinner
val environmentTypes: List<String> = ArrayList<String>(Arrays.asList(
TEST, PRE_PROD, PROD
))
val environmentTypeAdapter = IntegrationTypeAdapter(this, android.R.layout.simple_spinner_item, environmentTypes)

environmentTypeSpinner.adapter = environmentTypeAdapter
environmentTypeSpinner.setSelection(environmentTypeAdapter.getPositionForItem(SharedPrefs.getInstance().environmentType))
environmentTypeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(p0: AdapterView<*>?) {
//not required
}

override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
SharedPrefs.getInstance().environmentType = environmentTypeAdapter.getItem(p2)
APIManager.recreateInstance()
}
}

//integration type spinner
val integrationTypes: List<String> = ArrayList<String>(Arrays.asList(
EASY_HOSTED_PAYMENT_WINDOW
Expand Down Expand Up @@ -300,7 +326,6 @@ class MainActivity : AppCompatActivity(), MainActivityView {
drawerToggle.drawerArrowDrawable.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN)

//set old user configuration visible
switchProdEnv.isChecked = !SharedPrefs.getInstance().testMode
switchChargePayment.isChecked = SharedPrefs.getInstance().chargePayment

//setup nav drawer items listeners
Expand All @@ -310,11 +335,6 @@ class MainActivity : AppCompatActivity(), MainActivityView {
span.setSpan(StyleSpan(Typeface.BOLD), 0, MiASDK.getInstance().getVersionName().length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
fieldVersion.text = span

switchProdEnv.setOnCheckedChangeListener { _, checked ->
SharedPrefs.getInstance().testMode = !checked
APIManager.recreateInstance()
}

switchChargePayment.setOnCheckedChangeListener { _, checked ->
SharedPrefs.getInstance().chargePayment = checked
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.nets.miasample.network

import eu.nets.miasample.BuildConfig
import eu.nets.miasample.activity.MainActivity
import eu.nets.miasample.network.callback.HttpResponse
import eu.nets.miasample.network.interceptor.HeaderInterceptor
import eu.nets.miasample.network.interceptor.LoggerInterceptor
Expand Down Expand Up @@ -37,7 +38,12 @@ import retrofit2.converter.gson.GsonConverterFactory
*/
class APIManager private constructor(

private var baseUrl: String = if (SharedPrefs.getInstance().testMode) BuildConfig.TEST_BASE_URL else BuildConfig.PROD_BASE_URL,
private var baseUrl: String = when (SharedPrefs.getInstance().environmentType) {
MainActivity.PROD -> BuildConfig.PROD_BASE_URL
MainActivity.PRE_PROD -> BuildConfig.PRE_PROD_BASE_URL
MainActivity.TEST -> BuildConfig.TEST_BASE_URL
else -> BuildConfig.TEST_BASE_URL
},

private val okHttpClient: OkHttpClient = OkHttpClient().newBuilder()
.addInterceptor(LoggerInterceptor())
Expand All @@ -51,20 +57,48 @@ class APIManager private constructor(

companion object {
private var instance = APIManager()
var secretKey = if (SharedPrefs.getInstance().testMode) KeysProvider.testSecretKey else KeysProvider.prodSecretKey
var checkoutKey = if (SharedPrefs.getInstance().testMode) KeysProvider.testCheckoutKey else KeysProvider.prodCheckoutKey
var checkoutJS = if (SharedPrefs.getInstance().testMode) BuildConfig.TEST_CHECKOUT_JS else BuildConfig.PROD_CHECKOUT_JS

var secretKey = getSecretKeyValue()
var checkoutKey = getCheckoutKeyValue()
var checkoutJS = getCheckoutJSValue()

fun getInstance(): APIManager {
return instance
}

fun recreateInstance() {
instance = APIManager()
secretKey = if (SharedPrefs.getInstance().testMode) KeysProvider.testSecretKey else KeysProvider.prodSecretKey
checkoutKey = if (SharedPrefs.getInstance().testMode) KeysProvider.testCheckoutKey else KeysProvider.prodCheckoutKey
checkoutJS = if (SharedPrefs.getInstance().testMode) BuildConfig.TEST_CHECKOUT_JS else BuildConfig.PROD_CHECKOUT_JS
secretKey = getSecretKeyValue()
checkoutKey = getCheckoutKeyValue()
checkoutJS = getCheckoutJSValue()
}

private fun getSecretKeyValue(): String {
return when (SharedPrefs.getInstance().environmentType) {
MainActivity.PROD -> KeysProvider.prodSecretKey
MainActivity.PRE_PROD -> KeysProvider.preProdSecretKey
MainActivity.TEST -> KeysProvider.testSecretKey
else -> KeysProvider.testSecretKey
}
}

private fun getCheckoutKeyValue(): String {
return when (SharedPrefs.getInstance().environmentType) {
MainActivity.PROD -> KeysProvider.prodCheckoutKey
MainActivity.PRE_PROD -> KeysProvider.preProdCheckoutKey
MainActivity.TEST -> KeysProvider.testCheckoutKey
else -> KeysProvider.testCheckoutKey
}
}

private fun getCheckoutJSValue(): String {
return when (SharedPrefs.getInstance().environmentType) {
MainActivity.PROD -> BuildConfig.PROD_CHECKOUT_JS
MainActivity.TEST -> BuildConfig.TEST_CHECKOUT_JS
else -> BuildConfig.TEST_CHECKOUT_JS
}
}

}

fun registerPayment(request: RegisterPaymentRequest, response: HttpResponse<RegisterPaymentResponse>) {
Expand All @@ -76,6 +110,7 @@ class APIManager private constructor(
val call: Call<ChargePaymentResponse> = easyAPIService.chargePayment(paymentId, request)
call.enqueue(response)
}

fun cancelPayment(paymentId: String, request: PaymentActionRequest, response: HttpResponse<String>) {
val call: Call<String> = easyAPIService.cancelPayment(paymentId, request)
call.enqueue(response)
Expand All @@ -85,6 +120,7 @@ class APIManager private constructor(
val call: Call<PaymentResponse> = easyAPIService.getPayment(paymentId)
call.enqueue(response)
}

fun getSubscriptionPayment(paymentId: String, response: HttpResponse<SubscriptionRegistrationResponse>) {
val call: Call<SubscriptionRegistrationResponse> = easyAPIService.fetchSubscriptionPayment(paymentId)
call.enqueue(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ object KeysProvider {
var testCheckoutKey: String = ""
var prodSecretKey: String = ""
var prodCheckoutKey: String = ""
var preProdSecretKey: String = ""
var preProdCheckoutKey: String = ""

init {
assignBuildConfigValues()
Expand All @@ -37,6 +39,8 @@ object KeysProvider {
testCheckoutKey = BuildConfig.TEST_CHECKOUT_KEY
prodSecretKey = BuildConfig.PROD_SECRET_KEY
prodCheckoutKey = BuildConfig.PROD_CHECKOUT_KEY
preProdSecretKey = BuildConfig.PRE_PROD_SECRET_KEY
preProdCheckoutKey = BuildConfig.PRE_PROD_CHECKOUT_KEY
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eu.nets.miasample.utils

import android.content.Context
import android.content.SharedPreferences
import eu.nets.miasample.BuildConfig
import eu.nets.miasample.activity.MainActivity


Expand Down Expand Up @@ -40,7 +41,7 @@ class SharedPrefs {

private val emptyString = ""
private val currencyKey = "KEY_CURRENCY"
private val testModeKey = "TEST_MODE"
private val testModeKey = "TEST_MODE_KEY"
private val chargePaymentKey = "CHARGE_PAYMENT"
private val integrationTypeKey = "INTEGRATION_TYPE"
private val firstNameKey = "FIRSTNAME"
Expand All @@ -58,7 +59,7 @@ class SharedPrefs {
private val productionSubscriptionDetailsKey = "PRODUCTION_SUBSCRIPTION_DETAILS"

val subscriptionDataKey: String get() {
return if (testMode) testSubscriptionDetailsKey else productionSubscriptionDetailsKey
return if (environmentType.equals(MainActivity.TEST)) testSubscriptionDetailsKey else productionSubscriptionDetailsKey
}

var currency: String
Expand All @@ -69,12 +70,12 @@ class SharedPrefs {
sharedPrefs.edit().putString(currencyKey, value).apply()
}

var testMode: Boolean
var environmentType: String
get() {
return sharedPrefs.getBoolean(testModeKey, true)
return sharedPrefs.getString(testModeKey, MainActivity.TEST)
}
set(value) {
sharedPrefs.edit().putBoolean(testModeKey, value).apply()
sharedPrefs.edit().putString(testModeKey, value).apply()
}

var chargePayment: Boolean
Expand Down
19 changes: 11 additions & 8 deletions MiaSample/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,27 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:orientation="horizontal">
android:gravity="center_vertical"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prod_environment"
android:text="@string/environment_type"
android:textColor="@android:color/black"
android:textSize="16sp" />

<android.support.v7.widget.SwitchCompat
android:id="@+id/switchProdEnv"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginStart="20dp"
android:theme="@style/SwitchStyleBasic" />
<Spinner
android:id="@+id/environmentTypeSpinner"
style="@android:style/Widget.DeviceDefault.Light.Spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:padding="2dp" />

</LinearLayout>

Expand Down
2 changes: 2 additions & 0 deletions MiaSample/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@

<string name="hint_mobile_number">912 34 567</string>

<string name="environment_type">Environment</string>


</resources>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Easy - Android SDK v1.4.1
# Easy - Android SDK v1.5.0
----
![Logo](readme-files/NetsLogo.jpg)

Expand All @@ -17,7 +17,7 @@ MiA Easy Android SDK is a library which facilitates the Embedded DIBS Easy Check
----
In your `build.gradle` application level file, add:
```gradle
implementation('eu.nets.mia:mia-sdk:1.4.1') { transitive = true;}
implementation('eu.nets.mia:mia-sdk:1.5.0') { transitive = true;}
```

**Note:** the library is available through both `jcenter()` and `mavenCentral()` repositories.
Expand Down
2 changes: 1 addition & 1 deletion ReactNative/react-native-rn-mia/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ dependencies {
implementation 'com.facebook.react:react-native:+' // From node_modules

// Mia SDK
implementation 'eu.nets.mia:mia-sdk:1.4.1'
implementation 'eu.nets.mia:mia-sdk:1.5.0'
}

def configureReactNativePom(def pom) {
Expand Down
Binary file modified Xamarin/DLL Files/MiASDKBinding.dll
Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion documentation/Start - Overview of MiA Android SDK.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h1><a id="installation"></a>Installation</h1>
<li>Please add the following line in your application's <code>build.gradle</code> file.</li>
</ul>
<pre><code class="language-gradle"><span class="hljs-keyword">dependencies</span> {
implementation(<span class="hljs-string">'eu.nets.mia:mia-sdk:1.4.1'</span>) { transitive = <span class="hljs-keyword">true</span>;}
implementation(<span class="hljs-string">'eu.nets.mia:mia-sdk:1.5.0'</span>) { transitive = <span class="hljs-keyword">true</span>;}
</code></pre>
<h1><a id="getting-started"></a>Getting started</h1>
<hr>
Expand Down Expand Up @@ -486,6 +486,12 @@ <h4><a id="Release_notes_272"></a>Release notes:</h4>
<li>Improved MobilePay app switch support</li>
</ul>

<h4><a id="v150_Released_TBD_271"></a>v1.5.0 Released: 31-Aug-2021</h4>
<h4><a id="Release_notes_272"></a>Release notes:</h4>
<ul>
<li>Added app switch support for Vipps</li>
</ul>

<h4><a id="notes_266"></a>Note:</h4>
<ul>
<li>For any bug reports or question, please contact: mobile-acceptance@nets.eu</li>
Expand Down

0 comments on commit c825c6e

Please sign in to comment.