#josh-invalid-token

1 messages · Page 1 of 1 (latest)

peak steeple
pseudo wasp
#

I am assuming its because I am creating the token on the platform (there is no option to create it on the connected account with the react library) and then the setup intent is on the connected account, but im not sure how to work around these built-in limitatiions

fleet birch
#

looking into this now...

pseudo wasp
#

req_PoGzGcz1Yw6qMn

#

not sure if you can look up request ID's

fleet birch
#

yes, thank you

pseudo wasp
#

thanks! maybe i am doing something wrong, but its weird since when i do it on a custom connected account it works and on a standard one it breaks

#

so my only thought is token on platform and setupintent on connected account

fleet birch
#

Ok, there seem to be a couple things going on here.

#

1/ you're correct, the token is on one account and it's being used on another account

pseudo wasp
fleet birch
#

Correction: What does your model look like? Are you using direct charges? If so, you could tokenize on the connected account directly.

pseudo wasp
#

using a stripe card input

#

@stripe/react-stripe-js doesnt have any parameters in their documentation i can find to add stripeAccount: id to the params

pseudo wasp
peak steeple
#

Hey Josh! A few quick clarifying questions so we can get you set up correctly!

  1. What type of Connected Accounts are you using?
  2. Are you intending for these cards to just live on the individual Connected Accounts and use them for direct charges or are you planning on using them across Connected Accounts (you want to clone them first from your platform)?
pseudo wasp
#

We have a very complicated setup where we have 100 standard connected accounts using direct charges and need to migrate them one at a time to custom as they pass your teams legal review. So essentially, we need to support a dual migration where standard accounts and custom accounts both work depending on the merchant

peak steeple
#

You are planning on using Direct charges with Custom going forward?

pseudo wasp
#

btw, see request req_MifoqamQh0bkGZ for an example of me using payment_method_datasuccessfully on a custom account

#

no, we are using destination charges with custom

#

and direct charges with standard

peak steeple
#

Got it.

pseudo wasp
#

so now i have adding a card on custom (customer and payment method on platform) working, but it broke my existing standard integration

#

so to make the question simple, how do i create a token for a customer on a standard connected account

#

i call stripe.createToken() from @stripe/react-stripe-js but i have no option to pass in a connected account id

peak steeple
#

Thanks for clarifying. So if you want to create these tokens directly on your Connected Accounts then you should be able to pass the Stripe Account Header when you use loadStripe()

pseudo wasp
#

another question then, can I call loadStripe multiple times to refresh that header?

#

we have users who run multiple merchant accounts for tax purposes

peak steeple
#

Hmmm I think that will re-mount your card element each time. Let me ask a colleague who is more familiar with React the best way to do this.

pseudo wasp
#

And yet another question, how in the heck have I been making thousands of charges on merchants standard connected accounts including tokenizing the cards on my own platform and then using it on the merchants account as a saved payment method without ever having passed in that header before

peak steeple
#

Can you give me an example charge or request where that is happening? I'd assume you are cloning cards from your platform but I can look and confirm.

pseudo wasp
#

yeah let me find one

#

ch_3K78aY2E7UlueuJr10zHWdWJ

#

we have a flow where users enter their card info on our site to enroll in school (schools are merchants) and then we save the card info to the customer on the school merchant account and charge it

#

but that token is 10000% made on our own platform and we dont even make the customer object on our own platform nor do we save the payment method on our own platform

#

thats why im so confused since ive never passed that header in before

#

thanks for looking into it!

peak steeple
#

No problem! Okay so yes I was correct above that you can call loadStripe multiple times to refresh the Connected Account header but it will remount your components wen you do so so you will need to account for this.

#

Okay so for the above example you are passing the Stripe Account header when you attach the token to the customer, however you are doing this server-side. Take a look at req_TZ2cHuZpD5mPdL to see this. That said, I didn't realize that tokens actually work in a special manner with Connect where if you don't attach the token to a customer on your platform then you don't have to clone it from your platform, you just attach it directly on your Connected Account — which is why you haven't used the StripeAccount header client-side before.

pseudo wasp
#

well then i am confused why i need to do this now then

#

does it only work like that for sources API but not for payment methods API?

#

Sorry for being so cumbersome, there is not any documentation on this at all

peak steeple
#

Yeah not sure why you are using a SetupIntent now and not just keeping your past integration for your Standard Accounts? You definitely don't want to use Direct Charges with Custom.

#

Sorry, I need to step away but @sharp atlas is going to jump in to help!

pseudo wasp
#

We arent using direct charges with custom

#

I need to support both

sharp atlas
#

(give me some time to confirm my findings)

#

Okay so yeah unfortunately the flow you are trying to do is not possible with SetupIntent and PaymentIntents. It only worked with the legacy APIs

#

You can't create a card Token tok_ABC on the platform and then use it on a connected account as part of a SetupIntent or PaymentIntent confirmation

pseudo wasp
#

sure. so i can just do the following in react:

#
const A = () => {
  const school = useSelector(selectSchool) as any;
  const [
    stripePromise,
    setStripePromise,
  ] = useState<null | Promise<Stripe | null>>(null);

  useEffect(() => {
    const promise = loadStripe(
      process.env.REACT_APP_STRIPE_PUBLISHABLE_KEY as string,
      {
        betas: ['us_bank_account_beta_2'],
        stripeAccount: school.stripeCustom ? undefined : school.stripeAccountId,
      },
    );
    setStripePromise(promise);
  }, [school?.stripeCustom]);

  return (
      <Elements stripe={stripePromise}>
        <AppContainer />
      </Elements>
  );
};
#

Where that wraps my app

#

And then that will support both custom and standard integrations where school.stripeCustom indicates a custom connected account versus a standard one

sharp atlas
#

yeah that should work

pseudo wasp
#

Works!

#

Thank you so much

#

Well it doesnt unmount so i have to refresh

#

but i can figure it out from there

#

thank you!

#

If you have any suggestions on how to get stripe to unmount let me know!

sharp atlas
pseudo wasp
#

thats exactly what i meant thank you

#

have a good day