Skip to content

Commit cda190a

Browse files
test: verify paid opennode callback completes invoice
1 parent c337d7a commit cda190a

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

test/integration/features/callbacks/opennode-callback.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ Feature: OpenNode callback endpoint
1818
When I post a signed OpenNode callback with status "processing"
1919
Then the OpenNode callback response status is 200
2020
And the OpenNode callback response body is empty
21+
22+
Scenario: completes a pending invoice on paid callback
23+
Given OpenNode callback processing is enabled
24+
And a pending OpenNode invoice exists
25+
When I post a signed OpenNode callback with status "paid"
26+
Then the OpenNode callback response status is 200
27+
And the OpenNode callback response body is "OK"
28+
And the OpenNode invoice is marked completed

test/integration/features/callbacks/opennode-callback.feature.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ Then('the OpenNode callback response body is empty', function () {
110110
expect(['', undefined, null]).to.include(response.data)
111111
})
112112

113+
Then('the OpenNode invoice is marked completed', async function () {
114+
const dbClient = getMasterDbClient()
115+
const invoiceId = this.parameters.openNodeInvoiceId
116+
117+
const invoice = await dbClient('invoices')
118+
.where('id', invoiceId)
119+
.first('status', 'confirmed_at', 'amount_paid')
120+
121+
expect(invoice).to.exist
122+
expect(invoice.status).to.equal('completed')
123+
expect(invoice.confirmed_at).to.not.equal(null)
124+
expect(invoice.amount_paid).to.equal('21000')
125+
})
126+
113127
After({ tags: '@opennode-callback' }, async function () {
114128
SettingsStatic._settings = this.parameters.previousOpenNodeCallbackSettings
115129

0 commit comments

Comments
 (0)