Configure Midtrans notification URL per transaction - #46
Conversation
|
Warning Review limit reached
Next review available in: 12 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe backend now reads ChangesMidtrans notification routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Config as Config.Load
participant API as API
participant Payment as CreateSnapTransaction
participant Midtrans as Midtrans Snap API
Config->>API: Load MIDTRANS_NOTIFICATION_URL
API->>Payment: Pass NotificationURL
Payment->>Midtrans: Send X-Override-Notification
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
kebaikanku-landing | 35f3814 | Aug 01 2026, 10:49 AM |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
backend/internal/payment/midtrans_test.go (1)
22-24: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a regression case for an empty notification URL.
This test covers only the override branch. Add a second request with
NotificationURLempty and assert thatX-Override-Notificationis absent. This protects the fallback to the dashboard notification configuration; the override header bypasses that dashboard setting. (docs.midtrans.com)Also applies to: 52-57
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/internal/payment/midtrans_test.go` around lines 22 - 24, Add a regression case in the Midtrans notification request test for an empty NotificationURL, then assert the X-Override-Notification header is absent while preserving the existing override assertion. Ensure this request exercises the dashboard notification fallback rather than sending an override header.Source: MCP tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/internal/config/config.go`:
- Line 71: Validate MIDTRANS_NOTIFICATION_URL during configuration startup by
trimming it, requiring a valid URL with an allowed scheme and host, and
rejecting invalid values before donations can be accepted. When APP_ENV is
production, require the URL scheme to be HTTPS; preserve the validated value for
CreateSnapTransaction to use as X-Override-Notification.
In `@docs/payment-gateway.md`:
- Around line 33-37: Update the MIDTRANS_NOTIFICATION_TOKEN documentation in
backend/README.md to state that it is only supplied by a forwarding edge or
gateway that injects X-Notification-Token, not a general callback-route guard.
Clarify that direct Midtrans callbacks do not provide this header and that the
direct API route should leave the token unset, while preserving the existing
Midtrans signature-verification guidance.
In `@docs/release-alpha.md`:
- Around line 44-45: The sandbox E2E configuration in the release-alpha
instructions must use a reachable public or forwarded Midtrans notification
endpoint instead of the fixed example URL. Document the required tunnel or
forwarding Worker setup, mark MIDTRANS_NOTIFICATION_URL as a value that must be
replaced before running E2E, and retain the local backend URL context.
---
Nitpick comments:
In `@backend/internal/payment/midtrans_test.go`:
- Around line 22-24: Add a regression case in the Midtrans notification request
test for an empty NotificationURL, then assert the X-Override-Notification
header is absent while preserving the existing override assertion. Ensure this
request exercises the dashboard notification fallback rather than sending an
override header.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6a44c4aa-a0f6-4630-a79f-672c6d5a3329
📒 Files selected for processing (11)
.env.production.examplebackend/.env.examplebackend/README.mdbackend/cmd/api/main.gobackend/internal/config/config.gobackend/internal/payment/midtrans.gobackend/internal/payment/midtrans_test.godocker-compose.production.ymldocs/deployment.mddocs/payment-gateway.mddocs/release-alpha.md
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What changed
MIDTRANS_NOTIFICATION_URLasX-Override-Notificationon every Snap transactionX-Notification-TokenWhy
Midtrans supports transaction-specific notification URLs, so operators should not need to configure the Payment Notification URL manually in the Midtrans dashboard. The existing client only configured the browser finish redirect.
Validation
go test -race ./...go vet ./...docker compose --env-file .env.production.example -f docker-compose.production.yml configgit diff --checkSummary by CodeRabbit