Skip to content

feat: add POST /webhook-endpoint/send-test for test API keys - #62

Merged
thedevyashsaini merged 1 commit into
feat/standard-webhooksfrom
feat/test-webhook-endpoint
May 29, 2026
Merged

feat: add POST /webhook-endpoint/send-test for test API keys#62
thedevyashsaini merged 1 commit into
feat/standard-webhooksfrom
feat/test-webhook-endpoint

Conversation

@thedevyashsaini

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b7b4d4e2-f5ec-4ad2-a499-81bbde940529

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/test-webhook-endpoint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

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 new internal HTTP endpoint, POST /api/v1/internals/webhook-endpoint/send-test, that lets holders of a test-mode API key trigger a synthetic payment.succeeded webhook delivery to their configured endpoint. This mirrors the production webhook-forwarding path used by createdCheckout.ts, providing a self-service way to verify webhook receivers without performing a real test checkout.

Changes:

  • New handleSendTestWebhook handler that authenticates the caller, enforces auth.role === "test", verifies a configured webhook endpoint exists, and invokes forwardWebhook with a synthetic payment.succeeded event.
  • Registers the new route in registerApiRoutes under the existing /api/v1/internals/webhook-endpoint/... namespace.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/routes/http/api/webhookEndpoints.ts Adds handleSendTestWebhook handler that sends a synthetic test webhook event for test API keys.
src/routes/http/api/registerApiRoutes.ts Wires the new POST /api/v1/internals/webhook-endpoint/send-test route to the new handler.

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

Comment on lines +246 to +273
const endpoint = await getWebhookEndpointByApiKeyId(auth.apiKeyId);

if (!endpoint) {
builder.setError(404, {
type: "NotFoundError",
message: "No webhook endpoint configured for this API key",
});
reply.code(404);
return { error: "No webhook endpoint configured for this API key" };
}

const now = DateTime.utc();

await forwardWebhook(auth.apiKeyId, {
eventType: "payment.succeeded",
resource: "payment",
action: "succeeded",
data: {
paymentId: "test_pay_000000000000000000000",
checkoutSessionId: "test_cks_0000000000000000000",
userId: "test-user-00000000-0000-0000-0000-000000000000",
amount: 1000,
currency: "usd",
mode: "test",
billed_upto: now.toISO(),
createdAt: now.toISO(),
},
});
@thedevyashsaini
thedevyashsaini merged commit d8c082b into feat/standard-webhooks May 29, 2026
3 checks passed
@SteakFisher
SteakFisher deleted the feat/test-webhook-endpoint branch June 6, 2026 18:36
@SteakFisher
SteakFisher restored the feat/test-webhook-endpoint branch June 6, 2026 18:36
@SteakFisher
SteakFisher deleted the feat/test-webhook-endpoint branch June 8, 2026 16:31
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.

2 participants