Skip to content

Configure Midtrans notification URL per transaction - #46

Merged
wauputr4 merged 2 commits into
mainfrom
codex/midtrans-notification-forward
Aug 1, 2026
Merged

Configure Midtrans notification URL per transaction#46
wauputr4 merged 2 commits into
mainfrom
codex/midtrans-notification-forward

Conversation

@wauputr4

@wauputr4 wauputr4 commented Aug 1, 2026

Copy link
Copy Markdown
Member

What changed

  • send MIDTRANS_NOTIFICATION_URL as X-Override-Notification on every Snap transaction
  • document direct public API and Cloudflare edge-forwarder deployment modes
  • clarify that only a forwarding gateway may inject X-Notification-Token
  • add production Compose/env wiring and a request-header regression test

Why

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 config
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Midtrans payment transactions can now send notifications to a configurable public callback URL.
    • Notification delivery can target the API directly or use a forwarding service.
  • Documentation
    • Added setup guidance for configuring payment notification URLs in production.
    • Clarified notification token usage and continued signature verification requirements.
  • Configuration
    • Added the payment notification URL setting to deployment and environment examples.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@wauputr4, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1123524a-11bd-4387-929d-2c4faefee84a

📥 Commits

Reviewing files that changed from the base of the PR and between e4d944f and 35f3814.

📒 Files selected for processing (8)
  • README.md
  • backend/README.md
  • backend/cmd/api/main.go
  • backend/cmd/api/main_test.go
  • backend/internal/payment/midtrans_test.go
  • docs/deployment.md
  • docs/deployment_checklist.md
  • docs/release-alpha.md
📝 Walkthrough

Walkthrough

The backend now reads MIDTRANS_NOTIFICATION_URL, passes it to Midtrans Snap transactions, and sends it as X-Override-Notification. Environment examples, production configuration, tests, deployment guidance, and payment documentation were updated.

Changes

Midtrans notification routing

Layer / File(s) Summary
Payment request header support
backend/internal/payment/midtrans.go, backend/internal/payment/midtrans_test.go
SnapRequest accepts NotificationURL. The payment client conditionally sends X-Override-Notification. The test validates the header.
Configuration and API wiring
backend/internal/config/config.go, backend/cmd/api/main.go
Configuration loads MIDTRANS_NOTIFICATION_URL. Snap transaction creation passes the value to SnapRequest.
Deployment and configuration documentation
.env.production.example, backend/.env.example, docker-compose.production.yml, backend/README.md, docs/deployment.md, docs/payment-gateway.md, docs/release-alpha.md
Environment examples, production configuration, deployment guidance, payment gateway guidance, and release notes document the notification URL and supported targets.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: configuring the Midtrans notification URL for each transaction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/midtrans-notification-forward

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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
kebaikanku-landing 35f3814 Aug 01 2026, 10:49 AM

@wauputr4
wauputr4 marked this pull request as ready for review August 1, 2026 10:01

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
backend/internal/payment/midtrans_test.go (1)

22-24: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a regression case for an empty notification URL.

This test covers only the override branch. Add a second request with NotificationURL empty and assert that X-Override-Notification is 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

📥 Commits

Reviewing files that changed from the base of the PR and between cf7f72e and e4d944f.

📒 Files selected for processing (11)
  • .env.production.example
  • backend/.env.example
  • backend/README.md
  • backend/cmd/api/main.go
  • backend/internal/config/config.go
  • backend/internal/payment/midtrans.go
  • backend/internal/payment/midtrans_test.go
  • docker-compose.production.yml
  • docs/deployment.md
  • docs/payment-gateway.md
  • docs/release-alpha.md

Comment thread backend/internal/config/config.go
Comment thread docs/payment-gateway.md
Comment thread docs/release-alpha.md Outdated
@wauputr4

wauputr4 commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: e4d944f1e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@wauputr4
wauputr4 merged commit f38758c into main Aug 1, 2026
7 checks passed
@wauputr4
wauputr4 deleted the codex/midtrans-notification-forward branch August 1, 2026 10:51
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.

1 participant