Answer the question
In order to leave comments, you need to log in
How to properly configure a server on node js to receive notifications about incoming payments Yandex Money (yandex money)?
Colleagues, good afternoon!
I re-read the Yandex Money documentation and looked through all the posts on this topic, but I can’t fully figure it out.
I am making a skeleton for a small telegram online store with the ability to pay by card through Yandex Money.
For now, I do everything manually directly from the code editor to check if it works.
Set up a wallet to send notifications when receiving a payment:
Created an https server:
const express = require('express');
const app = express();
const https = require('https');
const fs = require('fs');
const port = 3000;
const options = {
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem')
};
const Server = ()=>{
app.post('/receive',(req, res)=>{
console.log('you have got some incoming payment');
res.status(200).send();
});
app.get('/',(req, res)=>{
console.log('get request');
res.status(200).send();
});
https.createServer(options, app)
.listen(port, function () {
console.log('Example app listening on port 3000!')
});
yandexMoney.ExternalPayment.getInstanceId(clientId,
function getInstanceComplete(err, data) {
if(err) {
// process error
}
var instanceId = data.instance_id;
// save it to DB
console.log('data.instance_id: ', data.instance_id)
});
var externalPayment = new yandexMoney.ExternalPayment(config.instanceId)
var options = {
pattern_id: 'p2p',
instance_id: config.instanceId,
to: '4100145656XXXXX',
amount: 5,
message: 'testpayment',
merchantArticleId: 123
};
externalPayment.request(options, function requestComplete(err, data) {
if(err) {
// process error
}
var requestId = data.request_id;
console.log('data', data);
externalPayment.process({"request_id": requestId,
ext_auth_success_uri: 'https://t.me/kursy_naXXXXXX,
ext_auth_fail_uri: 'https://t.me/kursy_naXXXXXX'
}, function (err, data) {
if(err) {
// process error
}
// process data
console.log('dataProcess', data)
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question