Skip to content

feat(backend): soft delete expired incoming payments with no funds#3940

Merged
takundachirema merged 8 commits into
mainfrom
takunda/raf-1224
Jun 22, 2026
Merged

feat(backend): soft delete expired incoming payments with no funds#3940
takundachirema merged 8 commits into
mainfrom
takunda/raf-1224

Conversation

@takundachirema

@takundachirema takundachirema commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request

  • Add deletedAt to the incoming payments model
  • In the IncomingPaymentService.handleExpired method, set deletedAt field instead of deleting the record and set the state to expired and processAt to null so that it is not processed by another worker.
  • Updated IncomingPaymentData type so that IncomingPaymentEvents have all metadata for WebHook

Context

Fixes RAF-1224

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Make sure that all checks pass
  • Bruno collection updated (if necessary)
  • Documentation issue created with user-docs label (if necessary)
  • OpenAPI specs updated (if necessary)

@github-actions github-actions Bot added type: tests Testing related pkg: backend Changes in the backend package. type: source Changes business logic labels Jun 10, 2026
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

🚀 Performance Test Results

Test Configuration:

  • VUs: 4
  • Duration: 1m0s

Test Metrics:

  • Requests/s: 45.63
  • Iterations/s: 15.22
  • Failed Requests: 0.00% (0 of 2747)
📜 Logs

> performance@1.0.0 run-tests:testenv /home/runner/work/rafiki/rafiki/test/performance
> ./scripts/run-tests.sh -e test -k -q --vus 4 --duration 1m

Cloud Nine GraphQL API is up: http://localhost:3101/graphql
Cloud Nine Wallet Address is up: http://localhost:3100/
Happy Life Bank Address is up: http://localhost:4100/
cloud-nine-wallet-test-backend already set
cloud-nine-wallet-test-auth already set
happy-life-bank-test-backend already set
happy-life-bank-test-auth already set
     data_received..................: 991 kB 17 kB/s
     data_sent......................: 2.1 MB 35 kB/s
     http_req_blocked...............: avg=7.62µs   min=1.86µs   med=5.54µs   max=1.31ms   p(90)=6.87µs   p(95)=7.66µs  
     http_req_connecting............: avg=219ns    min=0s       med=0s       max=135.19µs p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=86.96ms  min=6.42ms   med=71.27ms  max=410.1ms  p(90)=150.3ms  p(95)=174.21ms
       { expected_response:true }...: avg=86.96ms  min=6.42ms   med=71.27ms  max=410.1ms  p(90)=150.3ms  p(95)=174.21ms
     http_req_failed................: 0.00%  ✓ 0         ✗ 2747
     http_req_receiving.............: avg=106.67µs min=22.88µs  med=88.57µs  max=2.75ms   p(90)=134.07µs p(95)=183.76µs
     http_req_sending...............: avg=42.39µs  min=8.86µs   med=25.9µs   max=2.89ms   p(90)=46.32µs  p(95)=74.8µs  
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=86.81ms  min=6.27ms   med=71.14ms  max=409.99ms p(90)=150.15ms p(95)=174.12ms
     http_reqs......................: 2747   45.630187/s
     iteration_duration.............: avg=262.54ms min=175.02ms med=249.18ms max=867.98ms p(90)=328.19ms p(95)=359.06ms
     iterations.....................: 916    15.215599/s
     vus............................: 4      min=4       max=4 
     vus_max........................: 4      min=4       max=4 

@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit 7955b68
🔍 Latest deploy log https://app.netlify.com/projects/brilliant-pasca-3e80ec/deploys/6a29255a373a870008731219

@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit 6c448e6
🔍 Latest deploy log https://app.netlify.com/projects/brilliant-pasca-3e80ec/deploys/6a32f863eec1ba00099f96cd

updated soft delete tests to check getPage does not return deleted records

updated handleExpired to set processAt to null so that it is not processed further
@takundachirema takundachirema requested a review from mkurapov June 10, 2026 10:54
Comment thread packages/backend/src/open_payments/payment/incoming/service.ts Outdated

@mkurapov mkurapov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just two comments

const { filter, pagination, sortOrder, tenantId, walletAddressId, client } =
options ?? {}
const query = IncomingPayment.query(deps.knex)
const query = IncomingPayment.query(deps.knex).whereNull('deletedAt')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a small test case for this in the getPage -> filters test section

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added a getPage test to the 'Soft deletes an expired incoming payment with no money' test case, starting on line 817. Would you like me to put that in getPage -> filters test section instead, or I can add another test?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should have these tests a bit more self-contained and scoped to a particular function in the future, e.g. describe('complete incoming payment') -> test('returns error for deleted incoming payment') but this is sufficient and is testing everything that we want

Comment thread packages/backend/src/open_payments/payment/incoming/service.ts
@takundachirema takundachirema merged commit 7f9c32d into main Jun 22, 2026
67 of 107 checks passed
@takundachirema takundachirema deleted the takunda/raf-1224 branch June 22, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: backend Changes in the backend package. type: source Changes business logic type: tests Testing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants