lnbits / satspay

Create onchain and LN charges
MIT License
8 stars 4 forks source link

[Feature request] Fiat value in checkout #19

Open arbadacarbaYK opened 1 year ago

arbadacarbaYK commented 1 year ago

Please show fiat-value of preferred currency in checkout. Most merchants but also users have set their wallets and online-shops to a fiat-currency and the UX breaks here. That mean you cannot check easily if the amount of sats charged is correct. This goes especially for NFC payments, where you do not see the fiat-value again in your wallet before proceeding to pay.

talvasconcelos commented 1 year ago

Where is this fiat set, and is there a global variable we can tap to? Showing a fiat value is fairly straight forward, i just need to know what currency!

@dni @jackstar12 ?

jackstar12 commented 1 year ago

Where is this fiat set, and is there a global variable we can tap to? Showing a fiat value is fairly straight forward, i just need to know what currency!

@talvasconcelos This currency would have to be set in the creation form (if the user wants to be able to enter a fiat amount aswell?), altough it could default to the one used by the wallet, which you can get through this.g.wallet.currency, and then used as an argument to create_invoice which would calculate the corresponding amount of sats: https://github.com/lnbits/satspay/blob/ba0496e75cc623fae1c1f5237a20f6a68ae14e7c/crud.py#L31-L37

That would not work for onchain tough, so you could call the service that does the fiat conversion directly. https://github.com/lnbits/lnbits/blob/dev/lnbits/core/services.py#L66

talvasconcelos commented 1 year ago

I thought that what was asked was to just display the value on the charge in fiat (@arbadacarbaYK ?)! not defining the charge in fiat terms, that's another beast, and can cause some issues if for example i have a charge that expires in 24h!

So there's a currency property on g.wallet? I can use that... Convert at mount and display the fiat value, if exists in the wallet!

talvasconcelos commented 1 year ago

If the charge is only onchain, that doesn't work! On setting fiat tracking, there could/should be a global variable with that currency! It would make things easier for using at extensions.

jackstar12 commented 1 year ago

If the charge is only onchain, that doesn't work! On setting fiat tracking, there could/should be a global variable with that currency! It would make things easier for using at extensions.

Well, there is. this.g.wallet.currency if the current if I remember correctly or just the currency wallet property on the python side

arbadacarbaYK commented 1 year ago

I thought that what was asked was to just display the value on the charge in fiat (@arbadacarbaYK ?)! not defining the charge in fiat terms, that's another beast, and can cause some issues if for example i have a charge that expires in 24h!

So there's a currency property on g.wallet? I can use that... Convert at mount and display the fiat value, if exists in the wallet!

its was not just about displaying, also about storing in the csv - it belongs to https://github.com/lnbits/lnbits/issues/1754#issuecomment-1597603884 and some others where alltoghether i asked for a default national fiat currency and to have that possible to be overwritten in extensions and stored in the csv, tx-history for the tpos and print-outs.

Because it has gotten so many unconnected PR i lost track.

https://github.com/lnbits/lnbits/pull/1852 and https://github.com/lnbits/lnbits/pull/1789 and https://github.com/lnbits/tpos/issues/20 and https://github.com/lnbits/lnbits/pull/1852 and https://github.com/lnbits/lnbits/pull/1756 and https://github.com/lnbits/lnbits/pull/1813 and https://github.com/lnbits/lnbits/pull/1869 and https://github.com/lnbits/lnbits/issues/1909 and https://github.com/lnbits/lnbits/issues/1666