@defra-fish/connectors-lib 1.59.0-rc.8 → 1.59.0-rc.processRP
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/connectors-lib",
|
|
3
|
-
"version": "1.59.0-rc.
|
|
3
|
+
"version": "1.59.0-rc.processRP",
|
|
4
4
|
"description": "Shared connectors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -40,6 +40,5 @@
|
|
|
40
40
|
"ioredis": "^4.28.5",
|
|
41
41
|
"node-fetch": "^2.6.7",
|
|
42
42
|
"redlock": "^4.2.0"
|
|
43
|
-
}
|
|
44
|
-
"gitHead": "7b7ed5b4ba22c0fdf406fb206649a312b3ab72e0"
|
|
43
|
+
}
|
|
45
44
|
}
|
|
@@ -656,4 +656,43 @@ describe('sales-api-connector', () => {
|
|
|
656
656
|
})
|
|
657
657
|
})
|
|
658
658
|
})
|
|
659
|
+
|
|
660
|
+
describe('processRPResult', () => {
|
|
661
|
+
it('calls the endpoint and returns the expected response', async () => {
|
|
662
|
+
const transactionId = 'transaction-id'
|
|
663
|
+
const paymentId = 'payment-id'
|
|
664
|
+
const createdDate = '2025-01-01T00:00:00.000Z'
|
|
665
|
+
const expectedResponse = { transactionId, paymentId, createdDate }
|
|
666
|
+
fetch.mockReturnValue({
|
|
667
|
+
ok: true,
|
|
668
|
+
status: 200,
|
|
669
|
+
statusText: 'OK',
|
|
670
|
+
text: async () => JSON.stringify(expectedResponse)
|
|
671
|
+
})
|
|
672
|
+
await expect(salesApi.processRPResult('transaction-id', 'payment-id', '2025-01-01T00:00:00.000Z')).resolves.toEqual(expectedResponse)
|
|
673
|
+
expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/processRPResult/transaction-id/payment-id/2025-01-01T00:00:00.000Z', {
|
|
674
|
+
method: 'get',
|
|
675
|
+
headers: expect.any(Object),
|
|
676
|
+
timeout: 20000
|
|
677
|
+
})
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it('throws an error on non-2xx response', async () => {
|
|
681
|
+
fetch.mockReturnValue({
|
|
682
|
+
ok: false,
|
|
683
|
+
status: 500,
|
|
684
|
+
statusText: 'Internal Server Error',
|
|
685
|
+
text: async () => 'Server Error'
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
await expect(salesApi.processRPResult('transaction-id', 'payment-id', '2025-01-01T00:00:00.000Z')).rejects.toThrow(
|
|
689
|
+
'Internal Server Error'
|
|
690
|
+
)
|
|
691
|
+
expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/processRPResult/transaction-id/payment-id/2025-01-01T00:00:00.000Z', {
|
|
692
|
+
method: 'get',
|
|
693
|
+
headers: expect.any(Object),
|
|
694
|
+
timeout: 20000
|
|
695
|
+
})
|
|
696
|
+
})
|
|
697
|
+
})
|
|
659
698
|
})
|
|
@@ -295,3 +295,16 @@ export const getDueRecurringPayments = async date => exec2xxOrThrow(call(new URL
|
|
|
295
295
|
*/
|
|
296
296
|
export const preparePermissionDataForRenewal = async referenceNumber =>
|
|
297
297
|
exec2xxOrThrow(call(new URL(`/permissionRenewalData/${referenceNumber}`, urlBase), 'get'))
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Process a recurring payment result
|
|
301
|
+
*
|
|
302
|
+
* @param transactionId
|
|
303
|
+
* @param paymentId
|
|
304
|
+
* @param createdDate
|
|
305
|
+
* @returns {Promise<*>}
|
|
306
|
+
* @throws on a non-2xx response
|
|
307
|
+
*/
|
|
308
|
+
export const processRPResult = async (transactionId, paymentId, createdDate) => {
|
|
309
|
+
return exec2xxOrThrow(call(new URL(`/processRPResult/${transactionId}/${paymentId}/${createdDate}`, urlBase), 'get'))
|
|
310
|
+
}
|