opencollective / opencollective

We're tracking all our Issues, RFCs and a few other documents in this repository.
https://opencollective.com
MIT License
2k stars 367 forks source link

Currency mismatch with payment methods balance comparison in the Contribution flow #6182

Open itsnitish22 opened 1 year ago

itsnitish22 commented 1 year ago

Describe the bug If you have an Open Collective Gift Card with you for $150 and you want to donate a project INR165 ($2 approx), the donation panel shows that you don't have sufficient balance to donate INR 165 from $150. It is assuming INR = USD. The donation amount in whatever currency it might be, open collective is comparing it with USD and not letting the user to donate more than the value of that Gift Card which is in USD. Briefly, USD 150 = INR 12,270, but you can't donate more than INR 150 at a time using that gift card.

To Reproduce You must have a Gift Card with some balance Steps to reproduce the behavior:

  1. Go to Donation, and click on Contribute.
  2. Click on Other and add a value in your local currency which is in figures more than the Gift Card value (eg. donate INR 150 from $160).
  3. Proceed further and you'll see it will say that the balance is not sufficient in you gift card.

Expected behavior Every time someone tries to donate in their local currency, open collective should first convert it into USD and then check the balance from the Gift Card (whether it is sufficient for the donation or not)

Screenshots image

Desktop (please complete the following information):

Additional context N/A

Triage Template (core team only) This template is for members of the team to triage for prioritisation. For more guidance see https://www.loom.com/share/369ab467fbc64dec848085d38ff57ca0: P1 high frequency, high impact P2 low frequency, high impact P3 high frequency, low impact P4 low frequency, low impact Examples of high impact - a problem affects users during an essential process (expenses and payments > onboarding and registration > contributing) with no workaround. High frequency - >10% of users affected (measured as a proportion of total potential users for this case).
Betree commented 1 year ago

@itsnitish22 What's the collective you're trying to donate to? DigitalOcean gift cards are limited to initiatives hosted by the Open Source Collective, so it's likely that the contribution will fail anyway.

The currency issue does exist though. Using the same approach we've used for expense's amountV2, we could fix it by accepting a currency argument on PaymentMethod.balance and making sure we fetch something as:

loggedInUser {
  paymentMethods {
    balance(currency: $collectiveCurrency) {
      value
      currency
    }
  }
}
itsnitish22 commented 1 year ago

@Betree I am contributing to one of my collectives which has Open Source Collective as a fiscal host, so I don't think there would be a problem anyways donating to the collective.

Not a pro in JS, but got the idea how it would be rectified.

Betree commented 1 year ago

@itsnitish22 Can you link the abovementioned collective so that we can investigate?