@defra-fish/gafl-webapp-service 1.63.0-rc.1 → 1.63.0-rc.2
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/gafl-webapp-service",
|
|
3
|
-
"version": "1.63.0-rc.
|
|
3
|
+
"version": "1.63.0-rc.2",
|
|
4
4
|
"description": "The websales frontend for the GAFL service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"prepare": "gulp --gulpfile build/gulpfile.cjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@defra-fish/business-rules-lib": "1.63.0-rc.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.63.0-rc.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.63.0-rc.2",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.63.0-rc.2",
|
|
41
41
|
"@defra/hapi-gapi": "^2.0.0",
|
|
42
42
|
"@hapi/boom": "^9.1.2",
|
|
43
43
|
"@hapi/catbox-redis": "^6.0.2",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"./gafl-jest-matchers.js"
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "da12968d3b29944a03d9b29f69617d15f4a89264"
|
|
83
83
|
}
|
|
@@ -214,15 +214,17 @@ describe('The govuk-pay-service', () => {
|
|
|
214
214
|
})
|
|
215
215
|
|
|
216
216
|
it('should log debug message when response.ok is true', async () => {
|
|
217
|
+
const expectedLoggedOutput = { success: true, paymentId: 'abc123', bar: Symbol('bar'), baz: Symbol('baz') }
|
|
218
|
+
const resBody = { card_details: { foo: Symbol('foo') }, card_brand: Symbol('foobarbaz'), ...expectedLoggedOutput }
|
|
217
219
|
const mockResponse = {
|
|
218
220
|
ok: true,
|
|
219
|
-
json: jest.fn().mockResolvedValue(
|
|
221
|
+
json: jest.fn().mockResolvedValue(resBody)
|
|
220
222
|
}
|
|
221
223
|
govUkPayApi.createPayment.mockResolvedValue(mockResponse)
|
|
222
224
|
|
|
223
225
|
await sendPayment(preparedPayment)
|
|
224
226
|
|
|
225
|
-
expect(debug).toHaveBeenCalledWith('Successful payment creation response: %o',
|
|
227
|
+
expect(debug).toHaveBeenCalledWith('Successful payment creation response: %o', expectedLoggedOutput)
|
|
226
228
|
})
|
|
227
229
|
|
|
228
230
|
it('should log error message when response.ok is false', async () => {
|
|
@@ -334,15 +336,17 @@ describe('The govuk-pay-service', () => {
|
|
|
334
336
|
})
|
|
335
337
|
|
|
336
338
|
it('should log debug message when response.ok is true', async () => {
|
|
339
|
+
const expectedLoggedOutput = { success: true, paymentId: 'abc123', bar: Symbol('bar'), baz: Symbol('baz') }
|
|
340
|
+
const resBody = { card_details: { foo: Symbol('foo') }, card_brand: Symbol('foobarbaz'), ...expectedLoggedOutput }
|
|
337
341
|
const mockResponse = {
|
|
338
342
|
ok: true,
|
|
339
|
-
json: jest.fn().mockResolvedValue(
|
|
343
|
+
json: jest.fn().mockResolvedValue(resBody)
|
|
340
344
|
}
|
|
341
345
|
govUkPayApi.createRecurringPaymentAgreement.mockResolvedValue(mockResponse)
|
|
342
346
|
|
|
343
347
|
await sendRecurringPayment(preparedPayment)
|
|
344
348
|
|
|
345
|
-
expect(debug).toHaveBeenCalledWith('Successful agreement creation response: %o',
|
|
349
|
+
expect(debug).toHaveBeenCalledWith('Successful agreement creation response: %o', expectedLoggedOutput)
|
|
346
350
|
})
|
|
347
351
|
|
|
348
352
|
it('should log error message when response.ok is false', async () => {
|
|
@@ -60,7 +60,7 @@ export const sendPayment = async (preparedPayment, recurring = false) => {
|
|
|
60
60
|
|
|
61
61
|
if (response.ok) {
|
|
62
62
|
const resBody = await response.json()
|
|
63
|
-
debug('Successful payment creation response: %o', resBody)
|
|
63
|
+
debug('Successful payment creation response: %o', loggableBody(resBody))
|
|
64
64
|
return resBody
|
|
65
65
|
} else {
|
|
66
66
|
const errMsg = await getTransactionErrorMessage(preparedPayment.id, preparedPayment, response)
|
|
@@ -93,9 +93,7 @@ export const getPaymentStatus = async (paymentId, recurring = false) => {
|
|
|
93
93
|
|
|
94
94
|
if (response.ok) {
|
|
95
95
|
const resBody = await response.json()
|
|
96
|
-
|
|
97
|
-
const { card_brand, card_details, ...loggableBody } = resBody
|
|
98
|
-
debug('Payment status response: %o', loggableBody)
|
|
96
|
+
debug('Payment status response: %o', loggableBody(resBody))
|
|
99
97
|
return resBody
|
|
100
98
|
} else {
|
|
101
99
|
const mes = {
|
|
@@ -123,12 +121,18 @@ const createRecurringPaymentAgreement = async preparedPayment => {
|
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
123
|
|
|
124
|
+
const loggableBody = resBody => {
|
|
125
|
+
// eslint-disable-next-line camelcase
|
|
126
|
+
const { card_brand, card_details, ...filteredBody } = resBody
|
|
127
|
+
return filteredBody
|
|
128
|
+
}
|
|
129
|
+
|
|
126
130
|
export const sendRecurringPayment = async preparedPayment => {
|
|
127
131
|
const response = await createRecurringPaymentAgreement(preparedPayment)
|
|
128
132
|
|
|
129
133
|
if (response.ok) {
|
|
130
134
|
const resBody = await response.json()
|
|
131
|
-
debug('Successful agreement creation response: %o', resBody)
|
|
135
|
+
debug('Successful agreement creation response: %o', loggableBody(resBody))
|
|
132
136
|
return resBody
|
|
133
137
|
} else {
|
|
134
138
|
const errMsg = await getTransactionErrorMessage(preparedPayment.reference, preparedPayment, response)
|