我正在研究支付网关集成,不得不调用订单 api。但我不断收到错误
{"error":{"code":"BAD_REQUEST_ERROR","description":"Please provide your api key for authentication purposes."}}
我的整个代码段
const functions = require('firebase-functions');
var express = require('express');
var cors = require('cors');
var request = require('request');
const crypto = require('crypto');
var app = express();
app.use(cors({origin:true}));
app.post("/",(req,res)=>{
const amount = req.body.amount;
const key = '----insert your key here----';
const key_secret = '----- insert key secret here ----';
var options = { method: 'POST',
url: 'https://api.razorpay.com/v1/orders',
headers:
{
Authorization: 'Basic' + new Buffer(key + ":" + key_secret).toString("base64")},
form:
{ amount: amount,
currency: 'INR',
receipt: "Receipt #20",
payment_capture : 1
}
};
request(options, (error, response, body)=> {
if (error) throw new Error(error);
res.send(body);
});
})
exports.razorpaymentApi = functions.region('asia-east2').https.onRequest(app);
我已经 用我原来的 api 密钥和秘密替换了key和key_secret 。你能告诉我哪里出错了。谢谢