lightning-browser-extension icon indicating copy to clipboard operation
lightning-browser-extension copied to clipboard

Rethink: about allowing user to create invoice which has no payment amount enter

Open pavanjoshi914 opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe

Currently, we allow users to create invoices even when no amount is entered by the user , we can create invoices without entering the amount and description fields. One of the drawbacks it brings with webln is triggering of actions when the SendPayment function starts executing.

webln.sendPayment('lnbcrt1p3tgsttpp590awz5p8s5hchd6tqjatzhu73tdxyp23stj754u49lq8wlgdsseqdqdv93xxer9venkscqzpgxqyz5vqsp5p7ykrtzcqnj2xpegzrd8feqtuwvy5nx3szkusztnreukg430squs9qyyssq50lspygs2yrk76fet0mr9mydeqsfaq05k5xvtssrng8jj0u9nzp9dm9x764n96szg0nddfaypydd949j5updkw9rdnpj3uy7v6dccfqp2r9p0g', jsonObject)
          .then(function(r) {


			//	do some action here , like code for downloading a song after the payment
			// empty invoices still allow to run this block of code , which means without payment user can now play with metadata
    
          .catch(function(e) {
            alert("Failed: " + e.message);
            console.log('err pay:', e);
          });
    })
    .catch(function(e) {
      alert("Webln error, check console");
      console.log('err, provider', e);
    });

Describe the solution you'd like

  1. not allowing user to make empty invoices anymore
  2. add another constraint as a rule that r shall not be undefined
if(r != undefined){
all the metadata that has to be given to the user

}

pavanjoshi914 avatar Jun 23 '22 10:06 pavanjoshi914

I am not sure if I get what you mean. you refer to people calling webln.sendPayment with an zero-amount invoice?

bumi avatar Jun 23 '22 16:06 bumi

I am not sure if I get what you mean. you refer to people calling webln.sendPayment with an zero-amount invoice?

Yes, this is a prblem for defining metadata content after .then() callback block

pavanjoshi914 avatar Jun 23 '22 16:06 pavanjoshi914