我正在尝试将云功能部署到与贝宝支付相关的 Firebase。但是,我不断收到一个我不明白的错误。这是我的函数 index.js
const functions = require("firebase-functions");
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// functions.logger.info("Hello logs!", {structuredData: true});
// response.send("Hello from Firebase!");
// });
const braintree = require("braintree");
const gateway= new braintree.BraintreeGateway({
environment: braintree.Environment.Sandbox,
merchantId: "g4rwjwrjjwjewjjewj",
publicKey: "wkklljwljhtwkthkth",
privateKey: "ktktjhjhttrhjerhjterh",
});
exports.paypalPayment= functions.https.onRequest(async(req, res) =>{
const nonceFromTheClient = req.body.payment_method_nonce;
const deviceData = req.body.device_data;
// const amount = req.body.amount;
gateway.transaction.sale({
amount: '10.00',
// paymentMethodNonce: nonceFromTheClient,
paymentMethodNonce: 'fake-paypal-one-time-nonce',
deviceData: deviceData,
options: {
submitForSettlement: true
}
}, (err, result) => {
if (err != null) {
console.log(err);
} else {
res.json({result: "success"});
}
}
);
});
以下是尝试部署时的终端消息
i deploying functions
+ 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 cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (45.96 KB) for uploading
+ functions: functions folder uploaded successfully
i functions: updating Node.js 12 function paypalPayment(us-central1)...
Functions deploy had errors with the following functions:
paypalPayment(us-central1)
To try redeploying those functions, run:
firebase deploy --only "functions:paypalPayment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
如果有帮助,我正在尝试将 paypal 付款与 Flutter 集成