#hunk_code

1 messages · Page 1 of 1 (latest)

left wedgeBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1225911904363614288

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

chrome elbowBOT
high cave
#

heyo

carmine wasp
#

Hi 👋

When you say a verification session, what specifically are you refering to?

#

Do you mean Stripe Connect onboarding?

high cave
#

onee sec let me reference my code base again to get the precise answer

carmine wasp
#

Since you are attemtping to do this is a webview, I assume it's not the API-based verifciation.

high cave
#

yeah we use the postman stripe urls templates and then we created our our iirc

carmine wasp
#

I'm not familiar with Postman Stripe URLs. Can you share the API endpoints you are hitting?

high cave
#
checkStripeID = async () => {
    try {
      const stripeUtil = new StripeUtil()
      const response = await fetch(
        `https://api.stripe.com//v1/accounts/${this.state.stripeId}`,
        {
          method: 'GET',
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            Authorization:
            stripeUtil.getStripeAPIKey()
          }
        }
      );

      const jsonResponse = await response.json();
      console.log(jsonResponse)
      return jsonResponse.payouts_enabled;
    } catch (error) {
      console.error('Error checking Stripe account:', error);
      throw error;
    }
  };
#

here's how we check for a verified account

carmine wasp
#

Okay yeay you're attempting to retrieve an account object from the API using ID

high cave
#

then I use a webview like so to get the verfication link to show if the users stripe id wee create for them hasn't been verified yet

case 'stripeLink':
            const { stripeLink } = this.state;
            const { showModal } = this.state;
            console.log(
              'Stripe Link In WebView',
                stripeLink,this.state.showModal
            );
            return (
              <View style={{ flex: 1 ,backgroundColor:'#FFF',}}>
                {/* Check if stripeLink is available before rendering WebView */}
                {showModal && (
                  <WebView
                    source={{ uri: stripeLink }}
                    style={{ flex: 1 }}
                    setSupportMultipleWindows={false}
                    onShouldStartLoadWithRequest={() => true}
                    originWhitelist={['*']}
                    onNavigationStateChange={this.onNavigationStateChange}
                    webviewDebuggingEnabled={true}
                  />

                )}
                <TouchableOpacity onPress={this.closeModal} style={{ top:hp2dp("1%"),left:wp2dp("100%")-hp2dp("7%"), backgroundColor:Colors.juegos_purple, position:'absolute', width:hp2dp("6%"), height:hp2dp("6%"), borderRadius:5, justifyContent:'center',alignItems:'center'}}><FontAwesomeIcon style={{color:Colors.juegos_white}} size={hp2dp("4%")} icon={faX}/></TouchableOpacity>
              </View>
            );

high cave
carmine wasp
#

Where is the stripeLink created?

#

Would it be possible to see an example stripeLink value?

high cave
#

yeah i'll get you both in just a sec

#

here's where we set it


 createStripeAccountLink = async () => {
    try {
      const stripeUtil = new StripeUtil()
      const data = `refresh_url=https%3A%2F%2Fexample.com%2Freauth&return_url=https%3A%2F%2Fexample.com%2Freturn&account=${this.state.stripeId}&type=account_onboarding`;

      const response = await fetch('https://api.stripe.com//v1/account_links', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          Authorization:
          stripeUtil.getStripeAPIKey()
        },
        body: data
      });

      const jsonResponse = await response.json();
      const returnURL = jsonResponse.url;
      this.setState({ stripeLink: returnURL });
      return returnURL;
    } catch (error) {
      console.error('Error creating Stripe account link:', error);
      throw error;
    }
  };

and heres where we call it with a log

 console.log(
              'Stripe Link In WebView',
                stripeLink,this.state.showModal
            );
LOG  Stripe Link In WebView https://connect.stripe.com/setup/s/acct_1P2Iz4IKvKjZygXD/MI5O4SdILA8Z true
carmine wasp
#

Okay cool! Thanks.

#

And you are attempting to load the hosted onboarding in a Webview? Is there a reason you are not redirecting to an actual browser?

high cave
#

our company wanted to keep everything in app as much as possible for user experience so I suggested a webview to try to keep the tab running in app. however hitting specifically the bank connection requires multiple tabs so i thought that saving the session would let my return back to stripe once the bank has finished using the one tab we have access to (which kind of worked)

carmine wasp
#

I'm not sure what you mean in your question about "fixing the session". Sessions are single use only and cannot be re-used.

#

I wonder if you are running into an issue there

#

Hosted onboarding isn’t supported when embedded through webviews. It’s only supported in standalone browsers.

high cave
#

yeah, our original problem was that no matter what we did we couldn't get the session to be preserved thus resulting in "authentication session is in an invalid state".

i tried this solution which let us somewhat preserve the session with the caveat that the user has to close out of the stuck white screen and reopen the modal to get "connect availible accounts" and thus finish making a verified account


onNavigationStateChange = (navState) => {
    // Check if the new URL includes 'example.com'
    if (navState.url.includes('example.com')) {
      // Close the modal and WebView
      this.closeModal();
    }

    if (navState.url.includes('stripe.com')) {
      // Update the state with the current Stripe session URL
      this.setState({ stripeLink: navState.url });
      // Persist the session state locally
      AsyncStorage.setItem('stripe_session_link', navState.url)
        .then(() => console.log('Session state persisted:', navState.url))
        .catch(error => console.error('Error persisting session state:', error));
    }
  };

carmine wasp
#

I think redirecting to a standalone browser 1) is required because we are explicit about not supporting webviews and 2) will help alleviate this inconsistent state issue

high cave
carmine wasp
#

At which point? Adding the external bankt account?

carmine wasp
#

Sorry that doesn't help me at all. I cannot see it and the tab closes instantly for me

high cave
#

yeah its just a white screen for me too, thats the big problem

#

if stripe hosted like this isn't support in webviews then it doesn't realistically make sense for use to try to persue the edge case despite it "seeming" like we might be one revelation away from getting one smooth webview onboard.

in any case what alternative do you suggest for react to pop this link directly into my default browser and to handle everything there. (i assume i just deep link back to my app for better flow)

alternatively is there an react native solution for create stripe accounts with banking information to connect with our proprietary in app accounts

carmine wasp
#

The deep link is the correct choice for the redirect back

high cave
carmine wasp
#

Identity verification is not the same as Connect Onboarding. So I don't think this would address your needs, I'm sorry to say

high cave
#

thats no problem, honestly being able to narrow down the solutions is a big help

carmine wasp
#

I'm still digging for mobile options

high cave
#

and yeah I skimmed some of the documentation and trying to create our own server endpoint seems out of scope and the verifying documents isn't what i'm looking for at this stage of the project. I'll let my team know everything you've told me come monday. thanks for everything you've done so far. if you come across anything else mobile related that would be a big heelp but i feel like we have something to work off here. i'll be around looking at chat but i have to head out and take care of my animals. once again thank you

carmine wasp
#

Okay, I'll post anything I find to this thread. We close threads after a period of inactivity but you will always be able to access this thread in case I put anything else useful here. And you can always come back and ask follow up quesitons

high cave
#

👍