Skip to content

Commit

Permalink
[MBL1260] Add Checkout Screen to Flow (#1991)
Browse files Browse the repository at this point in the history
* WIP pager experimentation

* Merge branch 'master' into mgriego/experimental_compose_pager

* add some fixes for add-ons screen, add shipping rules

* remove some unused imports

* updated spacing for add-ons container

* move checkout flow code to its own viewmodel

* [MBL-1257] Add existing logic for rewards carousel to new compose flow (#1978)

* adjust viewmodel to use UI State class for reward carousel

* Add logic for rewards carousel screen, fix a few visual bugs, adjust logic to use coroutines and flows/ui states

* lint

* more lint

* move reward carousel logic into its own viewmodel/ui state

* lint and info comments

* add display logic for confirm details screen

* add stripe card ids

* remove unused import

* add create checkout call to move on from confirmation page

* formatting and default action on next button

* lint

* add logic for quantities for confirm screen

* fix logic when displaying the shipping location an amounts

* add bonus support min additions and amount conversions

* lint

* update implementation in checkout screen based on local changes

* remove unneeded disclaimer text on reward cards

* remove unused import

* add new translated string

* fix shipping amount for rewards (add-ons not working?)

* preliminary changes for the late pledge checkout screen, WIP

* MBL-1258 Add logic for add ons screen (#1980)

* Skeleton AddOnsVM and navigation to Confirm Pledge Details screen

* Logic for location selector - hide for digital addons, update shipping costs when location changes

* Fix bug with currentShippingRule state not persisting

* Update AddOnsUIState.currentAddOnsSelection instead of local addOnsMap to correctly count total addons

* Fix bug where addOnCount is not remembered when navigating back to addons

* Clean up ktlint

* Clear previous addons selection when a new reward is selected

* Also clear individual item count when new reward is selected

* If reward cannot be shipped, only display addons that also cannot be shipped

* Fix ktlint

* Reset shippingSelectorIsGone when new reward is selected

* Copy over Alex's fix on master

* ktlint

* Add comment back to config.yml

* add full id list for confirm checkout, calculate totals more accurately

* [NoTicket] Fix add-ons shipping rule logic  (#1987)

* move add-ons and shipping rules logic out of flow viewmodel, fix add-ons shipping amounts diplayed, update add-ons when shipping rule changes, filter add-ons based on reward selection

* lint

* MBL-1291: Feature Flag for latePledges (#1986)

* clean up state emission

* remove unneeded binging reference

* more lint

* another lint

* some bug fixes and code cleanup

---------

Co-authored-by: Yun Cheng <[email protected]>
Co-authored-by: Isabel Martin <[email protected]>
  • Loading branch information
3 people authored Mar 27, 2024
1 parent aed54b6 commit 8fcc125
Show file tree
Hide file tree
Showing 7 changed files with 452 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.apollographql.apollo.ApolloCall
import com.apollographql.apollo.ApolloClient
import com.apollographql.apollo.api.Response
import com.apollographql.apollo.exception.ApolloException
import com.google.android.gms.common.util.Base64Utils
import com.google.gson.Gson
import com.kickstarter.libs.utils.extensions.isNotNull
import com.kickstarter.models.Backing
Expand Down Expand Up @@ -93,6 +94,7 @@ import type.CurrencyCode
import type.NonDeprecatedFlaggingKind
import type.PaymentTypes
import type.StripeIntentContextTypes
import java.nio.charset.Charset

interface ApolloClientTypeV2 {
fun getProject(project: Project): Observable<Project>
Expand Down Expand Up @@ -1570,7 +1572,7 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient

this.service.mutate(
CompleteOnSessionCheckoutMutation.builder()
.checkoutId(checkoutId)
.checkoutId(Base64Utils.encodeUrlSafe(("Checkout-$checkoutId").toByteArray(Charset.defaultCharset())))
.paymentIntentClientSecret(paymentIntentClientSecret)
.paymentSourceId(paymentSourceId)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import com.kickstarter.ui.fragments.RewardsFragment
import com.kickstarter.viewmodels.projectpage.AddOnsViewModel
import com.kickstarter.viewmodels.projectpage.CheckoutFlowViewModel
import com.kickstarter.viewmodels.projectpage.ConfirmDetailsViewModel
import com.kickstarter.viewmodels.projectpage.LatePledgeCheckoutViewModel
import com.kickstarter.viewmodels.projectpage.PagerTabConfig
import com.kickstarter.viewmodels.projectpage.ProjectPageViewModel
import com.kickstarter.viewmodels.projectpage.RewardsSelectionViewModel
Expand Down Expand Up @@ -111,6 +112,9 @@ class ProjectPageActivity :
private lateinit var confirmDetailsViewModelFactory: ConfirmDetailsViewModel.Factory
private val confirmDetailsViewModel: ConfirmDetailsViewModel by viewModels { confirmDetailsViewModelFactory }

private lateinit var latePledgeCheckoutViewModelFactory: LatePledgeCheckoutViewModel.Factory
private val latePledgeCheckoutViewModel: LatePledgeCheckoutViewModel by viewModels { latePledgeCheckoutViewModelFactory }

private lateinit var addOnsViewModelFactory: AddOnsViewModel.Factory
private val addOnsViewModel: AddOnsViewModel by viewModels { addOnsViewModelFactory }

Expand Down Expand Up @@ -151,6 +155,7 @@ class ProjectPageActivity :
checkoutViewModelFactory = CheckoutFlowViewModel.Factory(env)
confirmDetailsViewModelFactory = ConfirmDetailsViewModel.Factory(env)
addOnsViewModelFactory = AddOnsViewModel.Factory(env)
latePledgeCheckoutViewModelFactory = LatePledgeCheckoutViewModel.Factory(env)
env
}

Expand Down Expand Up @@ -512,8 +517,14 @@ class ProjectPageActivity :
if (checkoutPayment.id != 0L) checkoutFlowViewModel.onConfirmDetailsContinueClicked {
startLoginToutActivity()
}
latePledgeCheckoutViewModel.provideCheckoutId(checkoutPayment.id)
}

val latePledgeCheckoutUIState by latePledgeCheckoutViewModel.latePledgeCheckoutUIState.collectAsStateWithLifecycle()

val userStoredCards = latePledgeCheckoutUIState.storeCards
val userEmail = latePledgeCheckoutUIState.userEmail

val pagerState = rememberPagerState(initialPage = 0, pageCount = { 4 })

this@ProjectPageActivity.onBackPressedDispatcher.addCallback {
Expand Down Expand Up @@ -594,9 +605,16 @@ class ProjectPageActivity :
}
}
},
storedCards = userStoredCards,
userEmail = userEmail,
onBonusSupportMinusClicked = { confirmDetailsViewModel.decrementBonusSupport() },
onBonusSupportPlusClicked = { confirmDetailsViewModel.incrementBonusSupport() },
selectedAddOnsMap = selectedAddOnsMap
selectedAddOnsMap = selectedAddOnsMap,
onPledgeCtaClicked = { selectedCard ->
latePledgeCheckoutViewModel.onPledgeButtonClicked(selectedCard = selectedCard, project = projectData.project(), totalAmount = totalAmount)
},
onAddPaymentMethodClicked = {
}
)
}
}
Expand Down
Loading

0 comments on commit 8fcc125

Please sign in to comment.