-
-
Notifications
You must be signed in to change notification settings - Fork 3
Harden Stripe webhook setup: same-URL cleanup, atomic credentials, shared URL helper #1827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3f8b639
Harden Stripe webhook setup: same-URL cleanup, atomic credentials, sh…
stefan-burke 770d703
Create webhook endpoint before deleting strays (review fix)
stefan-burke 19d92be
Fix typecheck: rename recordedListing to recordedInListing in setupWi…
stefan-burke 000d015
Record webhook-setup review follow-ups in TODO.md; drop unused export
stefan-burke 39ba0e3
Merge origin/main; defer stray deletion until after DB save + endpoin…
stefan-burke fbb879b
Add coverage for stripe.ts new paths: delete catch, limit-error branc…
stefan-burke 0b45fac
Make create-throws tests actually throw from fetch; remove untestable…
stefan-burke 1e04758
Fix createThrowsMaximum: use 400 Response instead of throwing
stefan-burke 6a77f71
Merge remote-tracking branch 'origin/main' into split/stripe-webhook-…
stefan-burke 9b7cf87
Preserve strays in cap-recovery, delete old recorded endpoint by ID, …
stefan-burke 1399189
Fix 4 review threads: stub cleanup in settings tests, remove dead exp…
stefan-burke 929ecdb
Merge remote-tracking branch 'origin/main' into split/stripe-webhook-…
stefan-burke 7072294
Fix typecheck: restore requireCreatedBody export and createThrowsNonE…
stefan-burke 92b8829
Fix settings test failures: read snapshot instead of invalidating cache
stefan-burke 709a666
Fix coverage gaps: remove concurrent-race guard, simplify isEndpointL…
stefan-burke 54f8880
Fix remaining coverage: simplify isEndpointLimitError, add GET-withou…
stefan-burke 1123749
Add POST-without-body test to cover init?.body ?? '' default branch
stefan-burke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * One home for the payment webhook URL: the route Stripe/Square/SumUp deliver | ||
| * signed payment callbacks to, and the page a customer's browser lands on | ||
| * after a hosted checkout. Replacing a provider's endpoint (or building the URL | ||
| * a webhook signature is verified against) goes through here so every caller | ||
| * reads the same host. | ||
| * | ||
| * The constructor is pure (taking the domain in), leaving the domain lookup to a | ||
| * thin wrapper so the URL shape can be unit-tested without seeding a domain. | ||
| */ | ||
|
|
||
| import { getEffectiveDomain } from "#shared/config.ts"; | ||
|
|
||
| /** The fixed path under the effective domain that receives payment callbacks. */ | ||
| const PAYMENT_WEBHOOK_PATH = "/payment/webhook"; | ||
|
|
||
| /** Build the public payment webhook URL for the given domain. */ | ||
| const paymentWebhookUrl = (domain: string): string => | ||
| `https://${domain}${PAYMENT_WEBHOOK_PATH}`; | ||
|
|
||
| /** Build the payment webhook URL from the current effective domain. */ | ||
| export const getPaymentWebhookUrl = (): string => | ||
| paymentWebhookUrl(getEffectiveDomain()); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the Stripe settings helper already called out,
test/lib/server-settings/sensitive-field-masking.test.tsalso stubs onlystripeApi.setupWebhookEndpointbefore posting this route. With this new cleanup call, that masking test now falls through to the real Stripe client using fake keys such assk_test_real_secret; the list call is swallowed but still performs live network work and can hang or vary by environment, so this helper also needs to stubstripeApi.cleanupOldWebhookEndpoints.Useful? React with 👍 / 👎.