#tahmass-dev_api
1 messages · Page 1 of 1 (latest)
👋 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. Thank you for your patience!
⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
🔗 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/1214922640326795274
📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.
You can't – Express accounts can only be connected to a single platform. You'd create and onboard a new account: https://docs.stripe.com/connect/express-accounts
Thanks for response😇 . So for a user who already have a working stripe account and instead of creating a connected account they want to just connect it with our stripe. What is the proper method to do that?
Well if it's an Express account, they can't. In any case the correct method is to create an account via the API and onboard via an Account Link
But we can do that in custom account?
No, only standard accounts can be connected to multiple platforms
Right
So customer who want to connect their stripe with ours should have standard account?
The recommended practice is to create a new Account via the API, and onboard that to your platform. Your user can use their existing Stripe credentials to authenticate with the new account, but it is considered a separate entity in Stripe
Otherwise you'd generate an OAuth link and the user can connect their exisitng account
Right Thanks! I did that like this. But this seems to be not working. If this way is wrong or any other solution please suggest Thanks
I redirected user to this https://connect.stripe.com/oauth/authorize?response_type=code&client_id=CLIENT_ID&scope=read_write&redirect_uri=${redirectUri}` when user land on redirect URI I called this function written below
exports.stripeOAuthCallback = functions.https.onRequest((req, res) => {
cors(req, res, async () => {
try {
functions.logger.log("req", req);
const code = req.body.code;
console.log("code", code);
const resp = await axios.post("https://connect.stripe.com/oauth/token", {
grant_type: "authorization_code",
client_id: "CLIENT_ID",
code: code,
client_secret:
"SECRETE",
redirect_uri: "http://localhost:3001/", // Same as above
});
functions.logger.log("response.data", resp.data);
const connectedAccountId = resp.data.stripe_user_id;
const accessToken = resp.data.access_token;
// Log or use the connected account ID as needed
functions.logger.log("Connected Account ID:", connectedAccountId);
functions.logger.log("Access Token:", accessToken);
const connectedAccountResp = await axios.post(
"https://api.stripe.com/v1/accounts",
{
type: "express", // or "express" based on your requirements
},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
res.status(200).json({
message: "Stripe account connected successfully!",
connectedAccountId: connectedAccountId,
createdAccount: connectedAccountResp.data,
});
} catch (e) {
res.status(500).json({ error: e.message });
}
});
});
OK, what's not working specifically?