我已经在我的应用程序中使用typescript实现了stripe,我有以下功能:
exports.deleteStripeCustomer = functions.https.onCall((data, context) => {
const deleted = await stripe.customers.del(
"I need to add the customers ID here"
);
});在需要添加customerID字符串中,我想从我已经侦听的快速代码中添加客户ID,并在调用函数时将其添加到函数中。
在swift中,这是这样做的:
func sayHello(name: string) {
print("hello \(name)")
}然后,当调用函数时,id从其他地方传入,如下所示:
sayHello(name: usersName)你知道这是如何在typescript中完成的吗?
提前感谢,任何帮助都将不胜感激!
发布于 2021-05-05 07:18:52
在TypeScript函数中,您只需从data参数获取它。
exports.deleteStripeCustomer = functions.https.onCall((data, context) => {
const userId = data.userId
});在Swift调用中,您可以这样传递它:
let payload = [
"userId": "u456"
]
SomeAPI.httpsCallable("deleteStripeCustomer").call(payload) { (_, error) in
if let error = error {
print(error)
}
}我从来没有使用过Stripe,我也不知道他们的客户端API是如何配置的(或者说服务器端),但我假设它就像我过去使用过的其他TypeScript-Swift互操作一样,这就是它是如何在那里完成的。如果您将我链接到他们关于此API的文档,我可以提供进一步的帮助,但通常情况下,既然您问的一般,这就是它是如何完成的。
https://stackoverflow.com/questions/67392140
复制相似问题