Skip to content

Commit

Permalink
Refactor: allow different action URLs on card-tokenize success form (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran authored Sep 10, 2024
2 parents 79aea2f + 94003a3 commit c5fc5d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions benefits/enrollment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

from django import forms

from benefits.routes import routes


class CardTokenizeSuccessForm(forms.Form):
"""Form to bring client card token back to server."""

action_url = routes.ENROLLMENT_INDEX
id = "form-card-tokenize-success"
method = "POST"

def __init__(self, data=None, action_url=None, *args, **kwargs):
super().__init__(data, *args, **kwargs)
self.action_url = action_url

# hidden input with no label
card_token = forms.CharField(widget=forms.HiddenInput(), label="")

Expand Down
4 changes: 3 additions & 1 deletion benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ def index(request):
tokenize_system_error_form = forms.CardTokenizeFailForm(
routes.ENROLLMENT_SYSTEM_ERROR, "form-card-tokenize-fail-system-error"
)
tokenize_success_form = forms.CardTokenizeSuccessForm(auto_id=True, label_suffix="")
tokenize_success_form = forms.CardTokenizeSuccessForm(
action_url=routes.ENROLLMENT_INDEX, auto_id=True, label_suffix=""
)

# mapping from Django's I18N LANGUAGE_CODE to Littlepay's overlay language code
overlay_language = {"en": "en", "es": "es-419"}.get(request.LANGUAGE_CODE, "en")
Expand Down

0 comments on commit c5fc5d7

Please sign in to comment.