Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Provide customer ephemeral key is called twice #8837

Closed
ncapitelli opened this issue Jul 22, 2024 · 1 comment · Fixed by #9493
Closed

[BUG] Provide customer ephemeral key is called twice #8837

ncapitelli opened this issue Jul 22, 2024 · 1 comment · Fixed by #9493
Labels

Comments

@ncapitelli
Copy link

Summary

When the CustomerSheet component is launched, the customerEphemeralKeyProvider callback gets triggered twice, even though the component is only launched once. This happens because LaunchedEffect(Unit) and remember are used, preventing its reinitialization.

Code to reproduce

@Composable
@OptIn(ExperimentalCustomerSheetApi::class)
fun WalletBottomSheet(state: WalletState) {
    val customerSheet = rememberCustomerSheet(
        configuration = CustomerSheet
            .Configuration
            .builder(merchantDisplayName = state.merchantName)
            .googlePayEnabled(state.displayGooglePay)
            .build(),
        customerAdapter = CustomerAdapter.create(
            context = LocalContext.current,
            customerEphemeralKeyProvider = {
                println("It's called twice")
                state.customerEphemeralKeyProvider.provideCustomerEphemeralKey()
            },
            setupIntentClientSecretProvider = null,
        ),
        callback = state.onResult,
    )

    LaunchedEffect(Unit) {
        customerSheet.present()
    }
}

Android version

All versions are impacted

Impacted devices

All devices are impacted

Installation method

Installation using gradle dependency

Dependency Versions

kotlin: 1.9.24
stripe-android: 20.48.0
Android Gradle Plugin:
Gradle: 8.7

SDK classes

Video

Other information

@ncapitelli ncapitelli added the bug label Jul 22, 2024
@jaynewstrom-stripe
Copy link
Collaborator

Hi @ncapitelli I'm able to reproduce this, and it's not a desired behavior. I'll try to get a fix into the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants