diff --git a/LICENSE b/LICENSE
index aa22747..2178b26 100644
--- a/LICENSE
+++ b/LICENSE
@@ -3,7 +3,7 @@ Payment SDK – MIT License |Open Source
Recitals: PagoNxt will offer the payment SDK free of charge, to any person obtaining a copy of this software and associated documentation files under the conditions below. User has to verify the effects of Payment SDK on the implemented environment and will do that at its own risk. Digital downloads are software products. Their contents are protected under copyright and intellectual property law.
-Copyright © 2023 PagoNxt Merchant Solutions S.L. and Santander España Merchant Services, Entidad de Pago, S.L.U.
+Copyright © 2023 PagoNxt Merchant Solutions S.L. and Santander España Merchant Services, Entidad de Pago, S.L.U.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
diff --git a/README.md b/README.md
index eeaeb3d..7566dab 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
# Mobile Payment SDK Android
-For integration visit [docs](https://docs.getneteurope.com/MobilePaymentSDK.html)
+For integration visit [docs](https://docs.getneteurope.com/)
diff --git a/app/build.gradle b/app/build.gradle
index d9c1359..a2b9bb3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -5,18 +5,22 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
+apply plugin: 'testfairy'
android {
- compileSdkVersion 33
+ compileSdkVersion compileVersion
defaultConfig {
applicationId "com.sdkpay.ecom.examples"
- minSdkVersion 23
- targetSdkVersion 33
- versionCode 2
- versionName "1.1.1"
+ minSdkVersion minVersion
+ targetSdkVersion targetVersion
+ versionCode exampleAppVersionCode
+ versionName exampleAppVersion
flavorDimensions "default"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
+ lintOptions {
+ abortOnError false
+ }
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
@@ -38,6 +42,12 @@ android {
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
}
}
+ buildFeatures {
+ compose true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion androidxComposeCompiler
+ }
productFlavors {
normal {
@@ -51,15 +61,28 @@ android {
}
}
+apply from: 'libs/versions.gradle'
apply from: 'libs/dependencies.gradle'
dependencies {
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
- testImplementation "junit:junit:4.13.2"
- androidTestImplementation "androidx.test.ext:junit:1.1.5"
- androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
+ testImplementation "junit:junit:$junit"
+ androidTestImplementation "androidx.test.ext:junit:$testExt"
+ androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCore"
+
+ implementation "androidx.compose.ui:ui:$androidxCompose"
+ implementation "androidx.compose.ui:ui-tooling:$androidxCompose"
+ implementation "androidx.compose.ui:ui-tooling-preview:$androidxCompose"
+ implementation "androidx.compose.foundation:foundation:$androidxCompose"
+ implementation "androidx.compose.material:material:$androidxCompose"
+ implementation "androidx.compose.material:material-icons-core:$androidxCompose"
+ implementation "androidx.compose.material:material-icons-extended:$androidxCompose"
+ implementation "androidx.activity:activity-compose:$androidxActivityCompose"
+
+ debugImplementation "androidx.compose.ui:ui-tooling:$androidxCompose"
+ debugImplementation "androidx.compose.ui:ui-test-manifest:$androidxCompose"
implementation files('libs/alipay.aar')
implementation files('libs/camera.aar')
@@ -73,5 +96,9 @@ dependencies {
implementation files('libs/ratepay.aar')
implementation files('libs/blik.aar')
implementation files('libs/bizum.aar')
+ implementation files('libs/ideal.aar')
+ implementation files('libs/mbway.aar')
+ implementation files('libs/mbreferencia.aar')
+ implementation files('libs/zinia.aar')
}
diff --git a/app/gradlew.bat b/app/gradlew.bat
index f955316..e95643d 100644
--- a/app/gradlew.bat
+++ b/app/gradlew.bat
@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/app/libs/alipay.aar b/app/libs/alipay.aar
index b2b109d..8a47635 100644
Binary files a/app/libs/alipay.aar and b/app/libs/alipay.aar differ
diff --git a/app/libs/bizum.aar b/app/libs/bizum.aar
index 8eb05da..790be9b 100644
Binary files a/app/libs/bizum.aar and b/app/libs/bizum.aar differ
diff --git a/app/libs/blik.aar b/app/libs/blik.aar
index 045d23a..f937ccd 100644
Binary files a/app/libs/blik.aar and b/app/libs/blik.aar differ
diff --git a/app/libs/camera.aar b/app/libs/camera.aar
index 7b965ae..8e60684 100644
Binary files a/app/libs/camera.aar and b/app/libs/camera.aar differ
diff --git a/app/libs/card.aar b/app/libs/card.aar
index d4c6f13..4997510 100644
Binary files a/app/libs/card.aar and b/app/libs/card.aar differ
diff --git a/app/libs/core.aar b/app/libs/core.aar
index 33f2143..a6de341 100644
Binary files a/app/libs/core.aar and b/app/libs/core.aar differ
diff --git a/app/libs/dependencies.gradle b/app/libs/dependencies.gradle
index a62c76a..8311962 100644
--- a/app/libs/dependencies.gradle
+++ b/app/libs/dependencies.gradle
@@ -4,17 +4,6 @@
*/
dependencies {
- def kotlinVersion = "1.8.20"
- def appCompat = "1.6.1"
- def material = "1.8.0"
- def actvityKtx = "1.7.1"
- def fragmentKtx = "1.5.7"
- def rxKotlin = "2.2.0"
- def rxAndroid = "2.1.0"
- def constraint = "2.1.4"
- def coreKtx = "1.10.0"
- def lifecycleRuntimeKtx = "2.2.0"
- def camerax = "1.0.2"
implementation "androidx.appcompat:appcompat:$appCompat"
implementation "com.google.android.material:material:$material"
diff --git a/app/libs/ideal.aar b/app/libs/ideal.aar
new file mode 100644
index 0000000..8a4062c
Binary files /dev/null and b/app/libs/ideal.aar differ
diff --git a/app/libs/mbreferencia.aar b/app/libs/mbreferencia.aar
new file mode 100644
index 0000000..e352f6c
Binary files /dev/null and b/app/libs/mbreferencia.aar differ
diff --git a/app/libs/mbway.aar b/app/libs/mbway.aar
new file mode 100644
index 0000000..b2f18a5
Binary files /dev/null and b/app/libs/mbway.aar differ
diff --git a/app/libs/p24.aar b/app/libs/p24.aar
index 9a9b14e..5c6337c 100644
Binary files a/app/libs/p24.aar and b/app/libs/p24.aar differ
diff --git a/app/libs/paypal.aar b/app/libs/paypal.aar
index e52c2da..b8d3050 100644
Binary files a/app/libs/paypal.aar and b/app/libs/paypal.aar differ
diff --git a/app/libs/ratepay.aar b/app/libs/ratepay.aar
index fab55a4..2177db1 100644
Binary files a/app/libs/ratepay.aar and b/app/libs/ratepay.aar differ
diff --git a/app/libs/sepa.aar b/app/libs/sepa.aar
index ee7fbb9..86d989f 100644
Binary files a/app/libs/sepa.aar and b/app/libs/sepa.aar differ
diff --git a/app/libs/sofort.aar b/app/libs/sofort.aar
index ff44e2d..2496b8f 100644
Binary files a/app/libs/sofort.aar and b/app/libs/sofort.aar differ
diff --git a/app/libs/versions.gradle b/app/libs/versions.gradle
new file mode 100644
index 0000000..7589aa7
--- /dev/null
+++ b/app/libs/versions.gradle
@@ -0,0 +1,73 @@
+ext {
+ def prop = new Properties()
+ try {
+ prop.load(new FileInputStream(file('../project.properties')))
+ } catch (Exception e) {
+ }
+ releaseVersion = prop.getProperty("version")
+ releaseCode = releaseVersion.replaceAll("[^\\d]", "").toInteger()
+ sdkVersion = releaseVersion
+ gradlePlugin = '7.4.0'
+ kotlinGradlePlugin = '1.8.20'
+ testfairy = '3.+'
+ kotlinVersion = '1.8.20'
+ rxKotlin = '2.2.0'
+ rxAndroid = '2.1.0'
+ uiautomator = "2.2.0"
+ testRules = "1.2.0"
+ junit = '4.13.2'
+ testExt = "1.1.5"
+ testAnnotation = "1.1.0"
+ assertj = "3.15.0"
+ mockito = "2.18.3"
+ mockitoKotlin = "1.6.0"
+ espressoJunit = '1.1.5'
+ espressoCore = '3.5.1'
+ androidxCompose = "1.4.3"
+ androidxComposeCompiler = "1.4.6"
+ androidxActivityCompose = "1.5.1"
+ appCompat = "1.6.1"
+ material = "1.8.0"
+ constraint = "2.1.4"
+ coreKtx = "1.10.0"
+ actvityKtx = "1.7.1"
+ fragmentKtx = "1.5.7"
+ lifecycleRuntimeKtx = "2.2.0"
+ viewModelLifecycle = "2.6.1"
+ timber = "4.7.1"
+ camerax = '1.0.2'
+ recyclerview = "1.3.0"
+ cardview = "1.0.0"
+ butterknife = "10.2.1"
+ navigationCompose = "2.5.2"
+ eventbus = "3.0.0"
+ calligraphy = "2.3.0"
+ retrofit = "2.9.0"
+ loggingInterceptor = "4.4.0"
+ mockwebserver = "4.4.0"
+ iban4j = "3.2.1"
+ rxjava2 = "2.2.9"
+ voyager = "1.0.0-rc02"
+ sonar = "3.5.0.2730"
+
+ // Global versions
+ minVersion = 23
+ targetVersion = 33
+ compileVersion = 33
+ minifyEnabledDebug = true
+ minifyEnabledRelease = true
+ enabledDebuggable = true
+
+ // Test app
+ testAppVersion = "2.6.15"
+ testAppVersionCode = 2696
+
+ //Example app
+ exampleAppVersion = "2.5.9"
+ exampleAppVersionCode = 10
+
+ //Shop app
+ shopAppVersion = "1.9.10"
+ shopAppVersionCode = 190
+
+}
diff --git a/app/libs/wiretransfer.aar b/app/libs/wiretransfer.aar
index 09b6292..f83110b 100644
Binary files a/app/libs/wiretransfer.aar and b/app/libs/wiretransfer.aar differ
diff --git a/app/libs/zinia.aar b/app/libs/zinia.aar
new file mode 100644
index 0000000..3e38ba3
Binary files /dev/null and b/app/libs/zinia.aar differ
diff --git a/app/src/androidTest/java/com/sdkpay/ecom/examples/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/sdkpay/ecom/examples/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..b587d72
--- /dev/null
+++ b/app/src/androidTest/java/com/sdkpay/ecom/examples/ExampleInstrumentedTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2023 PagoNxt Merchant Solutions S.L. and Santander España Merchant Services, Entidad de Pago, S.L.U.
+ * You may not use this file except in compliance with the License which is available at https://mit-license.org/
+ */
+
+package com.sdkpay.ecom.examples;
+
+import android.content.Context;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.sdkpay.ecom.examples", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 207a171..c9138cd 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,13 +1,15 @@
+
-
+ android:theme="@style/AppTheme.NoActionBar"/>
-
-
-
-
-
-
+ android:theme="@style/AppTheme.NoActionBar"/>
-
-
-
-
+ android:theme="@style/AppTheme.NoActionBar"/>
{
- private final Context mContext = this;
- AnimatedCardFieldFragment animatedCardFieldFragment;
- PaymentObjectProvider mPaymentObjectProvider = new PaymentObjectProvider(new OptionalFieldsProvider());
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_animated_card_form);
-
- animatedCardFieldFragment = new AnimatedCardFieldFragment.Builder()
- .setRequestFocus(true)
- .setRequireManualCardBrandSelection(true)
- .build();
-
- getSupportFragmentManager()
- .beginTransaction()
- .add(R.id.card_field_container, animatedCardFieldFragment)
- .commit();
-
- animatedCardFieldFragment
- .getEventObserver()
- .subscribe(
- state -> {
- Log.i("event", state.toString());
- }
- );
- }
-
- public void onSubmitButtonClicked(View view) {
- if(animatedCardFieldFragment.getCardBundle() != null) {
- new Client(this, URL_EE_TEST, REQUEST_TIMEOUT).startPayment(mPaymentObjectProvider.getCardFormPayment(animatedCardFieldFragment.getCardBundle()));
- findViewById(R.id.progress).setVisibility(View.VISIBLE);
- }else {
- Toast.makeText(mContext, "Card bundle is null!", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onObserve(PaymentResponse paymentResponse) {
- runOnUiThread(() -> {
- Toast.makeText(this, ResponseHelper.getFormattedResponse(paymentResponse), Toast.LENGTH_SHORT).show();
- findViewById(R.id.progress).setVisibility(View.GONE);
- }
-
- );
- }
-}
diff --git a/app/src/main/java/com/sdkpay/ecom/examples/AnimatedCardFieldActivity.kt b/app/src/main/java/com/sdkpay/ecom/examples/AnimatedCardFieldActivity.kt
new file mode 100644
index 0000000..7773003
--- /dev/null
+++ b/app/src/main/java/com/sdkpay/ecom/examples/AnimatedCardFieldActivity.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2023 PagoNxt Merchant Solutions S.L. and Santander España Merchant Services, Entidad de Pago, S.L.U.
+ * You may not use this file except in compliance with the License which is available at https://mit-license.org/
+ */
+package com.sdkpay.ecom.examples
+
+import android.content.Context
+import android.os.Bundle
+import android.util.Log
+import android.view.View
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import com.sdkpay.ecom.Client
+import com.sdkpay.ecom.card.AnimatedCardFieldFragment
+import com.sdkpay.ecom.card.ui.cardform.animated.AnimatedCardFieldState
+import com.sdkpay.ecom.examples.Constants.REQUEST_TIMEOUT
+import com.sdkpay.ecom.examples.Constants.URL_EE_TEST
+import com.sdkpay.ecom.examples.ResponseHelper.getFormattedResponse
+import com.sdkpay.ecom.examples.providers.OptionalFieldsProvider
+import com.sdkpay.ecom.examples.providers.PaymentObjectProvider
+import com.sdkpay.ecom.model.PaymentResponse
+import com.sdkpay.ecom.util.Observer
+
+class AnimatedCardFieldActivity : AppCompatActivity(), Observer {
+ private val mContext: Context = this
+ lateinit var animatedCardFieldFragment: AnimatedCardFieldFragment
+ var mPaymentObjectProvider = PaymentObjectProvider(OptionalFieldsProvider())
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_animated_card_form)
+ animatedCardFieldFragment = AnimatedCardFieldFragment.Builder()
+ .setRequestFocus(true)
+ .setRequireManualCardBrandSelection(true)
+ .build()
+ supportFragmentManager
+ .beginTransaction()
+ .add(R.id.card_field_container, animatedCardFieldFragment)
+ .commit()
+ animatedCardFieldFragment
+ .getEventObserver()
+ .subscribe { state: AnimatedCardFieldState -> Log.i("event", state.toString()) }
+ }
+
+ fun onSubmitButtonClicked(view: View?) {
+ val bundle = animatedCardFieldFragment.getCardBundle()
+ if (bundle != null) {
+ Client(this, URL_EE_TEST, REQUEST_TIMEOUT).startPayment(
+ mPaymentObjectProvider.getCardFormPayment(bundle)
+ )
+ findViewById(R.id.progress).visibility = View.VISIBLE
+ } else {
+ Toast.makeText(mContext, "Card bundle is null!", Toast.LENGTH_SHORT).show()
+ }
+ }
+
+ override fun onObserve(paymentResponse: PaymentResponse) {
+ runOnUiThread {
+ Toast.makeText(this, getFormattedResponse(paymentResponse), Toast.LENGTH_SHORT).show()
+ findViewById(R.id.progress).visibility = View.GONE
+ }
+ }
+}
diff --git a/app/src/main/java/com/sdkpay/ecom/examples/CardFieldActivity.java b/app/src/main/java/com/sdkpay/ecom/examples/CardFieldActivity.java
deleted file mode 100644
index 407803e..0000000
--- a/app/src/main/java/com/sdkpay/ecom/examples/CardFieldActivity.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright © 2023 PagoNxt Merchant Solutions S.L. and Santander España Merchant Services, Entidad de Pago, S.L.U.
- * You may not use this file except in compliance with the License which is available at https://mit-license.org/
- */
-
-package com.sdkpay.ecom.examples;
-
-import android.content.Context;
-import android.os.Bundle;
-
-import androidx.appcompat.app.AppCompatActivity;
-
-import android.util.Log;
-import android.view.View;
-import android.widget.Toast;
-
-import com.sdkpay.ecom.Client;
-import com.sdkpay.ecom.card.CardFieldFragment;
-import com.sdkpay.ecom.examples.providers.OptionalFieldsProvider;
-import com.sdkpay.ecom.examples.providers.PaymentObjectProvider;
-import com.sdkpay.ecom.model.PaymentResponse;
-import com.sdkpay.ecom.util.Observer;
-
-import static com.sdkpay.ecom.examples.Constants.REQUEST_TIMEOUT;
-import static com.sdkpay.ecom.examples.Constants.URL_EE_TEST;
-
-public class CardFieldActivity extends AppCompatActivity implements Observer {
- private final Context mContext = this;
- private final PaymentObjectProvider mPaymentObjectProvider = new PaymentObjectProvider(new OptionalFieldsProvider());
- CardFieldFragment cardFieldFragment;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_card_form);
-
- cardFieldFragment = new CardFieldFragment.Builder()
- .setRequireManualCardBrandSelection(true)
- .build();
- getSupportFragmentManager()
- .beginTransaction()
- .add(R.id.card_field_container, cardFieldFragment)
- .commit();
-
- cardFieldFragment
- .getEventObserver()
- .subscribe(
- state -> {
- Log.i("event", state.toString());
- }
- );
- }
-
- public void onSubmitButtonClicked(View view) {
- if (cardFieldFragment.getCardBundle() != null) {
- new Client(this, URL_EE_TEST, REQUEST_TIMEOUT).startPayment(mPaymentObjectProvider.getCardFormPayment(cardFieldFragment.getCardBundle()));
- findViewById(R.id.progress).setVisibility(View.VISIBLE);
- } else {
- Toast.makeText(mContext, "Card bundle is null!", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onObserve(PaymentResponse paymentResponse) {
- runOnUiThread(() -> {
- Toast.makeText(this, ResponseHelper.getFormattedResponse(paymentResponse), Toast.LENGTH_SHORT).show();
- findViewById(R.id.progress).setVisibility(View.GONE);
- }
-
- );
- }
-}
diff --git a/app/src/main/java/com/sdkpay/ecom/examples/KotlinCardFieldActivity.kt b/app/src/main/java/com/sdkpay/ecom/examples/CardFieldActivity.kt
similarity index 61%
rename from app/src/main/java/com/sdkpay/ecom/examples/KotlinCardFieldActivity.kt
rename to app/src/main/java/com/sdkpay/ecom/examples/CardFieldActivity.kt
index b70d729..54414da 100644
--- a/app/src/main/java/com/sdkpay/ecom/examples/KotlinCardFieldActivity.kt
+++ b/app/src/main/java/com/sdkpay/ecom/examples/CardFieldActivity.kt
@@ -2,48 +2,48 @@
* Copyright © 2023 PagoNxt Merchant Solutions S.L. and Santander España Merchant Services, Entidad de Pago, S.L.U.
* You may not use this file except in compliance with the License which is available at https://mit-license.org/
*/
-
package com.sdkpay.ecom.examples
+import android.content.Context
import android.os.Bundle
-import androidx.appcompat.app.AppCompatActivity
import android.util.Log
import android.view.View
import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
import com.sdkpay.ecom.Client
import com.sdkpay.ecom.card.CardFieldFragment
+import com.sdkpay.ecom.card.ui.cardform.CardFieldState
import com.sdkpay.ecom.examples.Constants.REQUEST_TIMEOUT
import com.sdkpay.ecom.examples.Constants.URL_EE_TEST
+import com.sdkpay.ecom.examples.ResponseHelper.getFormattedResponse
import com.sdkpay.ecom.examples.providers.OptionalFieldsProvider
import com.sdkpay.ecom.examples.providers.PaymentObjectProvider
import com.sdkpay.ecom.model.PaymentResponse
import com.sdkpay.ecom.util.Observer
-class KotlinCardFieldActivity : AppCompatActivity(), Observer {
- private val mContext = this
+class CardFieldActivity : AppCompatActivity(), Observer {
+ private val mContext: Context = this
private val mPaymentObjectProvider = PaymentObjectProvider(OptionalFieldsProvider())
- private lateinit var cardFieldFragment: CardFieldFragment
-
+ lateinit var cardFieldFragment: CardFieldFragment
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_card_form)
-
cardFieldFragment = CardFieldFragment.Builder()
- .setRequireManualCardBrandSelection(true)
- .build()
+ .setRequireManualCardBrandSelection(true)
+ .build()
supportFragmentManager
- .beginTransaction()
- .add(R.id.card_field_container, cardFieldFragment)
- .commit()
-
+ .beginTransaction()
+ .add(R.id.card_field_container, cardFieldFragment)
+ .commit()
cardFieldFragment
- .getEventObserver()
- .subscribe { state -> Log.i("event", state.toString()) }
+ .getEventObserver()
+ .subscribe { state: CardFieldState -> Log.i("event", state.toString()) }
}
- fun onSubmitButtonClicked(view: View) {
- if (cardFieldFragment.getCardBundle() != null) {
- Client(this, URL_EE_TEST, REQUEST_TIMEOUT).startPayment(mPaymentObjectProvider.getCardFormPayment(cardFieldFragment.getCardBundle()))
+ fun onSubmitButtonClicked(view: View?) {
+ val bundle = cardFieldFragment.getCardBundle()
+ if (bundle != null) {
+ Client(this, URL_EE_TEST, REQUEST_TIMEOUT).startPayment(mPaymentObjectProvider.getCardFormPayment(bundle))
findViewById(R.id.progress).visibility = View.VISIBLE
} else {
Toast.makeText(mContext, "Card bundle is null!", Toast.LENGTH_SHORT).show()
@@ -52,7 +52,7 @@ class KotlinCardFieldActivity : AppCompatActivity(), Observer {
override fun onObserve(paymentResponse: PaymentResponse) {
runOnUiThread {
- Toast.makeText(mContext, ResponseHelper.getFormattedResponse(paymentResponse), Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, getFormattedResponse(paymentResponse), Toast.LENGTH_SHORT).show()
findViewById(R.id.progress).visibility = View.GONE
}
}
diff --git a/app/src/main/java/com/sdkpay/ecom/examples/CardFieldFragmentImplFragment.kt b/app/src/main/java/com/sdkpay/ecom/examples/CardFieldFragmentImplFragment.kt
index 1ba8165..3945d41 100644
--- a/app/src/main/java/com/sdkpay/ecom/examples/CardFieldFragmentImplFragment.kt
+++ b/app/src/main/java/com/sdkpay/ecom/examples/CardFieldFragmentImplFragment.kt
@@ -47,8 +47,9 @@ class CardFieldFragmentImplFragment: Fragment(), Observer {
.subscribe { state -> Log.i("event", state.toString()) }
activity?.findViewById