Don't allow invoices lower than 0.001 and require 0.01 for sponsorship.

refs #122
This commit is contained in:
softsimon
2020-10-08 00:20:42 +07:00
parent 0cbc7e2ab6
commit 1f7483687f
3 changed files with 35 additions and 20 deletions

View File

@@ -48,23 +48,30 @@ class Donations {
if (!data || !data.id) {
return;
}
const response = await this.getStatus(data.id);
if (response.status === 'complete') {
if (this.notifyDonationStatusCallback) {
this.notifyDonationStatusCallback(data.id);
}
let imageUrl = '';
if (response.orderId !== '') {
try {
imageUrl = await this.$getTwitterImageUrl(response.orderId);
} catch (e) {
console.log('Error fetching twitter image from Hive', e.message);
}
}
this.$addDonationToDatabase(response, imageUrl);
if (response.status !== 'complete') {
return;
}
if (this.notifyDonationStatusCallback) {
this.notifyDonationStatusCallback(data.id);
}
if (parseFloat(response.btcPaid) < 0.001) {
return;
}
let imageUrl = '';
if (response.orderId !== '') {
try {
imageUrl = await this.$getTwitterImageUrl(response.orderId);
} catch (e) {
console.log('Error fetching twitter image', e.message);
}
}
this.$addDonationToDatabase(response, imageUrl);
}
private getStatus(id: string): Promise<any> {

View File

@@ -117,8 +117,8 @@ class Routes {
return;
}
if (p.amount < 0.01) {
res.status(400).send('Amount needs to be at least 0.01');
if (p.amount < 0.001) {
res.status(400).send('Amount needs to be at least 0.001');
return;
}