Ref(DeviceInfo-PaymentResult-WebView):
- Refactor `PaymentResultEntity` to include a nested `PaymentResultDataEntity` and companion factory methods for success and failure. - Update `PaymentResultStatus` enum members from `OK`/`ERROR` to `SUCCESS`/`FAILURE`. - Modify `PspService` and its implementations (`P3`, `PS4`, `Stage`) to return a non-nullable `PaymentResultEntity`. - Enhance `PspWebView` with improved instance lifecycle management, `rememberUpdatedState` for callbacks, and new `onWebViewReady` and `onPageFinished` hooks. - Optimize `PspWebView` to prevent redundant `loadUrl` calls during recomposition. - Add `README.md` and `AGENT.md` to provide project architecture overviews and hardware-specific development guidelines. - Update `TisWebViewScreen` and `StageWebViewScreen` to handle the refactored result models and utilize new WebView callbacks.
This commit is contained in:
@@ -159,24 +159,33 @@ class IapPosService @Inject constructor(
|
||||
|
||||
|
||||
if (result.isNullOrEmpty()) {
|
||||
throw Exception("پرداخت کنسل شد")
|
||||
return PaymentResultEntity.failure(
|
||||
id = id,
|
||||
message = "پرداخت لغو شد!"
|
||||
)
|
||||
}
|
||||
return try {
|
||||
val type = object : TypeToken<Map<String, Any>>() {}.type
|
||||
val data = gson.fromJson<Map<String, Any>>(result, type)
|
||||
PaymentResultEntity(
|
||||
id = id,
|
||||
status = if (data["Status"] == "OK") PaymentResultStatus.OK else PaymentResultStatus.ERROR,
|
||||
terminalId = data["TerminalId"].toString(),
|
||||
stan = data["STAN"].toString(),
|
||||
rrn = data["RRN"].toString(),
|
||||
responseCode = data["ResponseCode"].toString(),
|
||||
customerCardNO = data["CustomerCardNO"].toString(),
|
||||
transactionDateTime = data["TransactionDateTime"].toString(),
|
||||
description = data["Description"].toString()
|
||||
status = if (data["Status"] == "OK") PaymentResultStatus.SUCCESS else PaymentResultStatus.FAILURE,
|
||||
paymentResultDataEntity = PaymentResultEntity.PaymentResultDataEntity(
|
||||
terminalId = data["TerminalId"].toString(),
|
||||
stan = data["STAN"].toString(),
|
||||
rrn = data["RRN"].toString(),
|
||||
responseCode = data["ResponseCode"].toString(),
|
||||
customerCardNO = data["CustomerCardNO"].toString(),
|
||||
transactionDateTime = data["TransactionDateTime"].toString(),
|
||||
),
|
||||
message = data["Description"].toString()
|
||||
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw Exception("POS response is not a JSON object.")
|
||||
PaymentResultEntity.failure(
|
||||
id = id,
|
||||
message = e.message ?: "در هنگام پرداخت خطایی رخ داده است!"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,18 @@ class P3Service @Inject constructor(
|
||||
override fun decodePosResponse(
|
||||
id: String?,
|
||||
activityResult: ActivityResult
|
||||
): PaymentResultEntity? {
|
||||
): PaymentResultEntity {
|
||||
return try {
|
||||
iapPosService.decodeResponse(
|
||||
id = id,
|
||||
activityResult = activityResult
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
e.printStackTrace()
|
||||
PaymentResultEntity.failure(
|
||||
id = id,
|
||||
e.message
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user