medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Payment sessions endpoint fails if one of payment method retrieval fails

Open chemicalkosek opened this issue 3 years ago • 0 comments

Bug report

Describe the bug

Note: This issue could be relevant also if any other payment methods retrieval fails (Adyen, Paypal etc);

We're using three payment methods from Stripe (Cards, Blik, Przelewy24) If a payment method is deactivated in Stripe Dashboard (https://dashboard.stripe.com/settings/payment_methods), the whole POST /store/carts/{cartId}/payment-sessions endpoint fails and doesn't list any of the payment methods on checkout page. Such error logs from Stripe is visible in Medusa logs:

2022-07-26T15:24:49.575802168Z app[web.1]: {"level":"error","message":"All types provided in `payment_method_types` are invalid. Please ensure the provided types are activated in your dashboard (https://dashboard.stripe.com/account/payments/settings) and your account is enabled for any preview features that you are trying to use.","stack":[{"columnNumber":16,"fileName":"/app/node_modules/stripe/lib/Error.js","functionName":"Function.generate","lineNumber":40,"methodName":"generate","native":false,"typeName":"Function"},{"columnNumber":35,"fileName":"/app/node_modules/stripe/lib/StripeResource.js","functionName":"res.toJSON.then.StripeAPIError.message","lineNumber":220,"methodName":"message","native":false,"typeName":"res.toJSON.then.StripeAPIError"},{"columnNumber":5,"fileName":"node:internal/process/task_queues","functionName":"processTicksAndRejections","lineNumber":96,"methodName":null,"native":false,"typeName":null}],"timestamp":"2022-07-26 15:24:49"}
2022-07-26T15:24:49.577303344Z app[web.1]: SOME_IP - - [26/Jul/2022:15:24:49 +0000] "POST /store/carts/cart_01G86M4X9K143P96VA9ZVCGNQA/payment-sessions HTTP/1.1" 500 86 "https://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"

We discovered this the hard way. Since one payment processor (Przelewy24) temporarily suspended our account because of some lacks in Terms and Regulations on website. The other two payment methods don't show in such scenario because the whole endpoint has a 500 error. Only deactivating the affected plugin/service in Region settings makes it work. While this seems reasonable, in case of a temporary suspension, review process or any error on Stripe side, none of the payment methods will be listed. It probably will be relevant if some other payment method retrieval fails (like Paypal, Adyen or other). And we didn't even know about the suspension until we checked events on Stripe logs

System information

Medusa version (including plugins): "@medusajs/medusa": "^1.3.4", "medusa-payment-stripe": "^1.1.41",

Steps to reproduce the behavior

  1. Have two Stripe payment methods setup (ie. Stripe and Stripe Giropay)
  2. Turn off Giropay in Stripe Dashboard (https://dashboard.stripe.com/settings/payment_methods),
  3. See the payment-sessions endpoint fail and none of the payment methods are listed on checkout page

Expected behavior

Available payment methods are listed even if one of them is blocked/suspended/under review/errors out.

Additional context

We created our own services for Blik and Przelewy24 but you can test with with the built in methods (Giropay, Bancontact, iDEAL) This can be only tested in production (Stripe live keys), since in development (Stripe test keys) you can't turn off payment methods.

chemicalkosek avatar Jul 26 '22 16:07 chemicalkosek