Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete data from interface interactions #84

Merged
merged 6 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ before_deploy:
after_deploy:
- docker logout

addons:
apt:
packages:
- libgconf-2-4

deploy:
- provider: script
script: bash ./travis-build.sh "$TEST_DIR"
on:
tags: true
condition: $TRAVIS_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+
condition: $TRAVIS_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const adyenRequest = JSON.parse(interfaceInteractionFields.request)
const adyenRequestBody = JSON.parse(interfaceInteractionFields.request)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
10 changes: 0 additions & 10 deletions notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ Adyen sends notifications which look like this:
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"expiryDate": "12\/2012",
" NAME1 ": "VALUE1",
"authCode": "1234",
"cardSummary": "7777",
"totalFraudScore": "10",
"NAME2": " VALUE2 ",
"fraudCheck-6-ShopperIpUsage": "10"
},
"amount": {
"currency": "EUR",
"value": 10100
Expand All @@ -44,7 +35,6 @@ Adyen sends notifications which look like this:
],
"paymentMethod": "visa",
"pspReference": "test_AUTHORISATION_1",
"reason": "1234:7777:12\/2012",
"success": "true"
}
}
Expand Down
3 changes: 3 additions & 0 deletions notification/src/handler/notification/notification.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ function calculateUpdateActionsForPayment (payment, notification) {
}

function getAddInterfaceInteractionUpdateAction (notification) {
delete notification.additionalData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// strip away sensitive data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete notification.reason

return {
action: 'addInterfaceInteraction',
type: {
Expand Down
10 changes: 0 additions & 10 deletions notification/test/resources/notification.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"expiryDate": "12\/2012",
" NAME1 ": "VALUE1",
"authCode": "1234",
"cardSummary": "7777",
"totalFraudScore": "10",
"NAME2": " VALUE2 ",
"fraudCheck-6-ShopperIpUsage": "10"
},
"amount": {
"currency": "EUR",
"value": 10100
Expand All @@ -27,7 +18,6 @@
],
"paymentMethod": "visa",
"pspReference": "test_AUTHORISATION_1",
"reason": "1234:7777:12\/2012",
"success": "true"
}
}
Expand Down