gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] branch master updated (e71c580 -> accae1d)


From: gnunet
Subject: [taler-taler-android] branch master updated (e71c580 -> accae1d)
Date: Tue, 01 Sep 2020 16:29:03 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a change to branch master
in repository taler-android.

    from e71c580  [wallet] fulfillment_url is no longer required in contract 
terms
     new a0b0ee2  [cashier] check authentication credentials against auth 
endpoint
     new c59243c  [wallet] don't crash on serialization errors from wallet-core
     new c928b45  [wallet] support the new TalerErrorInfo error format
     new accae1d  [wallet] show fullfillment message on payment details screen

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .idea/runConfigurations/taler_android__check_.xml  | 21 ++++++++++++
 anastasis-ui/build.gradle                          |  4 +++
 .../src/main/res/layout/fragment_intro.xml         |  4 +--
 build.gradle                                       |  4 +++
 cashier/build.gradle                               | 12 ++++---
 .../src/main/java/net/taler/cashier/Response.kt    |  2 +-
 .../java/net/taler/cashier/config/ConfigManager.kt | 37 +++++++++++++++-------
 merchant-lib/build.gradle                          |  6 +++-
 merchant-terminal/build.gradle                     | 10 ++++--
 taler-kotlin-android/build.gradle                  |  6 +++-
 wallet/build.gradle                                | 16 ++++++----
 .../net/taler/wallet/backend/WalletBackendApi.kt   | 21 ++++++++----
 .../taler/wallet/backend/WalletBackendService.kt   | 12 +++++--
 .../net/taler/wallet/backend/WalletResponse.kt     | 19 ++++++-----
 .../net/taler/wallet/payment/PaymentManager.kt     |  5 ++-
 .../net/taler/wallet/payment/PaymentResponses.kt   |  4 +--
 .../wallet/transactions/TransactionAdapter.kt      |  2 +-
 .../transactions/TransactionDetailFragment.kt      |  6 +++-
 .../net/taler/wallet/transactions/Transactions.kt  | 22 ++++---------
 .../net/taler/wallet/withdraw/WithdrawManager.kt   |  4 +--
 .../net/taler/wallet/backend/WalletResponseTest.kt |  2 +-
 .../taler/wallet/payment/PaymentResponsesTest.kt   |  1 -
 22 files changed, 144 insertions(+), 76 deletions(-)
 create mode 100644 .idea/runConfigurations/taler_android__check_.xml

