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

#52 log the payload received from adyen in case of error #53

Merged
merged 3 commits into from
Apr 23, 2019

Conversation

LEQADA
Copy link
Contributor

@LEQADA LEQADA commented Apr 23, 2019

Resolves #52

Not the log looks like this:

{
  "name": "ctp-adyen-integration-notifications",
  "hostname": "local",
  "pid": 32801,
  "level": 50,
  "adyenRequestBody": "{\r\n  \"live\": \"false\",\r\n  \"notificationItems\": [\r\n    {\r\n      \"NotificationRequestItem\": {\r\n        \"additionalData\": {\r\n          \"expiryDate\": \"12\\/2012,\r\n          \" NAME1 \": \"VALUE1\",\r\n          \"authCode\": \"1234\",\r\n          \"cardSummary\": \"7777\",\r\n          \"totalFraudScore\": \"10\",\r\n          \"NAME2\": \"  VALUE2  \",\r\n          \"fraudCheck-6-ShopperIpUsage\": \"10\"\r\n        },\r\n        \"amount\": {\r\n          \"currency\": \"EUR\",\r\n          \"value\": 10100\r\n        },\r\n        \"eventCode\": \"AUTHORISATION\",\r\n        \"eventDate\": \"2019-01-30T18:16:22+01:00\",\r\n        \"merchantAccountCode\": \"XXX\",\r\n        \"merchantReference\": interfaceIds,\r\n        \"operations\": [\r\n          \"CANCEL\",\r\n          \"CAPTURE\",\r\n          \"REFUND\"\r\n        ],\r\n        \"paymentMethod\": \"visa\",\r\n        \"pspReference\": \"psp_reference\",\r\n        \"reason\": \"1234:7777:12\\/2012\",\r\n        \"success\": \"true\"\r\n      }\r\n    }\r\n  ]\r\n}\r\n",
  "err": {
    "message": "Unexpected token \r in JSON at position 155",
    "name": "SyntaxError",
    "stack": "SyntaxError: Unexpected token \r in JSON at position 155\n    at JSON.parse (<anonymous>)\n    at handleNotification (/app/src/api/notification/notification.controller.js:17:38)\n    at process._tickCallback (internal/process/next_tick.js:178:7)"
  },
  "msg": "Unexpected exception occurred.",
  "time": "2019-04-23T16:33:57.473Z",
  "v": 0
}

@LEQADA LEQADA added the notification Issue related to the notification module label Apr 23, 2019
@LEQADA LEQADA requested a review from butenkor April 23, 2019 15:00
@@ -21,7 +21,8 @@ async function handleNotification (request, response) {
{ 'Content-Type': 'application/json' },
JSON.stringify({ notificationResponse: '[accepted]' }))
} catch (e) {
logger.error(e, 'Unexpected exception occurred')
logger.error(e,
`Unexpected exception occurred. Received payload from Adyen: ${body}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to see body as JSON and not as an escaped JSON text. Did you try:

const customErr = { err, "adyenRequestBody": body}
logger.error({customErr}, "Unexpected exception occurred")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LEQADA LEQADA force-pushed the log-adyen-payload-in-case-of-unexpected-error branch from 5cdc10a to 4c0ee0c Compare April 23, 2019 16:25
@LEQADA LEQADA merged commit 32cef94 into master Apr 23, 2019
@LEQADA LEQADA deleted the log-adyen-payload-in-case-of-unexpected-error branch April 23, 2019 16:53
LEQADA added a commit that referenced this pull request Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notification Issue related to the notification module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log JSON payload if a JSON parsing error occured
2 participants