我想使用 Firebase Cloud Functions 捕获付款并立即在付款上创建转帐。捕获正确进行,但未执行传输。可能是什么原因?
参考文档:https ://github.com/razorpay/razorpay-node/blob/master/examples/index.js
以下是我的 Firebase Cloud Function 的源代码:
exports.CapturePayment = functions.database.ref('payment_id').onWrite((event) => {
const payment_id = event.data.val();
// Capture a particular payment
rzp.payments.capture(payment_id, 100000).then((data) => {
return event.data.ref.child('status').set(data);
console.log(data);
// Create transfers on a payment
rzp.payments.transfer(payment_id, {
transfers: [
{
account: 'acc_aldsfkas123123adsf',
amount: 100,
currency: 'INR'
}
]
}).then((data) => {
var db = admin.database();
var ref = db.ref("transfer");
return ref.update("Success");
console.log(data)
}).catch((error) => {
var db = admin.database();
var ref = db.ref("transfer");
return ref.update("Failure");
console.error(error)
})
// success
}).catch((error) => {
console.log(error);
// error
})
});