From 1fffd40cd0c80ff0ba58b791350f60a32808c476 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 17:22:51 +0000 Subject: [PATCH 1/2] fix: always include grant card in Plain customer cards response When Plain requests the grant card via cardKeys, always include it in the response even when the user doesn't exist. Previously, if the user was not found, we returned an empty cards array. Now we return an empty grant card ({key: "grant", components: []}) to match Plain's expectation that all requested card keys are always present in the response. Closes #4553 Co-authored-by: Marco Acierno --- backend/integrations/tests/test_views.py | 2 +- backend/integrations/views.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/integrations/tests/test_views.py b/backend/integrations/tests/test_views.py index 4e24a636b3..1e421795cc 100644 --- a/backend/integrations/tests/test_views.py +++ b/backend/integrations/tests/test_views.py @@ -70,7 +70,7 @@ def test_cannot_get_plain_customer_cards_when_user_doesnt_exist(rest_api_client) ) assert response.status_code == 200 - assert response.data == {"cards": []} + assert response.data == {"cards": [{"key": "grant", "components": []}]} @override_settings(PLAIN_INTEGRATION_TOKEN="secret") diff --git a/backend/integrations/views.py b/backend/integrations/views.py index 168b35ec8e..65756f127c 100644 --- a/backend/integrations/views.py +++ b/backend/integrations/views.py @@ -30,11 +30,11 @@ def plain_customer_cards(request): user = User.objects.filter(email=customer_email).first() - if not user: - return Response({"cards": []}) - cards = [] if "grant" in card_keys: - cards.append(create_grant_card(request, user, conference)) + if user: + cards.append(create_grant_card(request, user, conference)) + else: + cards.append({"key": "grant", "components": []}) return Response({"cards": cards}) From e759b0cbae6203185660dfc7f8141c1dae75b744 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 17:28:01 +0000 Subject: [PATCH 2/2] refactor: move user existence check into create_grant_card Each card function now handles its own requirements internally, keeping the view layer clean and making it easier to add new cards. Co-authored-by: Marco Acierno --- backend/integrations/plain_cards.py | 6 +++++- backend/integrations/views.py | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/integrations/plain_cards.py b/backend/integrations/plain_cards.py index 4c1cc7527b..84164910ba 100644 --- a/backend/integrations/plain_cards.py +++ b/backend/integrations/plain_cards.py @@ -3,7 +3,11 @@ def create_grant_card(request, user, conference): - grant = Grant.objects.of_user(user).for_conference(conference).first() + grant = ( + Grant.objects.of_user(user).for_conference(conference).first() + if user + else None + ) if not grant: return {"key": "grant", "components": []} diff --git a/backend/integrations/views.py b/backend/integrations/views.py index 65756f127c..9918e336c1 100644 --- a/backend/integrations/views.py +++ b/backend/integrations/views.py @@ -32,9 +32,6 @@ def plain_customer_cards(request): cards = [] if "grant" in card_keys: - if user: - cards.append(create_grant_card(request, user, conference)) - else: - cards.append({"key": "grant", "components": []}) + cards.append(create_grant_card(request, user, conference)) return Response({"cards": cards})