Skip to content

Commit

Permalink
#63 delete obsolete additionalData from payment response which is s…
Browse files Browse the repository at this point in the history
…tore… (#97)

* delete obsolete `additionalData` from payment response which is stored in interfaceInteractions.fields.

* fix typo exists to exist.
  • Loading branch information
ahmetoz authored Dec 19, 2019
1 parent 77f9cba commit 9228336
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extension/src/paymentHandler/payment-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ function createAddInterfaceInteractionAction (
request, response, type, status
}
) {
// strip away sensitive data
delete response.additionalData

return {
action: 'addInterfaceInteraction',
type: { key: c.CTP_INTERFACE_INTERACTION },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ describe('Cancel or refund', () => {

const adyenResponse = JSON.parse(interfaceInteractionFields.response)
expect(adyenResponse.response).to.equal('[cancelOrRefund-received]')
expect(adyenResponse.additionalData).to.not.exist
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('credit card payment', () => {

const adyenResponse = JSON.parse(response.body.interfaceInteractions[0].fields.response)
expect(adyenResponse.resultCode).to.be.equal('Authorised')
expect(adyenResponse.additionalData).to.not.exist

const { transactions } = response.body
expect(transactions).to.have.lengthOf(1)
Expand Down Expand Up @@ -91,6 +92,7 @@ describe('credit card payment', () => {
expect(adyenResponse.redirect.data.MD).to.exist
expect(adyenResponse.redirect.method).to.exist
expect(adyenResponse.redirect.url).to.exist
expect(adyenResponse.additionalData).to.not.exist
})

it('on wrong credit card number, should log error to interface interaction', async () => {
Expand Down Expand Up @@ -128,6 +130,7 @@ describe('credit card payment', () => {
expect(transaction.interactionId).to.be.undefined
expect(transaction.type).to.equal('Authorization')
expect(transaction.state).to.equal('Initial')
expect(adyenResponse.additionalData).to.not.exist

const response2 = await ctpClient.update(ctpClient.builder.payments,
ctpPayment.id, ctpPayment.version, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ describe('fetch payment', () => {
const adyenResponse = JSON.parse(interfaceInteractionFields.response)
expect(adyenResponse.groups).to.be.an.instanceof(Array)
expect(adyenResponse.paymentMethods).to.be.an.instanceof(Array)
expect(adyenResponse.additionalData).to.not.exist
})
})
5 changes: 5 additions & 0 deletions extension/test/integration/kcp-make-payment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ describe('kcp make payment', () => {
expect(response.statusCode).to.equal(201)
expect(response.body.custom.fields.redirectMethod).to.equal('GET')
expect(response.body.custom.fields.redirectUrl).to.exist

const adyenResponse = JSON.parse(response.body.interfaceInteractions[0].fields.response)
expect(adyenResponse.redirect.method).to.exist
expect(adyenResponse.redirect.url).to.exist
expect(adyenResponse.additionalData).to.not.exist
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ describe('Paypal payment', () => {
expect(response.statusCode).to.equal(201)
expect(response.body.custom.fields.redirectMethod).to.equal('GET')
expect(response.body.custom.fields.redirectUrl).to.exist

const adyenResponse = JSON.parse(response.body.interfaceInteractions[0].fields.response)
expect(adyenResponse.redirect.method).to.exist
expect(adyenResponse.redirect.url).to.exist
expect(adyenResponse.additionalData).to.not.exist
})
})

0 comments on commit 9228336

Please sign in to comment.