Adyen / adyen-dotnet-api-library

Adyen API Library for .NET
MIT License
108 stars 112 forks source link

Capabilities property on AccountHolder is null when calling CreateAccountHolderAsync or UpdateAccountHolderAsync in Adyen.Service.BalancePlatform.AccountHoldersService #1038

Open PeteGEPOS opened 3 months ago

PeteGEPOS commented 3 months ago

Describe the bug When making a call to create or update an AccountHolder via the AccountHoldersService class (Adyen.Service.BalancePlatform) using v16.2 of the .net Adyen SDK, the returned AccountHolder object has a null value for Capabilities.

To Reproduce Steps to reproduce the behavior:

  1. Create a call to CreateAccountHolderAsync passing an AccountHolderInfo object eg. public async Task<AccountHolder?> CreateAccountHolderAsync(AccountHolderInfo accountHolder) => await AccountHoldersService.CreateAccountHolderAsync(accountHolder);
  2. Result of that call has null value on Capabilities property of AccountHolder.
  3. Same behaviour is exhibited on updates using UpdateAccountHolderAsync passing a AccountHolderUpdateRequest object.
  4. Calling non-async versions of methods yields the same result.

Expected behavior Looking at the API documentation, I'm expecting to see a list of Capabilities. See https://docs.adyen.com/api-explorer/balanceplatform/latest/post/accountHolders .

Screenshots

image

Desktop (please complete the following information):

jillingk commented 3 months ago

Hi @PeteGEPOS,

Thanks for reaching out to us here. Could you maybe provide me with the json payload you're receiving from the call? Also which serializer are you using on your project, System.text or Newtonsoft?

Best, Jilling Adyen

PeteGEPOS commented 3 months ago

Hi @jillingk ,

Thanks for the reply. We're using System.Text. The following is the response from the call to UpdateAccountHolderAsync;

{class AccountHolder { BalancePlatform: XXXXXXXXXXXXXXXXXXXXX Capabilities: ContactDetails: Description: TEST: UPDATE.15 - Liable account holder used for payments and payouts Id: XXXXXXXXXXXXXXXXXXXXX LegalEntityId: XXXXXXXXXXXXXXXXXXXXX Metadata: MigratedAccountHolderCode: PrimaryBalanceAccount: XXXXXXXXXXXXXXXX Reference: PR.Test.01.Updated.15 Status: Active TimeZone: VerificationDeadlines: } }

Many thanks,

Pete

jillingk commented 3 months ago

Hi @PeteGEPOS,

That might be the culprit. We use Newtonsoft which often works fine with System.text except for the case of some very specific types. Could you perhaps try to import the Newtonsoft library in the framework you're using and see if that solves the issue?

In the meantime I'll see if we can make some changes to better support this dict<str, obj> type on deserialization for the System.text library.

Best, Jilling Adyen

PeteGEPOS commented 3 months ago

Hi @jillingk ,

Delving into the call stack a little further, I think this is what you were expecting re: the json response;

{
    "balancePlatform": "XXXXXXXXXXXXXXXXXXXXX",
    "description": "TEST: UPDATE.19 - Liable account holder used for payments and payouts",
    "legalEntityId": "XXXXXXXXXXXXXXXXXXXXX",
    "reference": "PR.Test.01.Updated.19",
    "id": "XXXXXXXXXXXXXXXXXXXXX",
    "primaryBalanceAccount": "XXXXXXXXXXXXXXXXXXXXX",
    "status": "active"
}

Pete

PeteGEPOS commented 3 months ago

Hi @PeteGEPOS,

That might be the culprit. We use Newtonsoft which often works fine with System.text except for the case of some very specific types. Could you perhaps try to import the Newtonsoft library in the framework you're using and see if that solves the issue?

In the meantime I'll see if we can make some changes to better support this dict<str, obj> type on deserialization for the System.text library.

Best, Jilling Adyen

