Don't allow invoices lower than 0.001 and require 0.01 for sponsorship.
refs #122
This commit is contained in:
		
							parent
							
								
									0cbc7e2ab6
								
							
						
					
					
						commit
						1f7483687f
					
				@ -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> {
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -27,9 +27,9 @@
 | 
			
		||||
            <div class="input-group-prepend" style="width: 42px;">
 | 
			
		||||
              <span class="input-group-text">₿</span>
 | 
			
		||||
            </div>
 | 
			
		||||
            <input formControlName="amount" class="form-control" type="number" min="0.01" step="1E-03">
 | 
			
		||||
            <input formControlName="amount" class="form-control" type="number" min="0.001" step="1E-03">
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="input-group mb-4">
 | 
			
		||||
          <div class="input-group mb-4" *ngIf="donationForm.get('amount').value >= 0.01; else lowAmount">
 | 
			
		||||
            <div class="input-group-prepend" style="width: 42px;">
 | 
			
		||||
              <span class="input-group-text">@</span>
 | 
			
		||||
            </div>
 | 
			
		||||
@ -41,12 +41,20 @@
 | 
			
		||||
        </form>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <ng-template #lowAmount>
 | 
			
		||||
        <div class="input-group mb-4 text-small">
 | 
			
		||||
          If you donate 0.01 BTC or more, your profile photo will be added to the list of sponsors above :)
 | 
			
		||||
        </div>
 | 
			
		||||
      </ng-template>
 | 
			
		||||
 | 
			
		||||
      <div *ngIf="donationStatus === 3" class="text-center">
 | 
			
		||||
        <div class="qr-wrapper mt-4 mb-2">
 | 
			
		||||
        <div class="qr-wrapper mt-2 mb-2">
 | 
			
		||||
          <app-qrcode [data]="donationObj.address + '?amount=' + donationObj.amount"></app-qrcode>
 | 
			
		||||
        </div>
 | 
			
		||||
        <br>
 | 
			
		||||
        <p style="font-size: 10px;">{{ donationObj.address }}</p>
 | 
			
		||||
        <p style="font-size: 12px;">{{ donationObj.amount }} BTC</p>
 | 
			
		||||
 | 
			
		||||
        <p>Waiting for transaction... </p>
 | 
			
		||||
        <div class="spinner-border text-light"></div>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user