feat: add Stripe Terminal SDK integration and on-site POS#54
feat: add Stripe Terminal SDK integration and on-site POS#54JacobCoffee merged 2 commits intomainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds a staff-facing Stripe Terminal Point-of-Sale flow to the registration system, including a new terminal payment model, JSON API endpoints for the POS workflow, and a manage UI page for on-site payments.
Changes:
- Introduces
TerminalPaymentmodel and addsTERMINALtoPayment.Method. - Adds Stripe Terminal support in
StripeClientand new staff-only JSON endpoints (views_terminal.py) + URL wiring. - Adds manage UI page (
terminal_pos.html) and navigation entry, plus tests covering the new model/endpoints/manage view.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_registration/test_terminal.py | New tests for terminal model, API endpoints (mocked Stripe), and manage POS view permissions/context. |
| src/django_program/registration/views_terminal.py | Implements staff-only JSON endpoints for connection tokens, intents, capture/cancel, attendee lookup, inventory, cart ops, and reader listing. |
| src/django_program/registration/views_checkin.py | Small refactor/formatting change in JSON parsing helper and a long line wrap. |
| src/django_program/registration/urls.py | Wires up new terminal JSON endpoints under the registration app. |
| src/django_program/registration/terminal.py | Adds TerminalPayment model to store terminal-specific metadata/lifecycle. |
| src/django_program/registration/stripe_client.py | Adds Stripe Terminal wrapper methods (connection token, list readers, create/process intents, cancel action). |
| src/django_program/registration/models.py | Adds TERMINAL payment method choice and exports TerminalPayment. |
| src/django_program/registration/migrations/0018_alter_payment_method_terminalpayment.py | Migration to add Terminal payment method choice and create TerminalPayment table. |
| src/django_program/registration/admin.py | Adds read-only admin for TerminalPayment. |
| src/django_program/manage/views_terminal.py | Adds manage TerminalPOSView rendering the POS template. |
| src/django_program/manage/urls.py | Adds manage route for the terminal POS page. |
| src/django_program/manage/templates/django_program/manage/terminal_pos.html | Adds POS UI (layout + Stripe Terminal JS integration + client-side flow). |
| src/django_program/manage/templates/django_program/manage/base.html | Adds sidebar nav entry for “Terminal POS”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Implements Phase 18: Stripe Terminal for in-person card payments at the registration desk with pre-authorization capture flow, attendee lookup, inventory fetching, cart operations, and a full POS UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d validation - Sanitize Stripe error responses to generic message (no info leak) - Fix except syntax to tuple form throughout views_terminal.py - Remove double amount conversion in create_terminal_payment_intent - Add client_secret to create-intent response - Add ValueError handler to CancelPaymentView - Validate quantity as integer in cart operations - Fix terminal POS UI: attendee/inventory response shapes, price format, cart payload keys, chargeCard reader_id, CSRF token seeding - Extract _add_cart_item helper to reduce complexity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0f63d3c to
f214bdb
Compare
| try: | ||
| client = StripeClient(self.conference) | ||
| except ValueError as exc: | ||
| return JsonResponse({"error": str(exc)}, status=400) |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 29 days ago
In general, to fix information exposure through exceptions, you should avoid returning raw exception messages or stack traces to the client. Instead, log the exception (including stack trace) on the server for debugging, and send the client a generic, non-sensitive error message (optionally with a stable error code) so that behavior is preserved without leaking internal details.
Here, the problematic code is in src/django_program/registration/views_terminal.py inside the post method shown, specifically the except ValueError as exc: block at lines 348–351. The fix is to change this block so that it logs the exception (using the already-configured logger in this module) and returns a generic error string. To avoid changing existing functionality more than necessary, we keep the HTTP status code 400 (client error) and still indicate a configuration failure in a generic way, e.g. "Stripe configuration error" or "Unable to initialize Stripe client", while not including str(exc) in the response. We can also include the exception and, optionally, stack information in the log via logger.exception, which uses the existing logger import and definition at the top of the file, so no new imports are needed.
Concretely:
- Edit the
except ValueError as exc:block so that:- It calls
logger.exception("Failed to initialize Stripe client")(or similar), passingexcfor context. - It returns
JsonResponse({"error": "Unable to initialize Stripe client"}, status=400)(or a similarly generic message).
- It calls
- No changes are needed elsewhere in this file for this fix.
| @@ -348,7 +348,8 @@ | ||
| try: | ||
| client = StripeClient(self.conference) | ||
| except ValueError as exc: | ||
| return JsonResponse({"error": str(exc)}, status=400) | ||
| logger.exception("Failed to initialize Stripe client", exc_info=exc) | ||
| return JsonResponse({"error": "Unable to initialize Stripe client"}, status=400) | ||
|
|
||
| try: | ||
| if reader_id: |
Summary
Design notes
capture_method=manual→ dispatch to reader → cardholder taps → capture after confirmationchange_conferenceperm)Test plan
tests/test_registration/test_terminal.py)make ci)🤖 Generated with Claude Code