【发布时间】:2021-10-10 14:24:53
【问题描述】:
我正在使用 Js 构建我的第一个 firebase 函数,以使用 Checkout.com API 处理卡支付,我已经安装了 checkout 和 firebase JavaScript SDK,这是我的 index.js 文件夹:
const functions = require("firebase-functions");
const { Checkout } = require("checkout-sdk-node");
const cko = new Checkout("sk_test_XXXXX-XXXX-XXXX");
exports.payWithToken = functions.https.onCall(async (data, context) => {
try {
const payment = await cko.payments.request({
source: {
token: data.token,
},
customer: {
email: context.auth.token.email
},
currency: data.currency,
amount: data.amount,
})
return {
"Status": payment.status,
"3DS-Link": payment.redirectLink,
"Approved": approved,
"Flagged": risk.flagged,
};
} catch (error) {
console.log(error)
throw new functions.https.HttpsError(error.name, error.message, error);
}
});
我认为我正确地遵循了文档,但由于某种原因,我无法将此功能部署到 firebase 并且出现此错误:
【问题讨论】:
-
检查你的
package.json语法应该是"scripts": { "lint": "eslint" },
标签: javascript firebase checkout