@defra-fish/connectors-lib 1.60.0-rc.2 → 1.60.0-rc.4
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.60.0-rc.
|
|
3
|
+
"version": "1.60.0-rc.4",
|
|
4
4
|
"description": "Shared connectors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"node-fetch": "^2.6.7",
|
|
43
43
|
"redlock": "^4.2.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "0c5c50b668c126c636f7a7a018dc5706e2d74eaf"
|
|
46
46
|
}
|
|
@@ -656,4 +656,54 @@ describe('sales-api-connector', () => {
|
|
|
656
656
|
})
|
|
657
657
|
})
|
|
658
658
|
})
|
|
659
|
+
|
|
660
|
+
describe('processRPResult', () => {
|
|
661
|
+
describe.each([
|
|
662
|
+
['transaction-id', 'payment-id', '2025-01-01T00:00:00.000Z'],
|
|
663
|
+
['abc-123', 'def-456', '2025-02-15T23:49:32.386Z']
|
|
664
|
+
])("Processing payment for transaction id '%s'", (transactionId, paymentId, createdDate) => {
|
|
665
|
+
beforeEach(() => {
|
|
666
|
+
fetch.mockReturnValue({
|
|
667
|
+
ok: true,
|
|
668
|
+
status: 200,
|
|
669
|
+
statusText: 'OK',
|
|
670
|
+
text: async () => JSON.stringify({ transactionId, paymentId, createdDate })
|
|
671
|
+
})
|
|
672
|
+
})
|
|
673
|
+
|
|
674
|
+
it('calls the endpoint with the correct parameters', async () => {
|
|
675
|
+
await salesApi.processRPResult(transactionId, paymentId, createdDate)
|
|
676
|
+
|
|
677
|
+
expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/processRPResult/${transactionId}/${paymentId}/${createdDate}`, {
|
|
678
|
+
method: 'get',
|
|
679
|
+
headers: expect.any(Object),
|
|
680
|
+
timeout: 20000
|
|
681
|
+
})
|
|
682
|
+
})
|
|
683
|
+
|
|
684
|
+
it('returns the expected response data', async () => {
|
|
685
|
+
const processedResult = await salesApi.processRPResult(transactionId, paymentId, createdDate)
|
|
686
|
+
|
|
687
|
+
expect(processedResult).toEqual({ transactionId, paymentId, createdDate })
|
|
688
|
+
})
|
|
689
|
+
})
|
|
690
|
+
|
|
691
|
+
it('throws an error on non-2xx response', async () => {
|
|
692
|
+
fetch.mockReturnValue({
|
|
693
|
+
ok: false,
|
|
694
|
+
status: 500,
|
|
695
|
+
statusText: 'Internal Server Error',
|
|
696
|
+
text: async () => 'Server Error'
|
|
697
|
+
})
|
|
698
|
+
|
|
699
|
+
await expect(salesApi.processRPResult('transaction-id', 'payment-id', '2025-01-01T00:00:00.000Z')).rejects.toThrow(
|
|
700
|
+
'Internal Server Error'
|
|
701
|
+
)
|
|
702
|
+
expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/processRPResult/transaction-id/payment-id/2025-01-01T00:00:00.000Z', {
|
|
703
|
+
method: 'get',
|
|
704
|
+
headers: expect.any(Object),
|
|
705
|
+
timeout: 20000
|
|
706
|
+
})
|
|
707
|
+
})
|
|
708
|
+
})
|
|
659
709
|
})
|
|
@@ -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
|
+
}
|