Skip to content

Send Discord webhook notification on storefront purchase#236

Open
Copilot wants to merge 7 commits intomainfrom
copilot/hit-discord-webhook-on-purchase
Open

Send Discord webhook notification on storefront purchase#236
Copilot wants to merge 7 commits intomainfrom
copilot/hit-discord-webhook-on-purchase

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

  • Add DISCORD_STORE_WEBHOOK_URL env var to .env.template
  • Load DISCORD_STORE_WEBHOOK_URL in Config class (modules/utils/config.py)
  • Add send_purchase_webhook() helper in modules/storefront/api.py that fires a Discord webhook notification with rich embed (order ID, buyer email, items, total, org name)
  • Call webhook after successful order in both create_order() and clerk_checkout() (non-blocking, error-safe)
  • Add tests for the webhook functionality (4 tests: correct payload, skipped when unconfigured, tolerates HTTP errors, skipped when env var missing)
  • Run linting and verify changes
  • Address code review: read webhook URL from os.environ directly instead of Config(testing=False), use oi.product relationship instead of N+1 get_storefront_product queries
  • Fix bandit B101 security checks: add # nosec B101 to test asserts and configure [tool.bandit] to exclude tests dir

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 11, 2026 10:29
- Add DISCORD_STORE_WEBHOOK_URL to .env.template and Config class
- Add send_purchase_webhook() helper that sends rich Discord embed
- Call webhook after successful purchase in create_order() and clerk_checkout()
- Webhook runs in background thread (non-blocking, error-safe)
- Add tests for webhook behavior

Co-authored-by: benjuntilla <46634820+benjuntilla@users.noreply.github.com>
…p to avoid N+1 queries

Co-authored-by: benjuntilla <46634820+benjuntilla@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Discord webhook for purchase notifications Send Discord webhook notification on storefront purchase Feb 11, 2026
Copilot AI requested a review from benjuntilla February 11, 2026 10:34
@benjuntilla
Copy link
Member

@copilot fix failing bandit security checks

Add # nosec B101 to test assert statements and configure bandit to
exclude tests directory in pyproject.toml.

Co-authored-by: benjuntilla <46634820+benjuntilla@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot fix failing bandit security checks

Fixed in 4b413bb. Added # nosec B101 to all assert statements in tests/test_purchase_webhook.py and configured [tool.bandit] in pyproject.toml to exclude the tests directory. Bandit now passes with 0 issues.

@benjuntilla benjuntilla marked this pull request as ready for review February 11, 2026 21:06
@benjuntilla benjuntilla requested a review from a team as a code owner February 11, 2026 21:06
Copilot AI review requested due to automatic review settings February 11, 2026 21:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a non-blocking Discord webhook notification when a storefront purchase is completed, configured via a new environment variable and covered by unit tests.

Changes:

  • Add DISCORD_STORE_WEBHOOK_URL to .env.template and load it in Config.
  • Implement send_purchase_webhook() in modules/storefront/api.py and invoke it after successful checkout/order creation.
  • Add tests validating webhook payload behavior and error-tolerance; add Bandit config to exclude tests.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
modules/storefront/api.py Adds webhook sender + calls it after successful purchases.
modules/utils/config.py Loads optional DISCORD_STORE_WEBHOOK_URL into config.
.env.template Documents the new webhook URL env var.
tests/test_purchase_webhook.py Introduces tests for webhook behavior using mocks/stubs.
pyproject.toml Adds Bandit configuration to exclude tests/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants