Feat(All): Tis
create first version
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,40 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.hilt)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.core"
|
||||
compileSdk {
|
||||
version = release(36) {
|
||||
minorApiLevel = 1
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.hilt.android)
|
||||
ksp(libs.hilt.compiler)
|
||||
implementation(libs.retrofit.converter.gson)
|
||||
|
||||
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.material)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.example.core
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.example.core.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.example.core.data
|
||||
|
||||
import com.example.core.domain.PaymentResult
|
||||
import com.example.core.model.PaymentResultEntity
|
||||
import com.google.gson.Gson
|
||||
import javax.inject.Inject
|
||||
|
||||
class PaymentResultImpl @Inject constructor(
|
||||
private val gson: Gson
|
||||
) : PaymentResult {
|
||||
|
||||
override fun post(paymentResultEntity: PaymentResultEntity?): String {
|
||||
return "window.onPaymentResult(${gson.toJson(paymentResultEntity)});"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.example.core.di
|
||||
|
||||
import com.example.core.data.PaymentResultImpl
|
||||
import com.example.core.domain.PaymentResult
|
||||
import com.google.gson.Gson
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
||||
class CoreModule {
|
||||
@Provides
|
||||
fun provideGson(): Gson {
|
||||
return Gson()
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providePaymentResult(
|
||||
gson: Gson
|
||||
): PaymentResult = PaymentResultImpl(
|
||||
gson = gson
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.core.domain
|
||||
|
||||
import com.example.core.model.PaymentResultEntity
|
||||
|
||||
interface PaymentResult {
|
||||
fun post(paymentResultEntity: PaymentResultEntity?) : String
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.example.core.domain
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.result.ActivityResult
|
||||
import com.example.core.model.PaymentResultEntity
|
||||
|
||||
interface PspService {
|
||||
fun pay(amount: Long): Intent
|
||||
fun print(lines: List<String>, onMessage: (String) -> Unit)
|
||||
|
||||
// POS App specific
|
||||
fun decodePosResponse(
|
||||
id: String?,
|
||||
activityResult: ActivityResult
|
||||
): PaymentResultEntity?
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.core.model
|
||||
|
||||
data class PaymentResultEntity(
|
||||
val id : String? = null,
|
||||
val status : PaymentResultStatus,
|
||||
val terminalId : String,
|
||||
val stan : String,
|
||||
val rrn : String,
|
||||
val responseCode : String,
|
||||
val customerCardNO : String,
|
||||
val transactionDateTime : String,
|
||||
val description : String?,
|
||||
|
||||
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.core.model
|
||||
|
||||
enum class PaymentResultStatus {
|
||||
OK,
|
||||
ERROR
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.example.core
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user