Skip to content

Commit

Permalink
Merge pull request #3886 from alphagov/pp-12853-amendments-for-axios-…
Browse files Browse the repository at this point in the history
…plus-proxya-agent

PP-12853 Add the charset in Content-Type header for Apple Pay
  • Loading branch information
marcotranchino authored Aug 2, 2024
2 parents ee386b6 + c3cc7fe commit ca77f53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ module.exports = async (req, res) => {
}

const alternativeOptions = {
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json; charset=utf-8' },
httpsAgent: proxyAgent
}

try {
const response = await axios.post(url, data, alternativeOptions)

logger.info('Apple Pay session successfully generated via axios')
logger.info('Apple Pay session successfully generated via axios and https proxy agent')
res.status(200).send(response.data)
} catch (error) {
logger.info('Error generating Apple Pay session', {
...getLoggingFields(req),
error: error.message
error: error.message,
status: error.response ? error.response.status : 'No status'
})
logger.info('Apple Pay session via axios and https proxy agent failed', 'Apple Pay Error')
res.status(500).send('Apple Pay Error')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Validate with Apple the merchant is legitimate', () => {
initiativeContext: merchantDomain
}),
sinon.match({
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json; charset=utf-8' },
httpsAgent: sinon.match.instanceOf(HttpsProxyAgent)
})
)
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('Validate with Apple the merchant is legitimate', () => {
initiativeContext: merchantDomain
}),
sinon.match({
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json; charset=utf-8' },
httpsAgent: sinon.match.instanceOf(HttpsProxyAgent)
})
)
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('Validate with Apple the merchant is legitimate', () => {
initiativeContext: merchantDomain
}),
sinon.match({
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json; charset=utf-8' },
httpsAgent: sinon.match.instanceOf(HttpsProxyAgent)
})
)
Expand Down

0 comments on commit ca77f53

Please sign in to comment.