feat(compliance): merchant account deletion / anonymization (#314)#345
Merged
Pvsaint merged 3 commits intoMetroLogic:mainfrom Mar 30, 2026
Merged
Conversation
…ic#314) Schema: - Add deletion_requested_at, anonymized_at to Merchant - Add MerchantDeletionRequest model (tracks request + execution) - Add AuditActionType: merchant_deletion_requested, merchant_anonymized - Add AuditEntityType: merchant_account - Migration: 20260329143000_merchant_deletion_anonymization Service (merchantDeletion.service.ts): - requestDeletion(): records request, marks merchant, writes audit log - executeDeletion(): anonymizes PII fields, wipes KYC docs, clears webhook URLs, hard-deletes OTPs/bank/subs/customers; retains payments/settlements/refunds/invoices under legal hold - getDeletionRequest(): status polling Routes: - POST /api/v1/merchants/me/deletion-request - GET /api/v1/merchants/me/deletion-request - POST /api/v1/merchants/admin/:id/deletion-request - POST /api/v1/merchants/admin/:id/anonymize Tests: 9 unit tests, all passing - Fix IKMSProvider/KMSFactory type errors (pre-existing) - Fix payment.service uuid ESM issue (crypto.randomUUID) - Add adminUser to AuthRequest type
bd3149e to
fc15f51
Compare
… model and new Merchant fields
|
@rayeberechi 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! 🚀 |
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.
Overview
This PR implements a comprehensive workflow for merchant account closure and data erasure. It balances GDPR 'Right to Be Forgotten' requirements with financial regulatory mandates for data retention, ensuring PII is wiped while transaction integrity is preserved for audit trails.
Core Implementation (#314)
deletion_requested_at). This triggers a 'Pending' state for operational review.merchant_deletion_requestedandmerchant_anonymizedevents into the global audit log, capturing the requester's identity and timestamp.Technical Specification
deletion_requested_atandanonymized_atfields to theMerchantmodel.MerchantDeletionRequestto track the lifecycle of closure requests.$transactionto ensure that either all PII is wiped or none of it is, preventing "partial deletions."merchantDeletion.service.test.tsverify that financial records remain queryable after their associated merchant has been anonymized.Results
Verification
Closes #314