GithubHelp home page GithubHelp logo

Comments (4)

butenkor avatar butenkor commented on June 4, 2024

Hi @lojzatran. This error is actually caused by extension module and thus prevents notification module from adding the interaction, right?

It might be useful in case of 5xx errors to log whole payment and not just payload with actions, wdyt?

from adyen-commercetools.

lojzatran avatar lojzatran commented on June 4, 2024

I tried the action in impex and got this error back:

{
  "statusCode": 400,
  "message": "The value '{}' is not valid for field 'createdAt'. ",
  "errors": [
    {
      "code": "InvalidField",
      "message": "The value '{}' is not valid for field 'createdAt'. ",
      "action": {
        "action": "addInterfaceInteraction",
        "type": {
          "typeId": "type",
          "key": "ctp-adyen-integration-interaction-notification"
        },
        "fields": {
          "createdAt": {},
          "status": "AUTHORISATION",
          "notification": "{\"NotificationRequestItem\":{\"additionalData\":{\"expiryDate\":\"10/2020\",\"authCode\":\"39697\",\"cardSummary\":\"1142\"},\"amount\":{\"currency\":\"EUR\",\"value\":495},\"eventCode\":\"AUTHORISATION\",\"eventDate\":\"2019-07-03T19:19:30+02:00\",\"merchantAccountCode\":\"CommercetoolsGmbHDE775\",\"merchantReference\":\"paymentReferenceId\",\"operations\":[\"CANCEL\",\"CAPTURE\",\"REFUND\"],\"paymentMethod\":\"visa\",\"pspReference\":\"853562174370815K\",\"reason\":\"39697:1142:10/2020\",\"success\":\"true\"}}"
        }
      },
      "actionIndex": 1,
      "invalidValue": {},
      "field": "createdAt"
    }
  ]
}

In the error above, it is indeed 500 error from extension, but I cannot reproduce this behaviour. However, the root cause here is the empty createdAt, which should not be sent at all. Once we solve it, we can check for other errors.

from adyen-commercetools.

lojzatran avatar lojzatran commented on June 4, 2024

I investigated this error on my local machine and found out the following:

  1. Missing value {} for createdAt is just a log issue. We pass createdAt: new Date() as an action to ctpClient and somehow when we got an error back, this is being displayed as createdAt: {}. This I solved by passing createdAt: new Date().toISOString() instead. So when we create an action from notification module, we pass the correct date value, but the logging for error just displays it wrong.
  2. The real problem lies in extension module. We got this error:
"Unexpected token , in JSON at position 32518\\\",\\\"stack\\\":\\\"SyntaxError: Unexpected token , in JSON at position 32518\\\\n    at JSON.parse (<anonymous>)\\\\n    at _getPaymentObject (/app/src/api/payment/payment.controller.js:53:30)

The error is in this line const requestBody = JSON.parse(body) from this method:

async function _getPaymentObject (request) {
  const body = await httpUtils.collectRequestData(request)
  try {
    const requestBody = JSON.parse(body)
    return requestBody.resource.obj
  } catch (err) {
    throw new Error(`Error during parsing CTP request: '${body}'. Ending the process. `
      + `Error: ${JSON.stringify(serializeError(err))}`)
  }
}

So this means that the request does not contain complete JSON and cannot be parsed. However, when I tested on my local, there was no error. I tried multiple times and they all returned correct results.

from adyen-commercetools.

butenkor avatar butenkor commented on June 4, 2024

It cannot be reproduced anymore.

from adyen-commercetools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.