Modern Apps git

← Modern-Apps.git

travel: Continue to checkout opens the payment screen

Commit
caac270ba3603f89ce054d72a0561bf2b63c3471
Author
Vayun Mathur <[email protected]>
When
2026-11-01 17:45 UTC (1 month ago)
Parents
4bb0fa6
Since the hosted-checkout rework the button only started checkout in the
background and never navigated, so it appeared to do nothing. Save the extras
(when changed), reset any stale payment intent, then go to Payment, which
fetches the intent for the current total.

Diff

travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt b/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.ktindex c49d976540..dae0934932 100644--- a/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt+++ b/travel/src/main/java/com/vayunmathur/travel/ui/AncillariesPage.kt@@ -36,7 +36,7 @@ import com.vayunmathur.travel.util.AncillariesState import com.vayunmathur.travel.util.TravelViewModel import com.vayunmathur.travel.util.initPassengers import com.vayunmathur.travel.util.retrySeatMaps-import com.vayunmathur.travel.util.saveAncillariesAndContinue+import com.vayunmathur.travel.util.saveAncillaries import com.vayunmathur.travel.util.setBaggageQuantity import com.vayunmathur.travel.util.setExtraQuantity import androidx.compose.ui.res.stringResource@@ -151,7 +151,7 @@ fun AncillariesPage(              Button(                 onClick = {-                    viewModel.saveAncillariesAndContinue()+                    viewModel.saveAncillaries { backStack.add(Route.Payment(offer.offerId)) }                 },                 enabled = !state.loading,                 modifier = Modifier.fillMaxWidth(),
travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.kt b/travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.ktindex 317e79db4d..ee0d9431de 100644--- a/travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.kt+++ b/travel/src/main/java/com/vayunmathur/travel/util/TravelBookingOps.kt@@ -271,13 +271,19 @@ internal fun TravelViewModel.selectedServices(): List<ServiceSelectionDto> { /**  * Save ancillary selections (`POST /trips/:id/ancillaries`, replacing all)  * when they differ from what the trip already has — including clearing them- * back to none. Then moves to checkout.+ * back to none — then call [onSaved] (the page moves on to Payment, which+ * fetches a fresh payment intent for the new total).  */-fun TravelViewModel.saveAncillariesAndContinue() {+fun TravelViewModel.saveAncillaries(onSaved: () -> Unit) {     val tripId = currentTrip?.tripId ?: return     val selections = selectedServices()+    val proceed = {+        // Any earlier intent is for the old total; Payment re-runs checkout from Idle.+        checkoutMutable.value = CheckoutState.Idle+        onSaved()+    }     if (!ancillariesNeedSaving(selections, savedServices)) {-        startCheckout()+        proceed()         return     }     ancillariesMutable.value = ancillariesMutable.value.copy(loading = true, error = null)@@ -286,7 +292,7 @@ fun TravelViewModel.saveAncillariesAndContinue() {             .onSuccess { _: AncillariesSelectionResultDto ->                 savedServices = selections                 ancillariesMutable.value = ancillariesMutable.value.copy(loading = false)-                startCheckout()+                proceed()             }             .onFailure {                 ancillariesMutable.value = ancillariesMutable.value.copy(loading = false, error = errorMessage(it))