Repository: fossasia/open-event-server

Issue:
Return the error message received from stripe in case of error.
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
When linking an event, the server returns a generic message "Stripe isn't configured properly for the event". Instead return the error message received from Stripe

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
#4852 


Discussion:

Resolving patch:
diff --git a/app/api/helpers/payment.py b/app/api/helpers/payment.py
--- a/app/api/helpers/payment.py
+++ b/app/api/helpers/payment.py
@@ -7,6 +7,7 @@
 
 from app.api.helpers.cache import cache
 from app.api.helpers.db import safe_query
+from app.api.helpers.exceptions import ForbiddenException
 from app.api.helpers.utilities import represents_int
 from app.models import db
 from app.models.event import Event
@@ -66,7 +67,7 @@ def get_event_organizer_credentials_from_stripe(stripe_auth_code):
         credentials = StripePaymentsManager.get_credentials()
 
         if not credentials:
-            raise Exception('Stripe credentials of the Event organizer not found')
+            raise ForbiddenException({'pointer': ''}, "Stripe payment isn't configured properly for this Event")
 
         data = {
             'client_secret': credentials['SECRET_KEY'],
diff --git a/app/api/stripe_authorization.py b/app/api/stripe_authorization.py
--- a/app/api/stripe_authorization.py
+++ b/app/api/stripe_authorization.py
@@ -44,17 +44,14 @@ def before_create_object(self, data, view_kwargs):
         try:
             self.session.query(StripeAuthorization).filter_by(event_id=data['event'], deleted_at=None).one()
         except NoResultFound:
-            try:
-                credentials = StripePaymentsManager\
-                    .get_event_organizer_credentials_from_stripe(data['stripe_auth_code'])
-                if 'error' in credentials:
-                    raise UnprocessableEntity({'pointer': '/data/stripe_auth_code'}, credentials['error_description'])
-                data['stripe_secret_key'] = credentials['access_token']
-                data['stripe_refresh_token'] = credentials['refresh_token']
-                data['stripe_publishable_key'] = credentials['stripe_publishable_key']
-                data['stripe_user_id'] = credentials['stripe_user_id']
-            except Exception:
-                raise ForbiddenException({'pointer': ''}, "Stripe payment isn't configured properly for this Event")
+            credentials = StripePaymentsManager\
+                .get_event_organizer_credentials_from_stripe(data['stripe_auth_code'])
+            if 'error' in credentials:
+                raise UnprocessableEntity({'pointer': '/data/stripe_auth_code'}, credentials['error_description'])
+            data['stripe_secret_key'] = credentials['access_token']
+            data['stripe_refresh_token'] = credentials['refresh_token']
+            data['stripe_publishable_key'] = credentials['stripe_publishable_key']
+            data['stripe_user_id'] = credentials['stripe_user_id']
         else:
             raise ConflictException({'pointer': '/data/relationships/event'},
                                     "Stripe Authorization already exists for this event")


Test patch: