Plant-for-the-Planet-org / planet-webapp

The Open Source and Commission Free Application that powers the Trillion Tree Campaign. Visit us to meet reforestation Organizations, individuals and companies who are on a journey to plant, monitor and restore a trillion trees.
https://www.trilliontreecampaign.org
Other
37 stars 15 forks source link

Fix errors caused by unsupported currencies for donations #773

Closed norbertschuler closed 2 years ago

norbertschuler commented 3 years ago

Describe the bug The API call for payment options, e.g. https://app.plant-for-the-planet.org/app/projects/proj_zoj2MAHlXzibgydQbif5CZBo/paymentOptions?country=AQ can reset the chosen currency in the donation popup to EUR, so the selected value of the currency chooser dialog gets changed and this dialog does not display any preselected country+currency anymore. If chosen such a unsupported currency twice, it keeps being displayed with the wrong amounts in EUR until the payment finally fails.

Is it on a Production or Development Build? production

To Reproduce Steps to reproduce the behavior:

  1. Open donation popup for a project

    1
  2. Click on choosing another currency and choose currency of e.g. Antarctica · AQD

    2
  3. See that currency is reset from AQD to EUR again while tree cost amount is set to 0.

    3
  4. Click on choosing another currency again and choose e.g. Antarctica · AQD

    4
  5. See that currency is now AQD

    5
  6. See error if trying to pay with chosen unsupported currency

    6

Expected behavior Either remove all unsupported currencies from frontend (check against list of supported currencies from backend) or fix the reset of unsupported currencies in the donation dialog.

sagararyal commented 3 years ago

API response here has: {"treeCost":0.0,"currency":"EUR","effectiveCountry":"DE","requestedCountry":"AQ","gateways":{"stripe":{"isLive":true,"methods":["stripe_cc"],"account":"acct_1DYCMDD2OpW2f42N","recurrency":{"enabled":true,"intervals":["none","daily","weekly","monthly","quarterly","semiyearly","yearly"]},"authorization":{"stripePublishableKey":"pk_live_kgrdlpO8m5OZmfysUTSwbzrd","accountId":"acct_1DYCMDD2OpW2f42N"}}}}

For effective country DE, and the currency EUR, treecost is 0;

The calculation needs to be fixed.

Even if frontend sends country that does not exist, it is job of the backend to return default currency, which it does here, but simply fails in calculation.

Are the rates not being fetched from fixer?

norbertschuler commented 3 years ago
Bildschirmfoto 2021-01-26 um 08 35 03