Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entering "'20.0%'" as payment method fee causes server error #6942

Closed
mkllnk opened this issue Feb 23, 2021 · 6 comments
Closed

Entering "'20.0%'" as payment method fee causes server error #6942

mkllnk opened this issue Feb 23, 2021 · 6 comments
Assignees
Labels
bug-s4 The bug is annoying, but doesn't prevent from using the platform. Not so many users are impacted. bugsnag good first issue hackathon Issues for upcoming hackathons

Comments

@mkllnk
Copy link
Member

mkllnk commented Feb 23, 2021

Description

Updating a payment method can cause a server error when entering invalid values.

It looks like someone tried to give a 20% discount by entering that value.

Expected Behavior

Invalid values should not be allowed or there should be a proper error message.

Actual Behaviour

It shows the snail.

Steps to Reproduce

  1. Edit a cash payment method.
  2. Select the "per item" calculator.
  3. Enter '20.0' with the single quotes as fee amount.
  4. Save.

Animated Gif/Screenshot

Workaround

Severity

bug-s1: a critical feature is broken: checkout, payments, signup, login
bug-s2: a non-critical feature is broken, no workaround
bug-s3: a feature is broken but there is a workaround
bug-s4: it's annoying, but you can use it
bug-s5: we can live with it, only a few users impacted

https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity

Your Environment

  • Version used:
  • Browser name and version:
  • Operating System and version (desktop or mobile):

Possible Fix

The only figures that should be allowed are:

  • numbers 0123456789
  • decimal point .
  • negative sign -

The error message should read:
Invalid input. Please use only numbers. For example: 10, 5.5, -20

Error in OpenFoodNetwork

ArgumentError in spree/admin/payment_methods#update
invalid value for BigDecimal(): "'-20'"

View on Bugsnag

Stacktrace

app/models/spree/preferences/preferable.rb:119 - BigDecimal
app/models/spree/preferences/preferable.rb:119 - convert_preference_value
app/models/spree/preferences/preferable_class_methods.rb:26 - block in preference
lib/spree/localized_number.rb:29 - call
lib/spree/localized_number.rb:29 - block (2 levels) in localize_number
app/controllers/spree/admin/payment_methods_controller.rb:43 - update

View full stacktrace

Created by Maikel via Bugsnag

@mkllnk mkllnk added bugsnag bug-s4 The bug is annoying, but doesn't prevent from using the platform. Not so many users are impacted. labels Feb 23, 2021
@RachL
Copy link
Contributor

RachL commented Feb 23, 2021

@mkllnk does this one occur for all negative figures? If so it can be a bigger problem than an s4 :(

@mkllnk
Copy link
Member Author

mkllnk commented Feb 24, 2021

No, the problem is the asterisk * at the front. The person thought that they can multiply like this. Just -20 should work.

@mkllnk
Copy link
Member Author

mkllnk commented Feb 24, 2021

No, actually, there is not asterisk. The mistake was to add single quotes: '-20'.

@mkllnk mkllnk changed the title Entering *-20.0 as payment method fee causes server error Entering "'-20.0'" as payment method fee causes server error Feb 24, 2021
@lin-d-hop lin-d-hop changed the title Entering "'-20.0'" as payment method fee causes server error Entering "'20.0%'" as payment method fee causes server error Jul 29, 2021
@meronogbai
Copy link
Contributor

Can I pick this up?

@apricot12
Copy link
Contributor

apricot12 commented Aug 29, 2021

Can I pick this up?

I just assigned you this issue. You can pick it up 😄

@filipefurtad0
Copy link
Contributor

To close this issue, other payment methods (other then Check) should be considered:

Also, all calculator types should be considered:

Combinations of the above should be considered when testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s4 The bug is annoying, but doesn't prevent from using the platform. Not so many users are impacted. bugsnag good first issue hackathon Issues for upcoming hackathons
Projects
Development

No branches or pull requests

6 participants