Skip to content

Conversation

@janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Oct 18, 2025

Summary

This implements a new internal builder for payment sheet to be used by the react-native sdk. This will allow removing many hacks and complexity from the react-native sdk related to activity lifecycle.

To do that we need to create activityResultLauncher without relying on the activity registerForActivityResult, since it requires it to be in CREATED state. To do that we can use activity.activityResultRegistry.register, which is the same API compose uses internally. This requires use to manage the lifecycle of the result launcher manually.

Option A

This is what is currently implemented in this PR as a proof of concept. Here we create the activityResultLauncher in DefaultPaymentSheetLauncher and we use a new parameter signal to allow the react-native sdk to notify that the activityResultLauncher must be unregistered.

Option B

Here we would pass activityResultLauncher alongside the activity in the builder build method. This is an alternative option that moves a little bit more of the complexity to the react-native sdk, however it will require exposing the contract classes, since they are currently internal, and required to create the activityResultLauncher.

In both cases the apis are gated by a new opt in annotation ReactNativeSdkInternal.

Motivation

Simplify the integration in the react-native sdk.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Tested in the react-native sdk example.

Screenshots

N/A

Changelog

[Added] Internal APIs for react-native sdk integration.

@janicduplessis janicduplessis marked this pull request as ready for review October 23, 2025 05:08
@janicduplessis janicduplessis requested review from a team as code owners October 23, 2025 05:08
CHANGELOG.md Outdated

## XX.XX.XX - 20XX-XX-XX
* [Added] Added support for `onBehalfOf` to CustomerSheet.IntentConfiguration. This parameter makes CustomerSheet use a connected account to determine the payment method that users see and whether CardBrandChoice is enabled. For more information, see the [SetupIntent docs](https://docs.stripe.com/api/setup_intents/object#setup_intent_object-on_behalf_of).
* [Added] Internal APIs for react-native sdk integration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is all internal, we shouldn't list it in the changelog.

implementation libs.kotlin.coroutines
implementation libs.kotlin.coroutinesAndroid
implementation libs.kotlin.serialization
implementation libs.androidx.activity
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run ruby scripts/update_transitive_dependencies.rb to make align our dependencies baseline with this change.

message = "This API should only be used internally by the react-native sdk."
)
@Retention(AnnotationRetention.BINARY)
annotation class ReactNativeSdkInternal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mark all the new public APIs with @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)

You can check this locally via ./gradlew apiCheck.

@jaynewstrom-stripe
Copy link
Collaborator

@janicduplessis looks like the only remaining failures are lint errors. Could you run ./gradlew ktlint detekt lintRelease apiCheck verifyReleaseResources locally to fix up the last of the issues?

Otherwise LGTM.

@janicduplessis
Copy link
Contributor Author

@jaynewstrom-stripe Should be all good now! There are some workflow that still need approval to run, could you look into it?

@jaynewstrom-stripe
Copy link
Collaborator

Looks like everything is good to me, I'll click merge!

@jaynewstrom-stripe jaynewstrom-stripe merged commit bfbf0ed into stripe:master Oct 24, 2025
23 checks passed
@janicduplessis janicduplessis deleted the @janic/rn-integration branch October 24, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants