【问题标题】:Generate Razorpay OrderId using FIrebase Cloud Functions for Android App使用 FIrebase Cloud Functions for Android App 生成 Razorpay OrderId
【发布时间】:2021-06-02 16:21:16
【问题描述】:

如何使用 Firebase 云功能为我的 Android 应用生成订单 ID 并将其发送给客户端?文档只有以下代码,没有更多细节 - https://razorpay.com/docs/payment-gateway/android-integration/standard/#step-3-create-an-order-in-your-server

  var options = {
  amount: 50000,  // amount in the smallest currency unit
  currency: "INR",
  receipt: "order_rcptid_11"
};
instance.orders.create(options, function(err, order) {
  console.log(order);
});

【问题讨论】:

    标签: android google-cloud-functions razorpay


    【解决方案1】:

    只需使用async/await,而不是制作回调函数。

    现在只需使用 firebase 函数来创建函数。

    export const createOrder = functions.https.onRequest(async (req, res) => {
        try{
            const order = await instance.orders.create({amount: amount, currency: 'INR', receipt: `${request.id}`, payment_capture: 1});
            res.send(order);
        }catch(e){
            console.log(e);
            res.status(403).send({error: 'Something went wrong'});
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2021-11-24
      • 1970-01-01
      • 2017-09-07
      • 2018-01-03
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-07
      • 2018-01-14
      相关资源
      最近更新 更多