#josh-invalid-token
1 messages · Page 1 of 1 (latest)
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
looking into this now...
yes, thank you
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
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
2/ there is not payment_method_data parameter on the setup intent: https://stripe.com/docs/api/setup_intents/create#create_setup_intent-payment_method
how do i create a token on a connected account in a PCI compliant manner on the frontend? Stripe must support this in some way surely
You can instead use the payment_method: https://stripe.com/docs/api/setup_intents/create#create_setup_intent-payment_method
Can you confirm what you're exactly trying to do here? Why are you not able to create it on the connected account cirectly? Or clone, https://stripe.com/docs/connect/cloning-customers-across-accounts across accounts?
Correction: What does your model look like? Are you using direct charges? If so, you could tokenize on the connected account directly.
how do i do this is my question
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
also to this point here, i pass in payment_method_data exactly as i do on standard for platform tokenization, and it works as intended, so i dont think this part has to do with it
Hey Josh! A few quick clarifying questions so we can get you set up correctly!
- What type of Connected Accounts are you using?
- 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)?
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
You are planning on using Direct charges with Custom going forward?
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
Got it.
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
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()
another question then, can I call loadStripe multiple times to refresh that header?
we have users who run multiple merchant accounts for tax purposes
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.
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
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.
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!
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.
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
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!
(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
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
yeah that should work
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!
I'm not sure what "it doesn't unmount" means but we have https://stripe.com/docs/js/element/other_methods/unmount which you could explicitly call before reloading Stripe