B2Bitcoin / beBOP

Marvelous p2p bitcoin-based online sales platform
https://be-bop.io
GNU Affero General Public License v3.0
15 stars 3 forks source link

Add a currency selection management #330

Open Tirodem opened 1 year ago

Tirodem commented 1 year ago

Context

Bootik owners can actually choose their currency in backoffice. image image In order to make future adoption easier, it'll be great to be able to add every currency. But, in term of usability, it's better not to have a too long selector on these UIs.

Proposition

Allow Bootik's owners to choose what currency they want to be displayed on their UI.

Source

https://en.wikipedia.org/wiki/ISO_4217#Active_codes_(List_One) with https://en.wikipedia.org/wiki/List_of_circulating_currencies#List_of_circulating_currencies_by_state_or_territory for currency symbol to display

UI

On /admin/config/currencies, make this table + a "SAVE" and a "CANCEL" button : image

coyotte508 commented 1 year ago

ok, so, add "backOfficeCurrency" config param

Shouldn't be hard after all the work of #325 , which refactored the codebase to handle multiple currencies easily

coyotte508 commented 1 year ago

Note that we use https://api.coingate.com/v2/rates/merchant/BTC/[CURRENCY] to get the exchange rate, so we're limited by coingate's api

For example https://api.coingate.com/v2/rates/merchant/BTC/XAF doesn't exist, but https://api.coingate.com/v2/rates/merchant/BTC/AED does exist

Same with another API: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=xaf doesn't exist

Tirodem commented 1 year ago

Can we use a "rebound" currency ? If we don't have BTC > XAF conversion, take the BTC > USD then USD > XAF ?

coyotte508 commented 1 year ago

Currently, BTC is our central currency. (eg we do conversions to and from BTC, to convert between EUR & USD for example)

Ideally we'd find another free API with BTC/XAF conversion: https://www.coinbase.com/graphql/query?&operationName=ConversionToolFragmentRefetchQuery&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22956400996ae3d34bc3dd32796f787226bf7b6e4db19d55e0b0797703b5386cea%22%7D%7D&variables=%7B%22baseSymbol%22%3A%22BTC%22%2C%22country%22%3A%22FR%22%2C%22targetCurrency%22%3A%22XAF%22%7D maybe we could use coinbase's API instead (but it's much less cleaner to query)

coyotte508 commented 1 year ago

Regarding table : it may be better instead to add an autocomplete:

Would probably be the same amount of work and it'd be a component we can reuse later on

Tirodem commented 1 year ago

Nice & better ! Can it be mixed easily with #32 ?

coyotte508 commented 1 year ago

Nice & better ! Can it be mixed easily with #32 ?

So the bootik owner would be able to select any language, even unsupported, and add product descriptions for them? In that case yes, the component could be reused in the admin interface for the bootik owner to choose additional languages.

Tirodem commented 1 year ago

That's nice, I wasn't expecting this much. So far I was juste speaking for the country's name in the selector. But what you say is fabulous.

Tirodem commented 1 year ago

Note that we use https://api.coingate.com/v2/rates/merchant/BTC/[CURRENCY] to get the exchange rate, so we're limited by coingate's api

For example https://api.coingate.com/v2/rates/merchant/BTC/XAF doesn't exist, but https://api.coingate.com/v2/rates/merchant/BTC/AED does exist

Same with another API: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=xaf doesn't exist

Can you take a look to this ? https://yadio.io/api.html Found it by checking Phoenix wallet code on Github ( https://github.com/ACINQ/phoenix/blob/406895f2430fbe2f93df55018ebf28c9e2aaf627/phoenix-shared/src/commonMain/kotlin/fr.acinq.phoenix/data/ExchangeRates.kt )

@ffmad any opinion about Yadio or a good "light side" API ?

Tirodem commented 1 year ago

Concerning Yadio, here's their way of processing the BTC rate: image So as it's BTC to USD and the reverse, we might be able to do a chain with conversion from USD to any other currency with a non-BTC currency API, but the one I found are paying after a certain amount of request. BTW, Yadio also tells this : image Maybe we can make a shortlist of currencies, check and ask them for the missing ones...