【发布时间】:2021-08-07 02:52:52
【问题描述】:
我有以下函数,试图获取 Stripe API 创建的 url Link 它应该返回以下对象
{
"object": "login_link",
"created": 1620954357,
"url": "https://connect.stripe.com/express/VGAOul448UhS",
"id": "lael_JTn3grKOB073gL"
}
Nodejs 可调用函数(在 Dart/Flutter 中调用)
exports.loginLink = functions.https.onCall(async (data, context) => {
const accountId = data.id;
console.log('this is accountId ---->' + accountId);
const loginLink = await stripe.accounts.createLoginLink(
accountId
).then(() => {
console.log(data.id)
console.log(loginLink);
return loginLink;
});
})
并从 Flutter 调用如下
Future<void> getUrl() async {
HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('loginLink');
dynamic results = await callable.call(<String, dynamic>{
'id': 'acct_1IpttSQgX5lyYgEb',});
print (results.data);
String urlLink = results.data;
}
Firebase 日志返回未处理的错误 ReferenceError:在初始化之前无法访问“loginLink” 在 /workspace/index.js:41:15
对获取 stripe 提供的 url 有任何帮助吗?
【问题讨论】:
标签: node.js flutter google-cloud-functions stripe-payments