Skip to content

Commit

Permalink
remove combined contract
Browse files Browse the repository at this point in the history
  • Loading branch information
toluo-stripe committed Jan 17, 2025
1 parent 934c98e commit a87ae60
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.stripe.android.PaymentConfiguration
import javax.inject.Inject

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)
Expand All @@ -30,24 +29,15 @@ internal class NativeLinkActivityContract @Inject constructor(
}

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

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()
}
}

0 comments on commit a87ae60

Please sign in to comment.