简体   繁体   English

使用 Android 应用程序的 FIrebase 云函数生成 Razorpay OrderId

[英]Generate Razorpay OrderId using FIrebase Cloud Functions for Android App

How to generate order ID using the Firebase cloud function for my Android app and send it to the client?如何使用 Firebase 云 function 为我的 Android 应用程序生成订单 ID 并将其发送给客户端? The documentation has only the following code and no more details - https://razorpay.com/docs/payment-gateway/android-integration/standard/#step-3-create-an-order-in-your-server该文档只有以下代码,没有更多详细信息 - 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);
});

Instead of making callback function just use the async/await .而不是回调 function 只需使用async/await

Now just make function by using firebase functions.现在只需使用 firebase 函数制作 function。

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'});
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM