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:
Amir Mousavi
2026-05-17 13:40:32 +03:30
parent 2b03af6e52
commit 08060001e1
14 changed files with 254 additions and 72 deletions
@@ -54,13 +54,13 @@ fun StageWebViewScreen(
activityResult = result
)
val jsResult = viewModel.postPaymentResult(paymentResultEntity)
val currentWebView = webView
if (currentWebView == null) {
Log.w(stageWebViewTag, "Skipping onPaymentResult JS callback: WebView is not ready yet.")
} else {
currentWebView.post {
currentWebView.evaluateJavascript(jsResult, null)
webView?.let {
it.post {
it.evaluateJavascript(jsResult, null)
}
} ?: run {
Log.w(stageWebViewTag, "Skipping onPaymentResult JS callback: WebView is not ready yet.")
}
isPaymentProcessing = false
}
@@ -32,17 +32,23 @@ class StageViewModel @Inject constructor(
id: String?,
activityResult: ActivityResult
): PaymentResultEntity {
return PaymentResultEntity(
val mockPaymentResult = PaymentResultEntity.success(
id = id,
status = com.example.core.model.PaymentResultStatus.ERROR,
terminalId = "123456",
stan = "123456",
rrn = "123456",
responseCode = "01",
customerCardNO = "1234567890123456",
transactionDateTime = "14030101120000",
description = "تراکنش ناموفق"
message = "تراکنش با موفقیت انجام شد",
data = PaymentResultEntity.PaymentResultDataEntity(
terminalId = "123456",
stan = "123456",
rrn = "123456789012",
responseCode = "00",
customerCardNO = "603799******1234",
transactionDateTime = "1403/05/20 12:30:45"
)
)
return mockPaymentResult
// return pspService.decodePosResponse(
// id = id,
// activityResult = activityResult
// )
}
private val mock = listOf<PrintEntity>(