import React , { useEffect } from 'react' ; import NativeStripeSdk from '../NativeStripeSdk' ; import { isAndroid , shouldAttributeExpo } from '../helpers' ; import type { AppInfo , ThreeDSecureConfigurationParams , InitStripeParams , InitialiseParams , } from '../types' ; import pjson from '../../package.json' ; const EXPO_PARTNER_ID = 'pp_partner_JBN7LkABco2yUu' ; /**
 *  Stripe Provider Component Props
 */ export interface Props { publishableKey : string ; merchantIdentifier ? : string ; threeDSecureParams ? : ThreeDSecureConfigurationParams ; stripeAccountId ? : string ; children : React . ReactElement | React . ReactElement [ ] ; urlScheme ? : string ; setUrlSchemeOnAndroid ? : boolean ; } const repository = pjson . repository ; const appInfo = { name : shouldAttributeExpo ( ) ? `${ pjson . name }/expo` : pjson . name , url : repository . url || repository , version : pjson . version , partnerId : shouldAttributeExpo ( ) ? EXPO_PARTNER_ID : undefined , } ; export const initStripe = async ( params ) : Promise < void > => { const extendedParams = { ... params , appInfo } ; NativeStripeSdk . initialise ( extendedParams ) ; } ; example param __namedParameters returns category export function StripeProvider ( { children , publishableKey , merchantIdentifier , threeDSecureParams , stripeAccountId , urlScheme , setUrlSchemeOnAndroid , } ) { useEffect ( ( ) => { if ( ! publishableKey ) { return ; } if ( isAndroid ) { NativeStripeSdk . initialise ( { publishableKey , appInfo , stripeAccountId , threeDSecureParams , urlScheme , setUrlSchemeOnAndroid , } ) ; } else { NativeStripeSdk . initialise ( { publishableKey , appInfo , stripeAccountId , threeDSecureParams , merchantIdentifier , urlScheme , } ) ; } } , [ publishableKey , merchantIdentifier , stripeAccountId , threeDSecureParams , urlScheme , setUrlSchemeOnAndroid , ] ) ; return < > { children } < />; }