Thanks for the reply @jillingk . I'll give it a go with regards to using Newtonsoft, however, that json response I just posted from the call stack isn't giving me much hope. That looks like the API is not returning what is expected as per https://docs.adyen.com/api-explorer/balanceplatform/latest/post/accountHolders . In fact, when making a patch via Postman to https://balanceplatform-api-test.adyen.com/bcl/v2/accountHolders/XXXXXXXXXXXXXXXXXXXXX, I get the same json (as expected) so it looks like either there's a bug in the API itself OR the documentation is wrong and the Capabilities aren't included in the Post / Patch requests?

I note that when doing a Get, via Postman the Capabilities are included so it looks as though it is an API bug.

{
    "balancePlatform": "XXXXXXXXXXXXXXXXXXXXX",
    "description": "TEST: UPDATE.21 - Liable account holder used for payments and payouts",
    "legalEntityId": "XXXXXXXXXXXXXXXXXXXXX",
    "reference": "PR.Test.01.Updated.18",
    "capabilities": {
        "receiveFromPlatformPayments": {
            "enabled": true,
            "requested": true,
            "allowed": true,
            "verificationStatus": "valid"
        },
        "receiveFromBalanceAccount": {
            "enabled": true,
            "requested": true,
            "allowed": true,
            "verificationStatus": "valid"
        },
        "sendToBalanceAccount": {
            "enabled": true,
            "requested": true,
            "allowed": true,
            "verificationStatus": "valid"
        },
        "sendToTransferInstrument": {
            "enabled": true,
            "requested": true,
            "allowed": false,
            "problems": [
                {
                    "entity": {
                        "id": "XXXXXXXXXXXXXXXXXXXXX",
                        "type": "LegalEntity"
                    },
                    "verificationErrors": [
                        {
                            "code": "2_8036",
                            "message": "'bankAccount' was missing.",
                            "remediatingActions": [
                                {
                                    "code": "2_115",
                                    "message": "Add bank account"
                                }
                            ],
                            "type": "dataMissing"
                        }
                    ]
                }
            ],
            "verificationStatus": "invalid"
        },
        "receivePayments": {
            "enabled": true,
            "requested": true,
            "allowed": true,
            "verificationStatus": "valid"
        }
    },
    "id": "XXXXXXXXXXXXXXXXXXXXX",
    "primaryBalanceAccount": "XXXXXXXXXXXXXXXXXXXXX",
    "status": "active"
}
jillingk commented 3 months ago

Hi @PeteGEPOS,

Just tried to deserialise your json payload in a quick unit test and it works fine using Newtonsoft so I don't think it's an issue with the library. Let me experiment with the System.text a bit and I'll come back as soon as I found something :)

edit: sorry read over your second point of patch/post not working vs get working. The thing is that these methods all return the same response model so that would point to the actual httprequest methods not working which is interesting. I'll look into it!

Best, Jilling Adyen

DjoykeAbyah commented 1 month ago

Hi @PeteGEPOS,

I wanted to check in and see if you're still experiencing this issue after using Newtonsoft?

Kind regards, Djoyke Adyen

PeteGEPOS commented 1 month ago

Hi Djoyke,

This is still a problem and it's also returning a null value for Capabilities on the UpdateAccountHolderAsync method in the same service as well. We are using 19.0.0 of the SDK.

The Capabilities are in the WebHook models and we're using those to update the Capabilities we store for an account holder so it's a minor issue as things stand as we just ignore that property in the API response and rely exclusively on the updates via the WebHooks.

Having said that, the same issue occurs on the VerificationDeadline property and that one doesn't seem to be coming through in the AccountHolderNotificationRequest despite the WebHook documentation implying it does (https://docs.adyen.com/api-explorer/balanceplatform-webhooks/2/post/balancePlatform.accountHolder.updated) - it's coming through as null. The ONLY way I seem to be able to get valid values for that property are if I call GetAccountHolderAsync.

Any thoughts?

Thanks,

Pete

jillingk commented 1 week ago

Hi @PeteGEPOS,

Apologies for the delayed response.

To double check, you are using our webhook models to deserialise the notifications right? The webhook model should be similar to the endpoint models, the only difference being that the endpoint apparently has some fields with private setters fields with no constructor. Either way Newtonsoft is still able to deserialise though, but I guess it could pose a problem for System.Text. If you can verify your webhook models are working we could consider removing these readonly fields.

Best, Jilling Adyen