Repository navigation
feat: chargeback management, merchant risk tiering, fraud tests & query index analysis - #1315
Merged
github-actions[bot] merged 1 commit intoOct 20, 2026
Conversation
…and query index analysis Closes Smartdevs17#926, Smartdevs17#927, Smartdevs17#928, Smartdevs17#739
|
@susanyusuf is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@susanyusuf Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
SagaciousBoss
added a commit
to SagaciousBoss/agenticpay
that referenced
this pull request
Oct 20, 2026
Resolves the conflicts that accumulated after Smartdevs17#1290 and Smartdevs17#1292 merged and subsequent PRs (Smartdevs17#1313, Smartdevs17#1314, Smartdevs17#1315 and others) landed on main: - backend/src/index.ts: keep main's payouts mount alongside the newer retry/batch worker startup lines. - backend/src/routes/payouts.ts: take main's version (it already contains the requireId(batchId) fixes from Smartdevs17#1292 plus later batching work). - backend/src/services/payouts/payout-engine.ts: take main's version (it already contains the awaited materialiseBatch fix plus later additions). - docs/PAYMENT_CORRECTNESS.md, docs/PAYOUT_RELIABILITY.md, docs/security/payment-security.md, docs/README.md: take main's versions, which include the three documents and their index entries from Smartdevs17#1290. Verified: the merged tree is identical to origin/main, so this branch's contribution is fully contained in main and no work was dropped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements the four issues assigned to me. Each feature follows the existing backend conventions (in-memory services + Express routers registered on the
/api/v1router, Zod validation,AppError/asyncHandlererror handling, Vitest coverage).This PR targets
main.Issues
Closes #926
Closes #927
Closes #928
Closes #739
What changed
#926 — Chargeback management with evidence submission
backend/src/services/chargebacks.ts: full chargeback lifecycle (received → under_review → evidence_required → evidence_submitted → representment → won/lost/accepted) with enforced transitions, evidence submission against a deadline, evidence removal, notes, an append-only timeline, and aggregate metrics (disputed/recovered amount, win rate).backend/src/routes/chargebacks.tsexposingPOST/GET /chargebacks,GET /chargebacks/:id,PATCH /chargebacks/:id/status,POST/DELETE .../evidence,POST .../notes, andGET /chargebacks/summary.backend/src/services/__tests__/chargebacks.test.tscovering success and failure paths (invalid transitions, deadline expiry via fake timers, closed cases, summaries).#927 — Fraud detection engine with ML scoring
backend/src/services/fraud-detection.ts) and route already existed but had no tests. Addedbackend/src/services/__tests__/fraud-detection.test.tscovering feature engineering, bounded scoring, allow/review/block paths, the review queue, threshold updates/reset, model training, adversarial probe, and defensive copies.#928 — Merchant onboarding with risk tiering
backend/src/services/merchant-risk-tiering.ts: deterministic0..100risk scoring over business/financial/compliance signals, tier assignment (low/medium/high/critical), tier policies (transaction/daily limits, payout hold, manual review, required checks), re-scoring, and per-transaction limit evaluation.backend/src/routes/merchant-risk.tsexposing assess/reassess, policy lookup, listing, retrieval, and transaction-limit evaluation endpoints.backend/src/services/__tests__/merchant-risk-tiering.test.ts.#739 — Database query optimization with index analysis
backend/src/services/query-optimization.ts: pure helpers to fingerprint SQL, extract tables/predicate/order-by columns, recommend composite indexes, detect likely full-table scans, and consolidate recommendations by table.POST /api/v1/database/analyse-queriestobackend/src/routes/database.tsto analyse observed SQL end-to-end.backend/src/services/query-optimization.test.tsandbackend/src/middleware/__tests__/queryLogger.test.ts(adds coverage for the existing slow-query logger/profiler).Documentation
docs/CHARGEBACK_MANAGEMENT.mdanddocs/MERCHANT_RISK_TIERING.md, and linked both fromdocs/README.md.Testing notes
No dependencies were installed in the environment used to prepare this branch; changes were written to match the repository's existing patterns (
tsconfigNodeNext.jsimport extensions, strict mode, ESLint rules). The added Vitest suites are run by CI via the changed-test-file step. You can run them locally with:Checklist
schema.prisma/migrations, so the migrations workflow is unaffectedbackend/src/index.ts