【发布时间】:2021-11-03 06:36:43
【问题描述】:
我正在使用 node.js 在 firebase 中编写云函数,但我收到错误 [firebase_functions/internal] internal。
我在 index.js 中的代码:-
const cors = require('cors')({origin: true});
const Razorpay = require('razorpay')
const instance = new Razorpay({
key_id: 'my id',
key_secret: 'my key'
})
exports.razorpayOrderId = functions.https.onCall(async(req, res) => {
var options = {
amount: 10000,
currency: "INR",
};
try{
instance.orders.create(options).then(order => console.log(order));
}catch(e){
console.log(e);
res.status(403).send({error: 'error'});
}
});
我在flutter中触发该功能的代码:-
HttpsCallable callable = FirebaseFunctions.instance.httpsCallable(
'razorpayOrderId',
options: HttpsCallableOptions(timeout: Duration(seconds: 5)),
);
try {
final HttpsCallableResult result = await callable.call(
<String, dynamic>{
'message': 10000,
},
);
print(result.data['response']);
} catch (e) {
print(e);
}
【问题讨论】:
标签: node.js firebase google-cloud-functions flutter-web razorpay