You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For processing in a back office system, we create transactions with a custom property containing an identifier. For example I create a 'mycustomprop' in the Buckaroo Plaza and provide a value for it when creating a transaction. This transaction also contains the push url.
When the push is received in the API, it successfully passes the hmac validation. The next step is actually deserializing the message which seems to fail when Custom Properties are used: Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'BuckarooSdk.DataTypes.CustomParameters' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
Cause
The actual JSON message has a 'CustomParameters' property which is a list of Name-Value pairs. The models used in the project however expect a 'List' property which is a list containing the Name-Value pairs. So the data model contains an additional layer which is not there in the JSON message. Therefore the deserialisation from JSON to the model failes.
Potential solutions
Change the object model structure in the SDK, so that it matches the actual JSON structure. This might cause side effects else where in the SDK Client I might not be aware of yet.
Create some kind of custom deserialisation logic on top of NewtonSoft JSON.
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'BuckarooSdk.DataTypes.CustomParameters' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path 'CustomParameters', line 1, position 581.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at PaymentApi.Controllers.DebugPushHandler.DeserializeTransaction(String jsonString) in C:\Repos\PaymentApi\Controllers\DebugPushHandler.cs:line 72
at PaymentApi.Controllers.DebugPushHandler.DeserializePush(String jsonString) in C:\Repos\PaymentApi\Controllers\DebugPushHandler.cs:line 55
at PaymentApi.Controllers.DebugPushHandler.DeserializePush(Byte[] body, String requestUri, String authorizationHeader) in C:\Repos\PaymentApi\Controllers\DebugPushHandler.cs:line 39
at PaymentApi.Controllers.Internal.BuckarooController.PostTransaction() in C:\Repos\PaymentApi\Controllers\BuckarooController.cs:line 94
at lambda_method631(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at PaymentApi.Middleware.RequestBufferingMiddleware.Invoke(HttpContext context) in C:\Repos\PaymentApi\Middleware\RequestBufferingMiddleware.cs:line 39
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Note: Stacktrace is made on an exact copy of PushHandler, but added as source 'DebugPushHandler' to allow debugging. The result is the same.
The text was updated successfully, but these errors were encountered:
Description
For processing in a back office system, we create transactions with a custom property containing an identifier. For example I create a 'mycustomprop' in the Buckaroo Plaza and provide a value for it when creating a transaction. This transaction also contains the push url.
When the push is received in the API, it successfully passes the hmac validation. The next step is actually deserializing the message which seems to fail when Custom Properties are used:
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'BuckarooSdk.DataTypes.CustomParameters' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
Cause
The actual JSON message has a 'CustomParameters' property which is a list of Name-Value pairs. The models used in the project however expect a 'List' property which is a list containing the Name-Value pairs. So the data model contains an additional layer which is not there in the JSON message. Therefore the deserialisation from JSON to the model failes.
Potential solutions
Relevant documentation
Technical implementation
Could also have used the SdkClient, which also has a PushHandler.
Example Push
Stack trace
Note: Stacktrace is made on an exact copy of PushHandler, but added as source 'DebugPushHandler' to allow debugging. The result is the same.
The text was updated successfully, but these errors were encountered: