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

Creation of AccountHolder from webhook contents fails #1320

Closed
vincenthartsteen opened this issue Jul 10, 2024 · 13 comments
Closed

Creation of AccountHolder from webhook contents fails #1320

vincenthartsteen opened this issue Jul 10, 2024 · 13 comments
Labels

Comments

@vincenthartsteen
Copy link

Describe the bug
Mapping of the accountHolder that is part of e.g. the balancePlatform.accountHolder.updated webhook fails. The status field for that account-holder is Active but that value can't be mapped to the AccountHolder$StatusEnum.

How to reproduce
Create or update an account-holder on the Balance platform. A webhook similar to the following will be sent:

{
  "data": {
    "balancePlatform": "MontroPlatform",
    "accountHolder": {
      "description": "Woe1200",
      "legalEntityId": "LE3293X223225R5KZBDZ99KZ5",
      "reference": "3402",
      "capabilities": {
        "receiveFromPlatformPayments": {
          "enabled": "true",
          "requested": "true",
          "allowed": "false",
          "problems": [
            {
              "entity": {
                "id": "LE3293X223225R5KZBDZ99KZ5",
                "type": "LegalEntity"
              },
              "verificationErrors": [
                {
                  "code": "2_902",
                  "message": "Terms Of Service forms are not accepted.",
                  "remediatingActions": [
                    {
                      "code": "2_902",
                      "message": "Accept TOS"
                    }
                  ],
                  "type": "invalidInput"
                }
              ]
            }
          ],
          "verificationStatus": "pending"
        }
      },
      "id": "AH3294C223227N5KZBDZBBCVG",
      "status": "Active"
    }
  },
  "environment": "test",
  "type": "balancePlatform.accountHolder.updated"
}

From that webhook, get the value for the accountHolder and pass that into AccountHolder.fromJson(...)

Notice that an exception is thrown:

com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `com.adyen.model.balanceplatform.AccountHolder$StatusEnum`, problem: Unexpected value 'Active'
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 35, column: 13] (through reference chain: com.adyen.model.balanceplatform.AccountHolder["status"])

The enum (AccountHolder$StatusEnum) only has values in lowercase. I created a simple test for this and indeed when I change Active to active the method returns an AccountHolder object.

So either the enum should accept the Active or the contents of the webhook should exactly match the values of the enum.

Expected behavior
The AccountHolder.fromJson should return a valid AccountHolder object based on the contents of the webhook.

Screenshots
Error message is shown in previous section.

Desktop (please complete the following information):

  • Kotlin Version: [1.8.22]
  • Library Version: [26.2.0]

Additional context
We are migrating our application from the Bank environment to the Balance platform and are now receiving these webhooks on the TEST environment.

@wboereboom
Copy link
Contributor

Hi @vincenthartsteen ,

Thanks for raising this issue.
The Accountholder you are trying to parse should be part of the configuration notification models. It's a bit more complicated than we would like unfortunately, but please try to deserialize the accountholder to this model instead. That should solve the enum issues.

We will try to provide more webhooks support in the future.

Kind Regards,
Wouter
Adyen

@Arnfinng
Copy link

We are experiencing the same problem. AccountHolderNotificationRequest.fromJson tries to deserialize to an AccountHolder (in the AccountHolderNotificationData), which fails as the status enum is no longer correct as the values we are actually getting are capitalized (e.g. "Active")

Cannot construct instance of com.adyen.model.configurationwebhooks.AccountHolder$StatusEnum, problem: Unexpected value 'Active'
com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of com.adyen.model.configurationwebhooks.AccountHolder$StatusEnum, problem: Unexpected value 'Active'
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 5, column: 17] (through reference chain: com.adyen.model.configurationwebhooks.AccountHolderNotificationRequest["data"]->com.adyen.model.configurationwebhooks.AccountHolderNotificationData["accountHolder"]->com.adyen.model.configurationwebhooks.AccountHolder["status"])

@vincenthartsteen
Copy link
Author

Hi @vincenthartsteen ,

Thanks for raising this issue. The Accountholder you are trying to parse should be part of the configuration notification models. It's a bit more complicated than we would like unfortunately, but please try to deserialize the accountholder to this model instead. That should solve the enum issues.

We will try to provide more webhooks support in the future.

Kind Regards, Wouter Adyen

Hi Wouter,

I'm afraid that doesn't work. The AccountHolder object from the configurationwebhooks package also has the StatusEnum where the values are lowercase. However the actual webhook that we receive has a value Active. This is an example from the test environment:

{"data":{"balancePlatform":"MontroPlatform","id":"AH3292Z223227P5L2ZVKZF3J8","accountHolder":{"description":"Ma1345","legalEntityId":"LE3294Q223225S5L2ZVKZ7FJJ","reference":"4002","capabilities":{"receiveFromBalanceAccount":{"enabled":"true","requested":"true","allowed":"true","verificationStatus":"valid"}},"id":"AH3292Z223227P5L2ZVKZF3J8","status":"Active"}},"environment":"test","type":"balancePlatform.accountHolder.updated"}

Here you see a "status":"Active" that can't be parsed by the AccountHolder.fromJson() because it expects active.

@jillingk
Copy link
Contributor

Hi @vincenthartsteen and @Arnfinng,

Which webhook versions are you using? You can check this on the Balance Platform Customer Area.

Best, Jilling
Adyen

@vincenthartsteen
Copy link
Author

vincenthartsteen commented Jul 22, 2024 via email

@jillingk
Copy link
Contributor

Hi @vincenthartsteen,

Could you try to update the configured versions to the latest ones? E.g. I'm pretty sure the Configuration version is now at v2, which is unfortunately the only version we support in this library. There's some small quirky changes like the enum casing changing that we sadly had to introduce across versions.

Best, Jilling
Adyen

@vincenthartsteen
Copy link
Author

vincenthartsteen commented Jul 22, 2024 via email

@jillingk
Copy link
Contributor

Hi @vincenthartsteen,

Yes for the webhooks with multiple versions you should be able to change it. I found the similar issue we had a short while ago that might offer you some more insight. Let me know if you're able to sort it out.

Best, Jilling
Adyen

@vincenthartsteen
Copy link
Author

vincenthartsteen commented Jul 24, 2024 via email

@jillingk
Copy link
Contributor

Hi @vincenthartsteen,

These quirks are exactly the reason my colleagues are trying to unify the two platforms :)

Apologies for the confusion, let us know if you are able to get it working!

Best, Jilling
Adyen

@vincenthartsteen
Copy link
Author

vincenthartsteen commented Jul 24, 2024 via email

Copy link

This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the stale label Aug 10, 2024
Copy link

This issue was closed due to inactivity. Please reopen if you still encounter this problem or have more information to add.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants