Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

**Fixes**

- [#2128](https://github.com/stripe/stripe-react-native/pull/2128) Fix headless task not registered by StripeProvider.
- [#2129](https://github.com/stripe/stripe-react-native/pull/2129) Fix iOS build on new arch 0.81 with static linkage

## 0.53.0 - 2025-09-15
Expand Down
11 changes: 6 additions & 5 deletions src/components/StripeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ const appInfo: AppInfo = {
partnerId: shouldAttributeExpo() ? EXPO_PARTNER_ID : undefined,
};

let didRegisterHeadlessTask = false;

export const initStripe = async (params: InitStripeParams): Promise<void> => {
// On Android when the activity is paused, JS timers are paused,
// which causes network requests to hang indefinitely on new arch.
// To work around this, we register a headless task that will keep
// the JS runtime running while the Stripe UI is opened.
// This task is started and stopped by the native module.
if (Platform.OS === 'android') {
if (Platform.OS === 'android' && !didRegisterHeadlessTask) {
function stripeHeadlessTask() {
return new Promise<void>(() => {});
}
Expand All @@ -42,6 +44,7 @@ export const initStripe = async (params: InitStripeParams): Promise<void> => {
'StripeKeepJsAwakeTask',
() => stripeHeadlessTask
);
didRegisterHeadlessTask = true;
}

const extendedParams: InitialiseParams = { ...params, appInfo };
Expand Down Expand Up @@ -83,18 +86,16 @@ export function StripeProvider({
}
const initializeStripe = async () => {
if (isAndroid) {
await NativeStripeSdk.initialise({
await initStripe({
publishableKey,
appInfo,
stripeAccountId,
threeDSecureParams,
urlScheme,
setReturnUrlSchemeOnAndroid,
});
} else {
await NativeStripeSdk.initialise({
await initStripe({
publishableKey,
appInfo,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

App info is added by initStripe already.

stripeAccountId,
threeDSecureParams,
merchantIdentifier,
Expand Down
Loading