Skip to content

Commit 532ff99

Browse files
committed
feat(feature:send-money): add payment success screen
1 parent fc705bc commit 532ff99

File tree

10 files changed

+609
-14
lines changed

10 files changed

+609
-14
lines changed

cmp-android/prodRelease-badging.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package: name='org.mifospay' versionCode='1' versionName='2025.8.4-beta.0.10' platformBuildVersionName='15' platformBuildVersionCode='35' compileSdkVersion='35' compileSdkVersionCodename='15'
1+
package: name='org.mifospay' versionCode='1' versionName='2025.8.4-beta.0.11' platformBuildVersionName='15' platformBuildVersionCode='35' compileSdkVersion='35' compileSdkVersionCodename='15'
22
minSdkVersion:'26'
33
targetSdkVersion:'34'
44
uses-permission: name='android.permission.INTERNET'

cmp-shared/src/commonMain/kotlin/org/mifospay/shared/navigation/MifosNavHost.kt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ import org.mifospay.feature.send.money.navigation.SEND_MONEY_BASE_ROUTE
7575
import org.mifospay.feature.send.money.navigation.SEND_MONEY_OPTIONS_ROUTE
7676
import org.mifospay.feature.send.money.navigation.navigateToPayeeDetailsScreen
7777
import org.mifospay.feature.send.money.navigation.navigateToPaymentProcessingScreen
78+
import org.mifospay.feature.send.money.navigation.navigateToPaymentSuccessScreen
7879
import org.mifospay.feature.send.money.navigation.navigateToSendMoneyOptionsScreen
7980
import org.mifospay.feature.send.money.navigation.navigateToSendMoneyScreen
8081
import org.mifospay.feature.send.money.navigation.payeeDetailsScreen
8182
import org.mifospay.feature.send.money.navigation.paymentProcessingScreen
83+
import org.mifospay.feature.send.money.navigation.paymentSuccessScreen
8284
import org.mifospay.feature.send.money.navigation.sendMoneyOptionsScreen
8385
import org.mifospay.feature.send.money.navigation.sendMoneyScreen
8486
import org.mifospay.feature.settings.navigation.settingsScreen
@@ -335,17 +337,31 @@ internal fun MifosNavHost(
335337
)
336338

337339
paymentProcessingScreen(
338-
onPaymentComplete = {
340+
onPaymentComplete = { payeeName, amount, upiName, transactionTimestamp ->
341+
navController.navigateToPaymentSuccessScreen(
342+
payeeName = payeeName,
343+
amount = amount,
344+
upiName = upiName,
345+
transactionTimestamp = transactionTimestamp,
346+
)
347+
},
348+
onPaymentFailed = { errorMessage ->
349+
navController.popBackStack()
350+
},
351+
)
352+
353+
paymentSuccessScreen(
354+
onShareScreenshot = {
355+
// TODO: Implement screenshot sharing functionality
356+
},
357+
onDone = {
339358
navController.navigate(HOME_ROUTE) {
340359
popUpTo(HOME_ROUTE) {
341360
inclusive = false
342361
}
343362
launchSingleTop = true
344363
}
345364
},
346-
onPaymentFailed = { errorMessage ->
347-
navController.popBackStack()
348-
},
349365
)
350366

351367
transferScreen(

feature/send-money/src/commonMain/composeResources/values/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,12 @@
6868
<string name="feature_send_money_continue">Continue</string>
6969
<string name="feature_send_money_paying_securely">Paying securely %1$s to</string>
7070
<string name="feature_send_money_paid_to">Paid to</string>
71+
72+
<!-- Payment Success Screen -->
73+
<string name="feature_send_money_payment_success">Payment Successful</string>
74+
<string name="feature_send_money_banking_name">Banking name: %1$s</string>
75+
<string name="feature_send_money_powered_by_upi">Powered by UPI</string>
76+
<string name="feature_send_money_share_screenshot">Share screenshot</string>
77+
<string name="feature_send_money_done">Done</string>
78+
<string name="feature_send_money_payment_success_description">Payment completed successfully</string>
7179
</resources>

feature/send-money/src/commonMain/kotlin/org/mifospay/feature/send/money/PayeeDetailsScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ private fun ProceedButton(
580580
val isButtonEnabled = if (hasSelectedAccount) {
581581
isAmountValid && isContactValid
582582
} else {
583-
isAmountValid && isContactValid && (isAmountPrefilled || state.hasNoteFieldBeenFocused)
583+
isAmountValid && isContactValid && state.amount.isNotEmpty()
584584
}
585585

586586
Button(

feature/send-money/src/commonMain/kotlin/org/mifospay/feature/send/money/PaymentProcessingScreen.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import template.core.base.designsystem.theme.KptTheme
4040

4141
@Composable
4242
fun PaymentProcessingScreen(
43-
onPaymentComplete: () -> Unit,
43+
onPaymentComplete: (String, String, String, String) -> Unit,
4444
onPaymentFailed: (String) -> Unit,
4545
modifier: Modifier = Modifier,
4646
viewModel: PaymentProcessingViewModel = koinViewModel(),
@@ -49,7 +49,12 @@ fun PaymentProcessingScreen(
4949

5050
EventsEffect(viewModel) { event ->
5151
when (event) {
52-
is PaymentProcessingEvent.PaymentComplete -> onPaymentComplete.invoke()
52+
is PaymentProcessingEvent.PaymentComplete -> onPaymentComplete.invoke(
53+
event.payeeName,
54+
event.amount,
55+
event.upiName,
56+
event.transactionTimestamp,
57+
)
5358
is PaymentProcessingEvent.PaymentFailed -> onPaymentFailed.invoke(event.errorMessage)
5459
}
5560
}
@@ -130,7 +135,7 @@ private fun PaymentProcessingContent(
130135
@Composable
131136
fun PaymentProcessingScreenPreview() {
132137
PaymentProcessingScreen(
133-
onPaymentComplete = {},
138+
onPaymentComplete = { _, _, _, _ -> },
134139
onPaymentFailed = {},
135140
modifier = Modifier,
136141
)

feature/send-money/src/commonMain/kotlin/org/mifospay/feature/send/money/PaymentProcessingViewModel.kt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.lifecycle.viewModelScope
1414
import kotlinx.coroutines.delay
1515
import kotlinx.coroutines.flow.update
1616
import kotlinx.coroutines.launch
17+
import kotlinx.datetime.Clock
1718
import org.mifospay.core.ui.utils.BaseViewModel
1819

1920
class PaymentProcessingViewModel(
@@ -43,13 +44,20 @@ class PaymentProcessingViewModel(
4344
try {
4445
mutableStateFlow.update { it.copy(isProcessing = true) }
4546

46-
delay(3000) // Simulate payment processing time
47+
delay(3000)
4748

4849
mutableStateFlow.update { it.copy(isProcessing = false) }
4950

50-
delay(1000) // Show completion state briefly
51+
delay(1000)
5152

52-
sendEvent(PaymentProcessingEvent.PaymentComplete)
53+
sendEvent(
54+
PaymentProcessingEvent.PaymentComplete(
55+
payeeName = state.payeeName,
56+
amount = state.amount,
57+
upiName = state.payeeName.uppercase(),
58+
transactionTimestamp = getCurrentUnixTimestamp(),
59+
),
60+
)
5361
} catch (e: Exception) {
5462
sendEvent(PaymentProcessingEvent.PaymentFailed(e.message ?: "Payment failed"))
5563
}
@@ -63,6 +71,14 @@ class PaymentProcessingViewModel(
6371
}
6472
}
6573
}
74+
75+
/**
76+
* Gets the current Unix timestamp from the mobile device
77+
* This is used as a fallback when PSP timestamp is not available
78+
*/
79+
private fun getCurrentUnixTimestamp(): String {
80+
return Clock.System.now().epochSeconds.toString()
81+
}
6682
}
6783

6884
data class PaymentProcessingState(
@@ -76,7 +92,12 @@ data class PaymentProcessingState(
7692
}
7793

7894
sealed interface PaymentProcessingEvent {
79-
data object PaymentComplete : PaymentProcessingEvent
95+
data class PaymentComplete(
96+
val payeeName: String,
97+
val amount: String,
98+
val upiName: String,
99+
val transactionTimestamp: String,
100+
) : PaymentProcessingEvent
80101
data class PaymentFailed(val errorMessage: String) : PaymentProcessingEvent
81102
}
82103

0 commit comments

Comments
 (0)