Stripe Connect 和 Firebase 函数
Stripe Connect and Firebase Functions
我正在尝试使用 firebase 函数设置条带连接。到目前为止,当使用以下代码将新项目添加到 firestore 数据库时,我创建了一个关联帐户。
exports.createConnectedAccount = functions.firestore
.document("dbitem/{dbitemId}")
.onCreate(async (snap, context) => {
const account = await stripeClient.accounts.create({ type: "express" });
return admin
.firestore()
.collection("connected_accounts")
.doc(snap.id)
.set({ account_id: account.id });
});
现在我从文档中不理解的部分如下:
const accountLink = await stripe.accountLinks.create({
account: 'acct_1032D82eZvKYlo2C',
refresh_url: 'https://example.com/reauth',
return_url: 'https://example.com/return',
type: 'account_onboarding',
});
如何创建帐户链接,以及如何通过 firebase 函数发出 https 请求以进行刷新和 return url。
我明白了。我看错了。
我的第一部分是正确的,我在将项目添加到数据库时创建了一个帐户。
exports.createConnectedAccount = functions.firestore
.document("dbitem/{dbitemId}")
.onCreate(async (snap, context) => {
const account = await stripeClient.accounts.create({ type: "express" });
return admin
.firestore()
.collection("connected_accounts")
.doc(snap.id)
.set({ account_id: account.id });
});
接下来我在 firebase 中创建了一个从前端触发的端点,它所做的是调用 accountLinks.create 返回一个 url 然后我传回前端
exports.refresh_url = functions.https.onRequest(async (req, res) => {
const body = JSON.parse(req.body);
const { account_id } = body;
await stripeClient.accountLinks
.create({
type: "account_onboarding",
account: account_id,
refresh_url:
"change this tothe address to the firebase endpoint",
return_url: "change this to the address for the firebase endpoint",
})
.then((accountLinks) => {
res.json(accountLinks.url);
})
.catch((err) => {
console.log("Could not get or createaccount links", err);
res.status(400);
res.send("could not get or create account links", err);
});
});
我正在尝试使用 firebase 函数设置条带连接。到目前为止,当使用以下代码将新项目添加到 firestore 数据库时,我创建了一个关联帐户。
exports.createConnectedAccount = functions.firestore
.document("dbitem/{dbitemId}")
.onCreate(async (snap, context) => {
const account = await stripeClient.accounts.create({ type: "express" });
return admin
.firestore()
.collection("connected_accounts")
.doc(snap.id)
.set({ account_id: account.id });
});
现在我从文档中不理解的部分如下:
const accountLink = await stripe.accountLinks.create({
account: 'acct_1032D82eZvKYlo2C',
refresh_url: 'https://example.com/reauth',
return_url: 'https://example.com/return',
type: 'account_onboarding',
});
如何创建帐户链接,以及如何通过 firebase 函数发出 https 请求以进行刷新和 return url。
我明白了。我看错了。
我的第一部分是正确的,我在将项目添加到数据库时创建了一个帐户。
exports.createConnectedAccount = functions.firestore
.document("dbitem/{dbitemId}")
.onCreate(async (snap, context) => {
const account = await stripeClient.accounts.create({ type: "express" });
return admin
.firestore()
.collection("connected_accounts")
.doc(snap.id)
.set({ account_id: account.id });
});
接下来我在 firebase 中创建了一个从前端触发的端点,它所做的是调用 accountLinks.create 返回一个 url 然后我传回前端
exports.refresh_url = functions.https.onRequest(async (req, res) => {
const body = JSON.parse(req.body);
const { account_id } = body;
await stripeClient.accountLinks
.create({
type: "account_onboarding",
account: account_id,
refresh_url:
"change this tothe address to the firebase endpoint",
return_url: "change this to the address for the firebase endpoint",
})
.then((accountLinks) => {
res.json(accountLinks.url);
})
.catch((err) => {
console.log("Could not get or createaccount links", err);
res.status(400);
res.send("could not get or create account links", err);
});
});