diff --git a/paymentsheet/src/main/java/com/stripe/android/link/LinkActivity.kt b/paymentsheet/src/main/java/com/stripe/android/link/LinkActivity.kt index f2c39dcb49a..830d4e30c1d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/link/LinkActivity.kt +++ b/paymentsheet/src/main/java/com/stripe/android/link/LinkActivity.kt @@ -104,7 +104,7 @@ internal class LinkActivity : ComponentActivity() { ) this@LinkActivity.setResult( RESULT_COMPLETE, - Intent().putExtras(bundle) + intent.putExtras(bundle) ) this@LinkActivity.finish() } diff --git a/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityContract.kt b/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityContract.kt index 66fbffacc53..e0e534c57f9 100644 --- a/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityContract.kt +++ b/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityContract.kt @@ -12,7 +12,7 @@ internal class LinkActivityContract @Inject internal constructor( ) : ActivityResultContract() { 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) } @@ -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 ) diff --git a/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityViewModel.kt b/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityViewModel.kt index 1bc725bac04..e9e8a1bfa2d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityViewModel.kt +++ b/paymentsheet/src/main/java/com/stripe/android/link/LinkActivityViewModel.kt @@ -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() diff --git a/paymentsheet/src/main/java/com/stripe/android/link/NativeLinkActivityContract.kt b/paymentsheet/src/main/java/com/stripe/android/link/NativeLinkActivityContract.kt index 63b24db28b5..fa8f526c0d3 100644 --- a/paymentsheet/src/main/java/com/stripe/android/link/NativeLinkActivityContract.kt +++ b/paymentsheet/src/main/java/com/stripe/android/link/NativeLinkActivityContract.kt @@ -8,8 +8,9 @@ import androidx.core.os.BundleCompat import com.stripe.android.PaymentConfiguration import javax.inject.Inject -internal class NativeLinkActivityContract @Inject constructor() : - ActivityResultContract() { +internal class NativeLinkActivityContract @Inject constructor( + private val webLinkActivityContract: WebLinkActivityContract +) : ActivityResultContract() { override fun createIntent(context: Context, input: LinkActivityContract.Args): Intent { val paymentConfiguration = PaymentConfiguration.getInstance(context) return LinkActivity.createIntent( @@ -29,10 +30,7 @@ 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 -> { @@ -40,4 +38,16 @@ internal class NativeLinkActivityContract @Inject constructor() : } } } + + 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() + } } diff --git a/paymentsheet/src/test/java/com/stripe/android/link/TestFactory.kt b/paymentsheet/src/test/java/com/stripe/android/link/TestFactory.kt index d5cbf851170..38b8a10c14b 100644 --- a/paymentsheet/src/test/java/com/stripe/android/link/TestFactory.kt +++ b/paymentsheet/src/test/java/com/stripe/android/link/TestFactory.kt @@ -133,7 +133,7 @@ internal object TestFactory { flags = emptyMap(), cardBrandChoice = null, passthroughModeEnabled = false, - useAttestationEndpointsForLink = true + useAttestationEndpointsForLink = false ) val LINK_WALLET_PRIMARY_BUTTON_LABEL = Amount(