openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 724 forks source link

[Admin][Orders] Snail when failing Stripe SCA-Payments #6964

Open filipefurtad0 opened 3 years ago

filipefurtad0 commented 3 years ago

Description

Updated: observed only for backoffice orders In staging, paying with a 3D-auth card requires an authentication step and clicking "Fail Authentication" or using a card which should trigger insufficient funds error, shows us the snail, triggering bugsnag:

https://app.bugsnag.com/open-food-france/coopcircuits/errors/6038dea811072c0018798902?event_id=6038dea80072dd55a5d70000&i=sk&m=nw

Is this only visible on a staging environment or to customers as well in production, each time a payment is not authorized by a bank?

Expected Behavior

Payment should fail with no snail; error should be displayed to the user.

Actual Behaviour

Payment fails, but snail is visible.

Steps to Reproduce

  1. Create any payment which requires 3D-auth.
  2. When prompted, click "Fail Payment"
  3. See the snail.
  4. Refreshing the page should allow you to proceed as usual.

Animated Gif/Screenshot

Peek 2021-02-26 16-04

Workaround

Refresh the page.

Severity

Assuming it is only visible in staging: bug-s5?

Your Environment

Possible Fix

filipefurtad0 commented 3 years ago

I've forgotten about this and bumped on it while testing Rails 5 - it is observed in master as well.

We probably have bigger fish to fry, but for documentation purposes, I'd re-open this issue - it's an S5, as long as we don't get this error in production, when a transactions is refused, due to insufficient funds - which we currently don't.

Following the authentication step for backoffice orders/payments, with cards like 4000008260003178 (insufficient funds) one should get:

Expected behavior https://app.bugsnag.com/yaycode/openfoodnetwork/errors/6048da3012ca530008ed410e?event_id=6048da300072da34e9ad0000&i=sk&m=nw

Handled error
RuntimeError: Your card has insufficient funds.
Location
app/controllers/checkout_controller.rb:221 - checkout_failed

One gets: Actual behavior is : https://app.bugsnag.com/yaycode/openfoodnetwork/errors/6048dace8fe78f00071a78b7?event_id=6048dace0072e54e07c10000&i=sk&m=nw

Unhandled error
StateMachines::InvalidTransition: Cannot transition state via :complete from :failed (Reason(s): State cannot transition via "complete")
Location
app/services/process_payment_intent.rb:23 - call!