diff --git a/.idea/runConfigurations/taler_android__check_.xml 
b/.idea/runConfigurations/taler_android__check_.xml
new file mode 100644
index 0000000..5d12227
--- /dev/null
+++ b/.idea/runConfigurations/taler_android__check_.xml
@@ -0,0 +1,21 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="taler-android [check]" 
type="GradleRunConfiguration" factoryName="Gradle">
+    <ExternalSystemSettings>
+      <option name="executionName" />
+      <option name="externalProjectPath" value="$PROJECT_DIR$" />
+      <option name="externalSystemIdString" value="GRADLE" />
+      <option name="scriptParameters" value="" />
+      <option name="taskDescriptions">
+        <list />
+      </option>
+      <option name="taskNames">
+        <list>
+          <option value="check" />
+        </list>
+      </option>
+      <option name="vmOptions" value="" />
+    </ExternalSystemSettings>
+    <GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
+    <method v="2" />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/anastasis-ui/build.gradle b/anastasis-ui/build.gradle
index ff0eec5..0f86815 100644
--- a/anastasis-ui/build.gradle
+++ b/anastasis-ui/build.gradle
@@ -38,6 +38,10 @@ android {
             minifyEnabled false
             proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
+        debug {
+            minifyEnabled minify_debug
+            proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
     }
 
     compileOptions {
diff --git a/anastasis-ui/src/main/res/layout/fragment_intro.xml 
b/anastasis-ui/src/main/res/layout/fragment_intro.xml
index 262287b..32b5b33 100644
--- a/anastasis-ui/src/main/res/layout/fragment_intro.xml
+++ b/anastasis-ui/src/main/res/layout/fragment_intro.xml
@@ -24,7 +24,6 @@
         android:layout_width="0dp"
         android:layout_height="0dp"
         android:layout_margin="16dp"
-        android:tint="@color/green"
         app:layout_constraintBottom_toTopOf="@+id/textView"
         app:layout_constraintDimensionRatio="1:1"
         app:layout_constraintEnd_toEndOf="parent"
@@ -33,7 +32,8 @@
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintVertical_bias="1.0"
         app:layout_constraintVertical_chainStyle="spread"
-        app:srcCompat="@drawable/ic_baseline_cloud_circle" />
+        app:srcCompat="@drawable/ic_baseline_cloud_circle"
+        app:tint="@color/green" />
 
     <TextView
         android:id="@+id/textView"
diff --git a/build.gradle b/build.gradle
index 7c9e378..61fff53 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,9 +2,13 @@ buildscript {
     ext.kotlin_version = '1.4.0'
     ext.ktor_version = "1.4.0"
     ext.nav_version = "2.3.0"
+    ext.material_version = "1.2.0"
     ext.lifecycle_version = "2.2.0"
+    ext.constraintlayout_version = "2.0.1"
     // check https://android-rebuilds.beuc.net/ for availability of free build 
tools
     ext.build_tools_version = "29.0.2"
+    // should debug build types be minified with D8 as well?
+    ext.minify_debug = false
     repositories {
         google()
         jcenter()
diff --git a/cashier/build.gradle b/cashier/build.gradle
index 4defd7a..f5c56a9 100644
--- a/cashier/build.gradle
+++ b/cashier/build.gradle
@@ -41,6 +41,10 @@ android {
             minifyEnabled true
             proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
+        debug {
+            minifyEnabled minify_debug
+            proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
     }
 
     kotlinOptions {
@@ -62,9 +66,9 @@ android {
 
 dependencies {
     implementation project(":taler-kotlin-android")
-    implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
+    implementation 
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
     implementation 'androidx.security:security-crypto:1.0.0-rc03'
-    implementation 'com.google.android.material:material:1.2.0'
+    implementation "com.google.android.material:material:$material_version"
 
     implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
     implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
@@ -75,6 +79,6 @@ dependencies {
 
     testImplementation 'junit:junit:4.13'
 
-    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
-    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
 }
diff --git a/cashier/src/main/java/net/taler/cashier/Response.kt 
b/cashier/src/main/java/net/taler/cashier/Response.kt
index 0ad39d0..c5b1c32 100644
--- a/cashier/src/main/java/net/taler/cashier/Response.kt
+++ b/cashier/src/main/java/net/taler/cashier/Response.kt
@@ -55,7 +55,7 @@ class Response<out T> private constructor(
         }
     }
 
-    private val isFailure: Boolean get() = value is Failure
+    val isFailure: Boolean get() = value is Failure
 
     suspend fun onSuccess(block: suspend (result: T) -> Unit): Response<T> {
         @Suppress("UNCHECKED_CAST")
diff --git a/cashier/src/main/java/net/taler/cashier/config/ConfigManager.kt 
b/cashier/src/main/java/net/taler/cashier/config/ConfigManager.kt
index a18073d..f83c7ba 100644
--- a/cashier/src/main/java/net/taler/cashier/config/ConfigManager.kt
+++ b/cashier/src/main/java/net/taler/cashier/config/ConfigManager.kt
@@ -24,7 +24,10 @@ import androidx.annotation.WorkerThread
 import androidx.lifecycle.LiveData
 import androidx.lifecycle.MutableLiveData
 import androidx.security.crypto.EncryptedSharedPreferences
+import 
androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV
+import 
androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
 import androidx.security.crypto.MasterKeys
+import androidx.security.crypto.MasterKeys.AES256_GCM_SPEC
 import io.ktor.client.HttpClient
 import io.ktor.client.request.get
 import io.ktor.client.request.header
@@ -56,11 +59,9 @@ class ConfigManager(
 
     val configDestination = 
ConfigFragmentDirections.actionGlobalConfigFragment()
 
-    private val masterKeyAlias = 
MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
+    private val masterKeyAlias = MasterKeys.getOrCreate(AES256_GCM_SPEC)
     private val prefs = EncryptedSharedPreferences.create(
-        PREF_NAME, masterKeyAlias, app,
-        EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
-        EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
+        PREF_NAME, masterKeyAlias, app, AES256_SIV, AES256_GCM
     )
 
     internal var config = Config(
@@ -111,17 +112,29 @@ class ConfigManager(
         }
     }
 
-    private suspend fun checkConfig(config: Config): Response<ConfigResponse> =
-        withContext(Dispatchers.IO) {
-            val url = "${config.bankUrl}/config"
-            Log.d(TAG, "Checking config: $url")
-            response {
-                httpClient.get(url) {
-                    // TODO why does that not fail already?
+    private suspend fun checkConfig(config: Config) = 
withContext(Dispatchers.IO) {
+        val url = "${config.bankUrl}/config"
+        Log.d(TAG, "Checking config: $url")
+        val configResponse = response {
+            httpClient.get(url) as ConfigResponse
+        }
+        if (configResponse.isFailure) {
+            configResponse
+        } else {
+            // we need to check an endpoint that requires authentication as 
well
+            // to see if the credentials are valid
+            val balanceResponse = response {
+                val authUrl = 
"${config.bankUrl}/accounts/${config.username}/balance"
+                Log.d(TAG, "Checking auth: $authUrl")
+                httpClient.get<Unit>(authUrl) {
                     header(Authorization, config.basicAuth)
-                } as ConfigResponse
+                }
             }
+            @Suppress("UNCHECKED_CAST")  // The type doesn't matter for 
failures
+            if (balanceResponse.isFailure) balanceResponse as 
Response<ConfigResponse>
+            else configResponse
         }
+    }
 
     @WorkerThread
     @SuppressLint("ApplySharedPref")
diff --git a/merchant-lib/build.gradle b/merchant-lib/build.gradle
index d76f867..87bafd3 100644
--- a/merchant-lib/build.gradle
+++ b/merchant-lib/build.gradle
@@ -38,7 +38,11 @@ android {
 
     buildTypes {
         release {
-            minifyEnabled false
+            minifyEnabled true
+            proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+        debug {
+            minifyEnabled minify_debug
             proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }
diff --git a/merchant-terminal/build.gradle b/merchant-terminal/build.gradle
index 1bdc138..f7bbc1c 100644
--- a/merchant-terminal/build.gradle
+++ b/merchant-terminal/build.gradle
@@ -25,6 +25,10 @@ android {
             minifyEnabled true
             proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
+        debug {
+            minifyEnabled minify_debug
+            proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
     }
 
     compileOptions {
@@ -59,8 +63,8 @@ android {
 dependencies {
     implementation project(":merchant-lib")
 
-    implementation 'com.google.android.material:material:1.1.0'
-    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+    implementation "com.google.android.material:material:$material_version"
+    implementation 
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
     implementation "androidx.recyclerview:recyclerview:1.1.0"
     implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01"
 
@@ -70,6 +74,6 @@ dependencies {
 
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
 
-    testImplementation 'androidx.test.ext:junit:1.1.1'
+    testImplementation 'androidx.test.ext:junit:1.1.2'
     testImplementation 'org.robolectric:robolectric:4.3.1'
 }
diff --git a/taler-kotlin-android/build.gradle 
b/taler-kotlin-android/build.gradle
index 8036800..e57d365 100644
--- a/taler-kotlin-android/build.gradle
+++ b/taler-kotlin-android/build.gradle
@@ -38,7 +38,11 @@ android {
 
     buildTypes {
         release {
-            minifyEnabled false
+            minifyEnabled true
+            proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+        debug {
+            minifyEnabled minify_debug
             proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }
diff --git a/wallet/build.gradle b/wallet/build.gradle
index 70b9648..30cf291 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -24,7 +24,7 @@ plugins {
     id "de.undercouch.download"
 }
 
-def walletCoreVersion = "v0.7.1-dev.22"
+def walletCoreVersion = "v0.7.1-dev.23"
 
 static def versionCodeEpoch() {
     return (new Date().getTime() / 1000).toInteger()
@@ -48,7 +48,7 @@ android {
         minSdkVersion 24
         targetSdkVersion 29
         versionCode 6
-        versionName "0.7.1.dev.22"
+        versionName "0.7.1.dev.23"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         buildConfigField "String", "WALLET_CORE_VERSION", 
"\"$walletCoreVersion\""
     }
@@ -57,6 +57,10 @@ android {
             minifyEnabled true
             proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
+        debug {
+            minifyEnabled minify_debug
+            proguardFiles 
getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
     }
     flavorDimensions "distributionChannel"
     productFlavors {
@@ -105,8 +109,8 @@ dependencies {
     implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
 
     implementation 'androidx.preference:preference:1.1.1'
-    implementation 'com.google.android.material:material:1.2.0'
-    implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
+    implementation "com.google.android.material:material:$material_version"
+    implementation 
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
 
     // Lists and Selection
     implementation "androidx.recyclerview:recyclerview:1.1.0"
@@ -133,8 +137,8 @@ dependencies {
 
     testImplementation 'junit:junit:4.13'
     testImplementation 'org.json:json:20200518'
-    androidTestImplementation 'androidx.test:runner:1.2.0'
-    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+    androidTestImplementation 'androidx.test:runner:1.3.0'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
 }
 
 def walletLibraryDir = "src/main/assets"
diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt 
b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
index c6261bf..a2b48b6 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
@@ -157,13 +157,20 @@ class WalletBackendApi(
                 }
             }
             sendRequest(operation, args?.invoke(JSONObject())) { isError, 
message ->
-                val response = if (isError) {
-                    val error = 
json.decodeFromString(WalletErrorInfo.serializer(), message.toString())
-                    WalletResponse.Error(error)
-                } else {
-                    @Suppress("UNCHECKED_CAST") // if serializer is null, T 
must be Unit
-                    val t: T = serializer?.let { 
json.decodeFromString(serializer, message.toString()) } ?: Unit as T
-                    WalletResponse.Success(t)
+                val response = try {
+                    if (isError) {
+                        val error =
+                            json.decodeFromString(TalerErrorInfo.serializer(), 
message.toString())
+                        WalletResponse.Error(error)
+                    } else {
+                        val t: T = serializer?.let {
+                            json.decodeFromString(serializer, 
message.toString())
+                        } ?: Unit as T
+                        WalletResponse.Success(t)
+                    }
+                } catch (e: Exception) {
+                    val info = TalerErrorInfo(0, "", e.toString(), null)
+                    WalletResponse.Error(info)
                 }
                 cont.resume(response)
             }
diff --git 
a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt 
b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt
index 993114c..c8a2bad 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt
@@ -184,13 +184,16 @@ class WalletBackendService : Service() {
 
     private fun handleAkonoMessage(messageStr: String) {
         val message = JSONObject(messageStr)
-        Log.v(TAG, "got back message: ${message.toString(2)}")
         when (val type = message.getString("type")) {
             "notification" -> {
-                sendNotify(message.getString("payload"))
+                val payload = message.getJSONObject("payload")
+                if (payload.optString("type") != "waiting-for-retry") {
+                    Log.v(TAG, "got back notification: ${message.toString(2)}")
+                }
+                sendNotify(payload.toString())
             }
             "tunnelHttp" -> {
-                Log.v(TAG, "got http tunnel request!")
+                Log.v(TAG, "got http tunnel request! ${message.toString(2)}")
                 Intent().also { intent ->
                     intent.action = HostCardEmulatorService.HTTP_TUNNEL_REQUEST
                     intent.putExtra("tunnelMessage", messageStr)
@@ -204,15 +207,18 @@ class WalletBackendService : Service() {
                         sendNotify(message.toString(2))
                     }
                     "reset" -> {
+                        Log.v(TAG, "got back message: ${message.toString(2)}")
                         exitProcess(1)
                     }
                     else -> {
+                        Log.v(TAG, "got back response: ${message.toString(2)}")
                         val payload = 
message.getJSONObject("result").toString(2)
                         handleResponse(false, message, payload)
                     }
                 }
             }
             "error" -> {
+                Log.v(TAG, "got back error: ${message.toString(2)}")
                 val payload = message.getJSONObject("error").toString(2)
                 handleResponse(true, message, payload)
             }
diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt 
b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
index 5826997..2476607 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
@@ -38,7 +38,7 @@ sealed class WalletResponse<T> {
     @Serializable
     @SerialName("error")
     data class Error<T>(
-        val error: WalletErrorInfo
+        val error: TalerErrorInfo
     ) : WalletResponse<T>()
 
     fun onSuccess(block: (result: T) -> Unit): WalletResponse<T> {
@@ -46,35 +46,34 @@ sealed class WalletResponse<T> {
         return this
     }
 
-    fun onError(block: (result: WalletErrorInfo) -> Unit): WalletResponse<T> {
+    fun onError(block: (result: TalerErrorInfo) -> Unit): WalletResponse<T> {
         if (this is Error) block(this.error)
         return this
     }
 }
 
 @Serializable
-data class WalletErrorInfo(
+data class TalerErrorInfo(
     // Numeric error code defined defined in the
     // GANA gnu-taler-error-codes registry.
-    val talerErrorCode: Int,
+    val code: Int,
 
     // English description of the error code.
-    val talerErrorHint: String,
+    val hint: String?,
 
     // English diagnostic message that can give details
     // for the instance of the error.
-    val message: String,
+    val message: String?,
 
-    // Error details, type depends on talerErrorCode
+    // Error details
     @Serializable(JSONObjectDeserializer::class)
     val details: JSONObject?
 ) {
     val userFacingMsg: String
         get() {
             return StringBuilder().apply {
-                append(talerErrorCode)
-                append(" ")
-                append(message)
+                append(code)
+                message?.let { append(" ").append(it) }
                 details?.let { details ->
                     append("\n\n")
                     details.optJSONObject("errorResponse")?.let { 
errorResponse ->
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt 
b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
index befcd83..9e6984c 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
@@ -26,7 +26,7 @@ import net.taler.common.ContractTerms
 import net.taler.lib.common.Amount
 import net.taler.wallet.TAG
 import net.taler.wallet.backend.WalletBackendApi
-import net.taler.wallet.backend.WalletErrorInfo
+import net.taler.wallet.backend.TalerErrorInfo
 import net.taler.wallet.payment.PayStatus.AlreadyPaid
 import net.taler.wallet.payment.PayStatus.InsufficientBalance
 import net.taler.wallet.payment.PreparePayResponse.AlreadyConfirmedResponse
@@ -76,7 +76,6 @@ class PaymentManager(
         }.onError {
             handleError("preparePay", it)
         }.onSuccess { response ->
-            Log.e(TAG, "PreparePayResponse $response") // TODO remove
             mPayStatus.value = when (response) {
                 is PaymentPossibleResponse -> response.toPayStatusPrepared()
                 is InsufficientBalanceResponse -> InsufficientBalance(
@@ -130,7 +129,7 @@ class PaymentManager(
         mPayStatus.value = PayStatus.None
     }
 
-    private fun handleError(operation: String, error: WalletErrorInfo) {
+    private fun handleError(operation: String, error: TalerErrorInfo) {
         Log.e(TAG, "got $operation error result $error")
         mPayStatus.value = PayStatus.Error(error.userFacingMsg)
     }
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt 
b/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt
index 2e99806..4b908b5 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt
@@ -21,7 +21,7 @@ import kotlinx.serialization.Serializable
 import net.taler.common.ContractTerms
 import net.taler.lib.android.CustomClassDiscriminator
 import net.taler.lib.common.Amount
-import net.taler.wallet.transactions.TransactionError
+import net.taler.wallet.backend.TalerErrorInfo
 
 @Serializable
 sealed class PreparePayResponse {
@@ -75,5 +75,5 @@ sealed class ConfirmPayResult {
 
     @Serializable
     @SerialName("pending")
-    data class Pending(val lastError: TransactionError) : ConfirmPayResult()
+    data class Pending(val lastError: TalerErrorInfo) : ConfirmPayResult()
 }
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
index 9dc2d23..936bbbd 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
@@ -104,7 +104,7 @@ internal class TransactionAdapter(
         private fun bindExtraInfo(transaction: Transaction) {
             if (transaction.error != null) {
                 extraInfoView.text =
-                    context.getString(R.string.payment_error, 
transaction.error!!.text)
+                    context.getString(R.string.payment_error, 
transaction.error!!.userFacingMsg)
                 extraInfoView.setTextColor(red)
                 extraInfoView.visibility = VISIBLE
             } else if (transaction is TransactionWithdrawal && 
!transaction.confirmed) {
diff --git 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
index 1103207..f15e34f 100644
--- 
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ 
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -144,7 +144,11 @@ class TransactionDetailFragment : Fragment() {
     private fun bindOrderAndFee(info: TransactionInfo, raw: Amount, fee: 
Amount) {
         orderAmountView.text = raw.toString()
         feeView.text = getString(R.string.amount_negative, fee.toString())
-        orderSummaryView.text = info.summary
+        orderSummaryView.text = if (info.fulfillmentMessage == null) {
+            info.summary
+        } else {
+            "${info.summary}\n\n${info.fulfillmentMessage}"
+        }
         if (info.fulfillmentUrl?.startsWith("http") == true) {
             val i = Intent().apply {
                 data = Uri.parse(info.fulfillmentUrl)
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt 
b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
index 3210093..db3f283 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
@@ -28,6 +28,7 @@ import net.taler.common.ContractProduct
 import net.taler.lib.common.Amount
 import net.taler.lib.common.Timestamp
 import net.taler.wallet.R
+import net.taler.wallet.backend.TalerErrorInfo
 import net.taler.wallet.cleanExchange
 import net.taler.wallet.transactions.WithdrawalDetails.ManualTransfer
 import net.taler.wallet.transactions.WithdrawalDetails.TalerBankIntegrationApi
@@ -40,7 +41,7 @@ sealed class Transaction {
     abstract val transactionId: String
     abstract val timestamp: Timestamp
     abstract val pending: Boolean
-    abstract val error: TransactionError?
+    abstract val error: TalerErrorInfo?
     abstract val amountRaw: Amount
     abstract val amountEffective: Amount
 
@@ -64,14 +65,6 @@ sealed class AmountType {
     object Neutral : AmountType()
 }
 
-@Serializable
-data class TransactionError(
-    private val ec: Int,
-    private val hint: String? = null,
-) {
-    val text get() = if (hint == null) "$ec" else "$ec $hint"
-}
-
 @Serializable
 @SerialName("withdrawal")
 class TransactionWithdrawal(
@@ -80,7 +73,7 @@ class TransactionWithdrawal(
     override val pending: Boolean,
     val exchangeBaseUrl: String,
     val withdrawalDetails: WithdrawalDetails,
-    override val error: TransactionError? = null,
+    override val error: TalerErrorInfo? = null,
     override val amountRaw: Amount,
     override val amountEffective: Amount
 ) : Transaction() {
@@ -137,7 +130,7 @@ class TransactionPayment(
     override val pending: Boolean,
     val info: TransactionInfo,
     val status: PaymentStatus,
-    override val error: TransactionError? = null,
+    override val error: TalerErrorInfo? = null,
     override val amountRaw: Amount,
     override val amountEffective: Amount
 ) : Transaction() {
@@ -161,7 +154,6 @@ class TransactionInfo(
     val fulfillmentUrl: String? = null,
     /**
      * Message shown to the user after the payment is complete.
-     * TODO actually show this
      */
     val fulfillmentMessage: String? = null,
     /**
@@ -197,7 +189,7 @@ class TransactionRefund(
      * Part of the refund that couldn't be applied because the refund 
permissions were expired
      */
     val amountInvalid: Amount? = null,
-    override val error: TransactionError? = null,
+    override val error: TalerErrorInfo? = null,
     @SerialName("amountEffective") // TODO remove when fixed in wallet-core
     override val amountRaw: Amount,
     @SerialName("amountRaw") // TODO remove when fixed in wallet-core
@@ -224,7 +216,7 @@ class TransactionTip(
     // TODO status: TipStatus,
     val exchangeBaseUrl: String,
     val merchant: ContractMerchant,
-    override val error: TransactionError? = null,
+    override val error: TalerErrorInfo? = null,
     override val amountRaw: Amount,
     override val amountEffective: Amount
 ) : Transaction() {
@@ -247,7 +239,7 @@ class TransactionRefresh(
     override val timestamp: Timestamp,
     override val pending: Boolean,
     val exchangeBaseUrl: String,
-    override val error: TransactionError? = null,
+    override val error: TalerErrorInfo? = null,
     override val amountRaw: Amount,
     override val amountEffective: Amount
 ) : Transaction() {
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt 
b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
index 730f704..b6b4285 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
@@ -25,7 +25,7 @@ import kotlinx.serialization.Serializable
 import net.taler.lib.common.Amount
 import net.taler.wallet.TAG
 import net.taler.wallet.backend.WalletBackendApi
-import net.taler.wallet.backend.WalletErrorInfo
+import net.taler.wallet.backend.TalerErrorInfo
 import net.taler.wallet.exchanges.ExchangeFees
 import net.taler.wallet.exchanges.ExchangeItem
 import net.taler.wallet.withdraw.WithdrawStatus.ReceivedDetails
@@ -201,7 +201,7 @@ class WithdrawManager(
     }
 
     @UiThread
-    private fun handleError(operation: String, error: WalletErrorInfo) {
+    private fun handleError(operation: String, error: TalerErrorInfo) {
         Log.e(TAG, "Error $operation $error")
         withdrawStatus.value = WithdrawStatus.Error(error.userFacingMsg)
     }
diff --git 
a/wallet/src/test/java/net/taler/wallet/backend/WalletResponseTest.kt 
b/wallet/src/test/java/net/taler/wallet/backend/WalletResponseTest.kt
index 4872149..a88b203 100644
--- a/wallet/src/test/java/net/taler/wallet/backend/WalletResponseTest.kt
+++ b/wallet/src/test/java/net/taler/wallet/backend/WalletResponseTest.kt
@@ -67,7 +67,7 @@ class WalletResponseTest {
                 "message":"unexpected exception: Error: BUG: invariant 
violation (purchase status)"
             }
         """.trimIndent()
-        val info = json.decodeFromString(WalletErrorInfo.serializer(), 
infoJson)
+        val info = json.decodeFromString(TalerErrorInfo.serializer(), infoJson)
         println(info.userFacingMsg)
     }
 }
diff --git 
a/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt 
b/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
index 15702c6..fbdc07d 100644
--- a/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
+++ b/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
@@ -57,7 +57,6 @@ class PaymentResponsesTest {
             "max_wire_fee": "CHF:0.1",
             "max_fee": "CHF:0.1",
             "wire_fee_amortization": 10,
-            "merchant_base_url": 
"https:\/\/backend.chf.taler.net\/instances\/department\/",
             "merchant": {
               "name": "BFH Department Technik und Informatik",
               "instance": "department"

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]