This week is dedicated to high-risk integration paths in ecommerce. Students learn secure patterns for Stripe integration, authorization flows, webhooks, idempotency, and signature or authorization awareness.
Cover client-to-server payment lifecycle, key separation, and safe handling of payment status transitions. Emphasize server-confirmed source of truth over client assumptions.
Teach that authentication answers "who are you" while authorization answers "are you allowed." Every account, order, or payment endpoint should validate ownership and role constraints.
Webhooks are inbound privileged messages. Validate provider signatures, reject unsigned or stale payloads, and isolate parsing from business side effects.
External systems retry. Handlers must be safe under repeated delivery. Store idempotency keys or event IDs to ensure repeated calls do not duplicate side effects.
Distinguish authenticity from permissions. A valid webhook signature proves source authenticity, not business authorization. Internal endpoints still need explicit permission checks.
1. Read raw body exactly as required by provider SDK.
2. Verify signature with provider secret.
3. Reject invalid signatures with a safe error response.
4. Check event age tolerance to reduce replay risk.
5. Enforce idempotency using event ID or request key.
6. Route only supported event types.
7. Log event metadata (not secrets or full payloads).
8. Return deterministic status for retry behavior.
Harden one integration-sensitive API path and submit a security checklist with threat notes and verification steps.