Skip to content

Commit

Permalink
Add EventReporter
Browse files Browse the repository at this point in the history
  • Loading branch information
tjclawson-stripe committed Jan 26, 2025
1 parent b0a1c79 commit 65c4a6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.CompositionLocalProvider
import com.stripe.android.common.ui.ElementsBottomSheetLayout
import com.stripe.android.paymentsheet.verticalmode.VerticalModeFormUI
import com.stripe.android.ui.core.elements.events.LocalCardBrandDisallowedReporter
import com.stripe.android.ui.core.elements.events.LocalCardNumberCompletedEventReporter
import com.stripe.android.uicore.StripeTheme
import com.stripe.android.uicore.elements.LocalAutofillEventReporter
import com.stripe.android.uicore.elements.bottomsheet.rememberStripeBottomSheetState
import com.stripe.android.uicore.utils.fadeOut

Expand Down Expand Up @@ -47,10 +51,16 @@ internal class FormActivity : AppCompatActivity() {
finish()
}
) {
VerticalModeFormUI(
interactor = viewModel.formInteractor,
showsWalletHeader = false
)
CompositionLocalProvider(
LocalAutofillEventReporter provides viewModel.eventReporter::onAutofill,
LocalCardNumberCompletedEventReporter provides viewModel.eventReporter::onCardNumberCompleted,
LocalCardBrandDisallowedReporter provides viewModel.eventReporter::onDisallowedCardBrandEntered
) {
VerticalModeFormUI(
interactor = viewModel.formInteractor,
showsWalletHeader = false
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.stripe.android.paymentsheet.DefaultFormHelper
import com.stripe.android.paymentsheet.FormHelper
import com.stripe.android.paymentsheet.LinkInlineHandler
import com.stripe.android.paymentsheet.NewOrExternalPaymentSelection
import com.stripe.android.paymentsheet.analytics.EventReporter
import com.stripe.android.paymentsheet.model.PaymentSelection
import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormArguments
import com.stripe.android.paymentsheet.verticalmode.BankFormInteractor
Expand All @@ -33,6 +34,7 @@ internal class FormActivityViewModel @Inject constructor(
private val cardAccountRangeRepositoryFactory: CardAccountRangeRepository.Factory,
private val selectionHolder: EmbeddedSelectionHolder,
private val linkConfigurationCoordinator: LinkConfigurationCoordinator,
val eventReporter: EventReporter
) : ViewModel() {

val formInteractor = initializeFormInteractor(paymentMethodMetadata, selectedPaymentMethodCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadataFactory
import com.stripe.android.model.PaymentMethodCode
import com.stripe.android.paymentelement.embedded.EmbeddedSelectionHolder
import com.stripe.android.paymentsheet.analytics.FakeEventReporter
import com.stripe.android.utils.FakeLinkConfigurationCoordinator
import com.stripe.android.utils.NullCardAccountRangeRepositoryFactory
import kotlinx.coroutines.test.runTest
Expand Down Expand Up @@ -39,7 +40,8 @@ internal class FormActivityViewModelTest {
selectedPaymentMethodCode = paymentMethodCode,
cardAccountRangeRepositoryFactory = NullCardAccountRangeRepositoryFactory,
selectionHolder = selectionHolder,
linkConfigurationCoordinator = FakeLinkConfigurationCoordinator()
linkConfigurationCoordinator = FakeLinkConfigurationCoordinator(),
eventReporter = FakeEventReporter()
)
}
}

0 comments on commit 65c4a6b

Please sign in to comment.