Implement payment checks in API
This commit is contained in:
parent
d8380ec33f
commit
323ffcc50b
1 changed files with 34 additions and 8 deletions
|
@ -155,16 +155,16 @@ var blockInterval = setInterval( function() {
|
|||
if (pay.test(memo) && txData.confirmations < 100) {
|
||||
var match2 = pay.exec(memo);
|
||||
if (match2 != null) {
|
||||
var session = match[1];
|
||||
var session = match2[1];
|
||||
}
|
||||
if (txData.amount >= 0.001 && txData.amount < 0.005){
|
||||
exptime = blocktime + 3600;
|
||||
exptime = txData.blocktime + 3600;
|
||||
} else if (txData.amount >= 0.005 && txData.amount < 0.025){
|
||||
exptime = blocktime + 24*3600;
|
||||
exptime = txData.blocktime + 24*3600;
|
||||
} else if (txData.amount >= 0.025 && txData.amount < 0.1) {
|
||||
exptime = blocktime + 7*24*3600;
|
||||
exptime = txData.blocktime + 7*24*3600;
|
||||
} else if (txData.mount >= 0.1) {
|
||||
exptime = blocktime + 4*7*24*3600;
|
||||
exptime = txData.blocktime + 4*7*24*3600;
|
||||
}
|
||||
|
||||
usermodel.findOne({session: session}).then(function(doc){
|
||||
|
@ -182,9 +182,9 @@ var blockInterval = setInterval( function() {
|
|||
payment.save(function(error) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('Payment saved');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -201,6 +201,32 @@ var blockInterval = setInterval( function() {
|
|||
});
|
||||
}, 75000);
|
||||
|
||||
var payCheck = setInterval( function() {
|
||||
|
||||
ownermodel.find({}).then((documents) => {
|
||||
if(documents.length > 0){
|
||||
//console.log(documents);
|
||||
async.each (documents, function(document, callback) {
|
||||
paymentmodel.findOne({ address: document.address, expiration: {$gt: Date.now()}}).then(payment => {
|
||||
if (payment != null){
|
||||
document.paid = true;
|
||||
document.save();
|
||||
} else {
|
||||
document.paid = false;
|
||||
document.save();
|
||||
}
|
||||
});
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log("Owners checked for payment");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 60000);
|
||||
|
||||
app.use(cors());
|
||||
app.options('*', cors());
|
||||
|
||||
|
|
Loading…
Reference in a new issue