Skip to content

Commit

Permalink
Hack flags
Browse files Browse the repository at this point in the history
  • Loading branch information
toluo-stripe committed Jan 17, 2025
1 parent 1056bff commit 934c98e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal class LinkActivity : ComponentActivity() {
)
this@LinkActivity.setResult(
RESULT_COMPLETE,
Intent().putExtras(bundle)
intent.putExtras(bundle)
)
this@LinkActivity.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class LinkActivityContract @Inject internal constructor(
) : ActivityResultContract<LinkActivityContract.Args, LinkActivityResult>() {

override fun createIntent(context: Context, input: Args): Intent {
return if (FeatureFlags.nativeLinkEnabled.isEnabled && input.configuration.useAttestationEndpointsForLink) {
return if (useNativeLink(input)) {
nativeLinkActivityContract.createIntent(context, input).apply {
putExtra(EXTRA_USED_NATIVE_CONTRACT, true)
}
Expand All @@ -32,6 +32,12 @@ internal class LinkActivityContract @Inject internal constructor(
}
}

private fun useNativeLink(input: Args): Boolean {
// if (FeatureFlags.nativeLinkEnabled.isEnabled) return true
// return input.configuration.useAttestationEndpointsForLink
return true
}

data class Args internal constructor(
internal val configuration: LinkConfiguration
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ internal class LinkActivityViewModel @Inject constructor(
}

private suspend fun warmUpIntegrityManager(): Boolean {
val configuration = activityRetainedComponent.configuration
if (configuration.stripeIntent.isLiveMode.not()) return true
if (configuration.useAttestationEndpointsForLink.not()) return true
// val configuration = activityRetainedComponent.configuration
// if (configuration.useAttestationEndpointsForLink.not()) return true

val result = integrityRequestManager.prepare()
val error = result.exceptionOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import androidx.core.os.BundleCompat
import com.stripe.android.PaymentConfiguration
import javax.inject.Inject

internal class NativeLinkActivityContract @Inject constructor() :
ActivityResultContract<LinkActivityContract.Args, LinkActivityResult>() {
internal class NativeLinkActivityContract @Inject constructor(
private val webLinkActivityContract: WebLinkActivityContract
) : ActivityResultContract<LinkActivityContract.Args, LinkActivityResult>() {
override fun createIntent(context: Context, input: LinkActivityContract.Args): Intent {
val paymentConfiguration = PaymentConfiguration.getInstance(context)
return LinkActivity.createIntent(
Expand All @@ -29,15 +30,24 @@ internal class NativeLinkActivityContract @Inject constructor() :
}

LinkActivity.RESULT_COMPLETE -> {
val result = intent?.extras?.let {
BundleCompat.getParcelable(it, LinkActivityContract.EXTRA_RESULT, LinkActivityResult::class.java)
}
result ?: LinkActivityResult.Canceled()
handleCompleteResult(resultCode, intent)
}

else -> {
LinkActivityResult.Canceled()
}
}
}

private fun handleCompleteResult(resultCode: Int, intent: Intent?): LinkActivityResult {
intent ?: return LinkActivityResult.Canceled()
val redirectUri = intent.data
if (redirectUri != null) {
return webLinkActivityContract.parseResult(resultCode, intent)
}
val result = intent.extras?.let {
BundleCompat.getParcelable(it, LinkActivityContract.EXTRA_RESULT, LinkActivityResult::class.java)
}
return result ?: LinkActivityResult.Canceled()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal object TestFactory {
flags = emptyMap(),
cardBrandChoice = null,
passthroughModeEnabled = false,
useAttestationEndpointsForLink = true
useAttestationEndpointsForLink = false
)

val LINK_WALLET_PRIMARY_BUTTON_LABEL = Amount(
Expand Down

0 comments on commit 934c98e

Please sign in to comment.