@defra-fish/gafl-webapp-service 1.63.0-rc.0 → 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.0",
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.0",
40
- "@defra-fish/connectors-lib": "1.63.0-rc.0",
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": "127bd6db86a97eb1b229f3de30e27046119ffca6"
82
+ "gitHead": "da12968d3b29944a03d9b29f69617d15f4a89264"
83
83
  }
@@ -102,7 +102,7 @@
102
102
  id: "ref",
103
103
  name: "referenceNumber",
104
104
  type: "text",
105
- classes: "govuk-!-width-one-third",
105
+ classes: "govuk-input--width-10",
106
106
  errorMessage: { text: mssgs.identify_error_empty } if error['referenceNumber'],
107
107
  label: {
108
108
  text: mssgs.identify_label_last_six,
@@ -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({ success: true, paymentId: 'abc123' })
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', { success: true, paymentId: 'abc123' })
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({ success: true, paymentId: 'abc123' })
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', { success: true, paymentId: 'abc123' })
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
- // eslint-disable-next-line camelcase
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)