-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wallets support to embedded. (#9917)
- Loading branch information
1 parent
96e9ba3
commit f611efb
Showing
11 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ntsheet/src/main/java/com/stripe/android/paymentelement/embedded/EmbeddedWalletsHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.stripe.android.paymentelement.embedded | ||
|
||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata | ||
import com.stripe.android.model.SetupIntent | ||
import com.stripe.android.paymentsheet.LinkHandler | ||
import com.stripe.android.paymentsheet.model.GooglePayButtonType | ||
import com.stripe.android.paymentsheet.state.WalletsState | ||
import com.stripe.android.uicore.utils.combineAsStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import javax.inject.Inject | ||
|
||
internal fun interface EmbeddedWalletsHelper { | ||
fun walletsState(paymentMethodMetadata: PaymentMethodMetadata): StateFlow<WalletsState?> | ||
} | ||
|
||
internal class DefaultEmbeddedWalletsHelper @Inject constructor( | ||
private val linkHandler: LinkHandler, | ||
) : EmbeddedWalletsHelper { | ||
override fun walletsState(paymentMethodMetadata: PaymentMethodMetadata): StateFlow<WalletsState?> { | ||
linkHandler.setupLink(paymentMethodMetadata.linkState) | ||
|
||
return combineAsStateFlow( | ||
linkHandler.isLinkEnabled, | ||
linkHandler.linkConfigurationCoordinator.emailFlow, | ||
) { isLinkAvailable, linkEmail -> | ||
WalletsState.create( | ||
isLinkAvailable = isLinkAvailable, | ||
linkEmail = linkEmail, | ||
isGooglePayReady = paymentMethodMetadata.isGooglePayReady == true, | ||
buttonsEnabled = true, | ||
paymentMethodTypes = paymentMethodMetadata.supportedPaymentMethodTypes(), | ||
googlePayLauncherConfig = null, // This isn't used for embedded. | ||
googlePayButtonType = GooglePayButtonType.Pay, // The actual google pay button isn't shown for embedded. | ||
onGooglePayPressed = { throw IllegalStateException("Not possible.") }, | ||
onLinkPressed = { throw IllegalStateException("Not possible.") }, | ||
isSetupIntent = paymentMethodMetadata.stripeIntent is SetupIntent | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters