diff --git a/src/fiatExchanges/BidaliScreen.test.tsx b/src/fiatExchanges/BidaliScreen.test.tsx index 73f16666a10..256c3984478 100644 --- a/src/fiatExchanges/BidaliScreen.test.tsx +++ b/src/fiatExchanges/BidaliScreen.test.tsx @@ -14,14 +14,14 @@ const mockScreenProps = getMockStackScreenProps(Screens.BidaliScreen, { declare global { interface Window { - walletApp: any + valora: any } } describe(BidaliScreen, () => { beforeEach(() => { // Reset injected JS effect - window.walletApp = undefined + window.valora = undefined }) it('renders correctly when no phone number is provided', () => { @@ -51,7 +51,7 @@ describe(BidaliScreen, () => { expect(webView).toBeDefined() // eslint-disable-next-line no-eval expect(eval(webView.props.injectedJavaScriptBeforeContentLoaded)).toBe(true) - expect(window.walletApp).toMatchInlineSnapshot(` + expect(window.valora).toMatchInlineSnapshot(` { "balances": { "CEUR": "5", @@ -91,7 +91,7 @@ describe(BidaliScreen, () => { expect(webView).toBeDefined() // eslint-disable-next-line no-eval expect(eval(webView.props.injectedJavaScriptBeforeContentLoaded)).toBe(true) - expect(window.walletApp).toMatchInlineSnapshot(` + expect(window.valora).toMatchInlineSnapshot(` { "balances": { "CEUR": "5", @@ -136,7 +136,7 @@ describe(BidaliScreen, () => { // eslint-disable-next-line no-eval expect(eval(webView.props.injectedJavaScriptBeforeContentLoaded)).toBe(true) // `paymentCurrency` is CEUR here because it has the highest balance in the local currency - expect(window.walletApp).toMatchInlineSnapshot(` + expect(window.valora).toMatchInlineSnapshot(` { "balances": { "CEUR": "9", diff --git a/src/fiatExchanges/BidaliScreen.tsx b/src/fiatExchanges/BidaliScreen.tsx index b7b68cace6f..d6bedb1da8c 100644 --- a/src/fiatExchanges/BidaliScreen.tsx +++ b/src/fiatExchanges/BidaliScreen.tsx @@ -40,8 +40,9 @@ function useInitialJavaScript( // When a payment request is needed, Bidali calls the provided `onPaymentRequest` method. // When a new url needs to be open (currently for FAQ, Terms of Service), `openUrl` is called by Bidali. // See also the comment in the `onMessage` handler + // IMPORTANT: DO NOT RENAME window.valora to anything else, it is used by Bidali for the custom integration. setInitialJavaScript(` - window.walletApp = { + window.valora = { paymentCurrency: "${currency.toUpperCase()}", phoneNumber: ${JSON.stringify(e164PhoneNumber)}, balances: ${jsonBalances}, @@ -84,10 +85,10 @@ function BidaliScreen({ route, navigation }: Props) { // These 2 callbacks needs to be called to notify Bidali of the status of the payment request // so it can update the WebView accordingly. const onPaymentSent = () => { - webViewRef.current?.injectJavaScript(`window.walletApp.paymentSent();`) + webViewRef.current?.injectJavaScript(`window.valora.paymentSent();`) } const onCancelled = () => { - webViewRef.current?.injectJavaScript(`window.walletApp.paymentCancelled();`) + webViewRef.current?.injectJavaScript(`window.valora.paymentCancelled();`) } dispatch( bidaliPaymentRequested( @@ -135,7 +136,7 @@ function BidaliScreen({ route, navigation }: Props) { // Update balances when they change useEffect(() => { webViewRef.current?.injectJavaScript(` - window.walletApp.balances = ${jsonBalances} + window.valora.balances = ${jsonBalances}; `) }, [jsonBalances])