-
Notifications
You must be signed in to change notification settings - Fork 9
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
New System enrollment error
page
#2032
Comments
Met with @thekaveman and @lalver1 today to go over the conditions in which to show the We took some notes during the meeting; here are some additional details and code snippets: We reviewed the original intention of each error page from #1939 and were able to unravel that We also decided that 400 level errors from Littlepay most likely indicate a misconfiguration on our end, so those should show our generic error page (i.e. by raising an Exception). Lastly, we noted Backoffice API misconfiguration can present itself in a few different ways, so we should test out as much misconfiguration as we can and let those show the generic error page. Some other notes:
Some rough pseudocode from our meeting: @decorator_from_middleware(EligibleSessionRequired)
def token(request):
"""View handler for the enrollment auth token."""
if not session.enrollment_token_valid(request):
agency = session.agency(request)
payment_processor = agency.payment_processor
client = Client(
base_url=payment_processor.api_base_url,
client_id=payment_processor.client_id,
client_secret=payment_processor.client_secret,
audience=payment_processor.audience,
)
client.oauth.ensure_active_token(client.token)
try:
response = client.request_card_tokenization_access()
except Exception as e:
# status_code == 500 => system enrollment error page
# status_code is 400-404 => our generic 500 error page
# UnsupportedTokenTypeError => our generic 500 error page
# anything else => our generic 500 error page (b/c it's probably a bug on our side)
session.update(request, enrollment_token=response.get("access_token"), enrollment_token_exp=response.get("expires_at"))
data = {"token": session.enrollment_token(request)}
return JsonResponse(data) @decorator_from_middleware(EligibleSessionRequired)
def index(request):
"""View handler for the enrollment landing page."""
...
try:
client.link_concession_group_funding_source(funding_source_id=funding_source.id, group_id=eligibility.group_id)
except HTTPError as e:
# 409 means that customer already belongs to a concession group.
# the response JSON will look like:
# {"errors":[{"detail":"Conflict (409) - Customer already belongs to a concession group."}]}
if e.response.status_code == 409:
analytics.returned_success(request, eligibility.group_id)
return success(request)
elif e.response.status_code >= 500:
# system enrollment error
else:
analytics.returned_error(request, str(e))
raise Exception(f"{e}: {e.response.json()}")
except Exception as e:
analytics.returned_error(request, str(e))
raise e
# generic 500 error page
else:
analytics.returned_success(request, eligibility.group_id)
return success(request) |
Acceptance Criteria
Front-end design implementation:
Back-end logic
enrollment/index.html
will need to know where to send useronError
callback in tokenization function needs to redirectonError
shows error pages rather than retry #2120onError
shows error pages rather than retry #2120Additional context
The text was updated successfully, but these errors were encountered: