我正在尝试将本地支付提供商连接到我的nodejs电报机器人。我尝试发送确认成功的付款参数网址,例如“ server_url”:“ https://api.telegram.org/bot:token/some_method”。但是无法在我的nodejs中捕获此回调。您能帮我,我必须发送哪种网址?如何在Node.js中捕获成功的付款?谢谢。
sendRequestLiqpay() {
// set invoice parameters
let request = {
"action" : "invoice_bot",
"version" : "3",
"email" : "alexXX@gmail.com",
"amount" : this.price,
"currency" : "UAH",
"orderId" : this.orderId,
"phone" : "3806750000",
// Payment provider return result of payment by POST to this URL. How to catch this data?
'server_url': 'https://api.telegram.org/bot:token/IDoNtnowMethodToCatchPostData'
}
let chatId = this.chatId;
let public_key = 'sandbox_xx';
let private_key = 'sandbox_xx';
// init payment prov session
let liqpay = new LiqPay(public_key, private_key);
// generate provider web form url to payment and send to chat
liqpay.api("request", request,
function( json ){
this.sendPaymentlinkToUser(chatId, json.href);
});
}
答案 0 :(得分:0)
我不明白您的问题,但是我相信下面的示例代码会帮助您,需要在Nodejs应用中添加请求包。看看这个Request - Simplified HTTP client:
const EventEmitter = require('events');
const querystring = require('querystring');
const request = require('request');
class BetaSmsMessenger extends EventEmitter{
constructor(){
super();
this.on('SEND_SMS', this.sendSMS);
}
sendSMS(data){
var queryParams = {
username: 'oyewolxxxxxx@gmail.com',
password: 'xxxxxx',
sender: 'xxxxxx',
mobiles: data.phone,
message: 'Welcome to xxxxxxx, your activation token is '+data.token
}
var baseUrl = "http://auth.betasms.com/api/v1/";
var query = querystring.stringify(queryParams);
var url = baseUrl+"?"+query;
request(url, (error, response, body) => console.log(body));
}
}
module.exports = BetaSmsMessenger;