@@ -27,13 +27,15 @@ const appInfo: AppInfo = {
2727  partnerId : shouldAttributeExpo ( )  ? EXPO_PARTNER_ID  : undefined , 
2828} ; 
2929
30+ let  didRegisterHeadlessTask  =  false ; 
31+ 
3032export  const  initStripe  =  async  ( params : InitStripeParams ) : Promise < void >  =>  { 
3133  // On Android when the activity is paused, JS timers are paused, 
3234  // which causes network requests to hang indefinitely on new arch. 
3335  // To work around this, we register a headless task that will keep 
3436  // the JS runtime running while the Stripe UI is opened. 
3537  // This task is started and stopped by the native module. 
36-   if  ( Platform . OS  ===  'android' )  { 
38+   if  ( Platform . OS  ===  'android'   &&   ! didRegisterHeadlessTask )  { 
3739    function  stripeHeadlessTask ( )  { 
3840      return  new  Promise < void > ( ( )  =>  { } ) ; 
3941    } 
@@ -42,6 +44,7 @@ export const initStripe = async (params: InitStripeParams): Promise<void> => {
4244      'StripeKeepJsAwakeTask' , 
4345      ( )  =>  stripeHeadlessTask 
4446    ) ; 
47+     didRegisterHeadlessTask  =  true ; 
4548  } 
4649
4750  const  extendedParams : InitialiseParams  =  {  ...params ,  appInfo } ; 
@@ -83,18 +86,16 @@ export function StripeProvider({
8386    } 
8487    const  initializeStripe  =  async  ( )  =>  { 
8588      if  ( isAndroid )  { 
86-         await  NativeStripeSdk . initialise ( { 
89+         await  initStripe ( { 
8790          publishableKey, 
88-           appInfo, 
8991          stripeAccountId, 
9092          threeDSecureParams, 
9193          urlScheme, 
9294          setReturnUrlSchemeOnAndroid, 
9395        } ) ; 
9496      }  else  { 
95-         await  NativeStripeSdk . initialise ( { 
97+         await  initStripe ( { 
9698          publishableKey, 
97-           appInfo, 
9899          stripeAccountId, 
99100          threeDSecureParams, 
100101          merchantIdentifier, 
0 commit comments