Skip to content

Commit

Permalink
Only store request body without header (which has adyen token in it)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetoz committed Nov 19, 2019
1 parent f2755b3 commit 7cc6018
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion extension/src/paymentHandler/payment-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function createAddInterfaceInteractionAction (
fields: {
createdAt: new Date(),
response: JSON.stringify(response),
request: JSON.stringify(request),
request: JSON.stringify(request.body),
type,
status
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Cancel or refund', () => {

const interfaceInteractionFields = updatedPayment.interfaceInteractions[1].fields
const adyenRequest = JSON.parse(interfaceInteractionFields.request)
const adyenRequestBody = JSON.parse(adyenRequest.body)
const adyenRequestBody = JSON.parse(adyenRequest)
expect(adyenRequestBody.originalReference).to.equal(chargeTransaction.interactionId)

const adyenResponse = JSON.parse(interfaceInteractionFields.response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ describe('credit card payment', () => {
const response = await ctpClient.create(ctpClient.builder.payments, JSON.parse(paymentDraft))
expect(response.statusCode).to.equal(201)
const adyenRequest = JSON.parse(response.body.interfaceInteractions[0].fields.request)
expect(adyenRequest.headers['x-api-key']).to.be.equal(process.env.ADYEN_API_KEY)

const adyenRequestBody = JSON.parse(adyenRequest.body)
const adyenRequestBody = JSON.parse(adyenRequest)
expect(adyenRequestBody.merchantAccount).to.be.equal(process.env.ADYEN_MERCHANT_ACCOUNT)
expect(adyenRequestBody.reference).to.be.equal(paymentTemplate.custom.fields.merchantReference)
expect(adyenRequestBody.returnUrl).to.be.equal(paymentTemplate.custom.fields.returnUrl)
Expand Down Expand Up @@ -71,9 +70,8 @@ describe('credit card payment', () => {

const response = await ctpClient.create(ctpClient.builder.payments, JSON.parse(paymentDraft))
const adyenRequest = JSON.parse(response.body.interfaceInteractions[0].fields.request)
expect(adyenRequest.headers['x-api-key']).to.be.equal(process.env.ADYEN_API_KEY)

const adyenRequestBody = JSON.parse(adyenRequest.body)
const adyenRequestBody = JSON.parse(adyenRequest)
expect(adyenRequestBody.merchantAccount).to.be.equal(process.env.ADYEN_MERCHANT_ACCOUNT)
expect(adyenRequestBody.reference).to.be.equal(paymentTemplate.custom.fields.merchantReference)
expect(adyenRequestBody.returnUrl).to.be.equal(`${process.env.API_EXTENSION_BASE_URL}/test-return-url`)
Expand Down Expand Up @@ -110,9 +108,8 @@ describe('credit card payment', () => {
expect(ctpPayment.interfaceInteractions[0].fields.status).to.equal(c.FAILURE)

const adyenRequest = JSON.parse(ctpPayment.interfaceInteractions[0].fields.request)
expect(adyenRequest.headers['x-api-key']).to.be.equal(process.env.ADYEN_API_KEY)

const adyenRequestBody = JSON.parse(adyenRequest.body)
const adyenRequestBody = JSON.parse(adyenRequest)
expect(adyenRequestBody.merchantAccount).to.be.equal(process.env.ADYEN_MERCHANT_ACCOUNT)
expect(adyenRequestBody.returnUrl).to.be.equal(paymentTemplate.custom.fields.returnUrl)
expect(adyenRequestBody.amount.currency).to.be.equal(paymentTemplate.transactions[0].amount.currencyCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ describe('fetch payment', () => {
const interfaceInteractionFields = response.body.interfaceInteractions[0].fields
expect(interfaceInteractionFields.type).to.be.equal('getAvailablePaymentMethods')
const adyenRequest = JSON.parse(interfaceInteractionFields.request)
expect(adyenRequest.headers['x-api-key']).to.be.equal(process.env.ADYEN_API_KEY)

const adyenRequestBody = JSON.parse(adyenRequest.body)
const adyenRequestBody = JSON.parse(adyenRequest)
expect(adyenRequestBody.merchantAccount).to.be.equal(process.env.ADYEN_MERCHANT_ACCOUNT)
expect(adyenRequestBody.countryCode).to.be.equal(paymentTemplate.custom.fields.countryCode)
expect(adyenRequestBody.amount.currency).to.be.equal(paymentTemplate.amountPlanned.currencyCode)
Expand Down
2 changes: 0 additions & 2 deletions extension/test/integration/kcp-make-payment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ describe('kcp make payment', () => {
const response = await ctpClient.create(ctpClient.builder.payments, paymentDraft)

expect(response.statusCode).to.equal(201)
const adyenRequest = JSON.parse(response.body.interfaceInteractions[0].fields.request)
expect(adyenRequest.headers['x-api-key']).to.be.equal(process.env.ADYEN_API_KEY)
expect(response.body.custom.fields.redirectMethod).to.equal('GET')
expect(response.body.custom.fields.redirectUrl).to.exist
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ describe('Paypal payment', () => {
const response = await ctpClient.create(ctpClient.builder.payments, paymentDraft)

expect(response.statusCode).to.equal(201)
const adyenRequest = JSON.parse(response.body.interfaceInteractions[0].fields.request)
expect(adyenRequest.headers['x-api-key']).to.be.equal(process.env.ADYEN_API_KEY)
expect(response.body.custom.fields.redirectMethod).to.equal('GET')
expect(response.body.custom.fields.redirectUrl).to.exist
})
Expand Down

0 comments on commit 7cc6018

Please sign in to comment.