无法使用 Stripe 部署 Firebase 云功能



我试图使用Firebase云功能与Stripe API通信,我无法部署任何功能,即使我只是初始化Stripe。

这是代码:

const fun = functions.region("europe-west2");
const secretKey = functions.config().stripe.key;
const pubKey = functions.config().stripe.push;
const stripe = new Stripe(pubKey, {
apiVersion: "2020-08-27",
});
export const helloWorld = fun
.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send({
"secret": secretKey,
"pub": pubKey,
"stripe": stripe,
});
});

我试着在函数初始化条纹,但我得到同样的错误。

错误:

firebase deploy --only functions:helloWorld
=== Deploying to '[PROJECT NAME]'...
i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> lint
> eslint --ext .js,.ts .
Running command: npm --prefix "$RESOURCE_DIR" run build
> build
> tsc
✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (90.78 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: updating Node.js 14 function helloWorld(europe-west2)...
i  functions: cleaning up build files...
Function URL (helloWorld(europe-west2)): [URL HERE]
Functions deploy had errors with the following functions:
helloWorld(europe-west2)
To try redeploying those functions, run:
firebase deploy --only "functions:helloWorld"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.

是否有我没有看到的语法错误?我用错图书馆了吗?我能做些什么来解决这个问题?

原来我只需要在函数文件夹内npm install stripe --save,而不是在源文件夹中。

相关内容

  • 没有找到相关文章

最新更新