Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

javascript - 未在条带帐户上创建客户(Customer is not created on stripe account)

I am running this node.js code to create customer on stripe account function deploy successful but failed to create customer on stripe I am not getting what I am missing.(我正在运行此node.js代码以在条带化帐户上创建客户功能部署成功,但在条带化上创建客户失败,但我没有得到我所缺少的信息。)

Fire base functions folder is also not showing the function there.(Fire base Functions文件夹也未显示该功能。) const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); const stripe = require('stripe')("secret key here"); var customer; stripe.customers.create( { email: 'customer@example.com', }, { maxNetworkRetries: 2, } );   ask by Developer translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When you use APIs to services (viz. stripe.com and firebase) outside your complete control, you must check for errors.(当您在完全无法控制的地方使用API??来服务(即Stripe.com和Firebase)时,必须检查错误。)

If you're using a service incorrectly the error will explain, or at least hint, what you're doing wrong.(如果您使用的服务不正确,该错误将说明或至少暗示您在做什么错。) The stripe-node API documentation suggests you invoke stripe.customer.create() as an awaited function, like this:(条带节点API文档建议您将stripe.customer.create()作为等待的函数调用,如下所示:) const customer = await stripe.customers.create({ email: 'customer@example.com', }); This is easy if you call it from an async function.(如果从异步函数调用它,这很容易。) You should use this sort of code in your async function to check for errors back from stripe.com.(您应该在异步函数中使用这种代码来检查来自stripe.com的错误。) try { const customer = await stripe.customers.create({ email: 'customer@example.com', }); /* here's your customer object */ } catch (error) { console.error ('stripe', error); } If you do not call it from an async function, you can wait for results using the Promises scheme.(如果您不通过异步函数调用它,则可以使用Promises方案等待结果。) stripe.customers.create({ email: 'customer@example.com', }) .then ( function (customer) { /* here's your customer object */ }) .catch ( function (error) { console.error ('stripe', error); }); If you haven't yet figured out how async/await or Promises work, the time has come for you do to that.(如果您尚未弄清楚异步/等待或Promises的工作方式,那么您就该这样做了。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...