Closed BlackWolves-nl closed 5 years ago
Hi BlackWolves-nl,
I am not able to reproduce the issue. I've tried the following code:
string json = "{\"ReferenceNumber\": null,\"OrderID\": null,\"UserID\": \"534721\"}";
PaymentRequest paymentRequest = new PaymentRequest() {
Amount = new Amount(Currency.EUR, "100.00"),
Description = "Description",
RedirectUrl = this.DefaultRedirectUrl,
Metadata = json
};
PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest);
Assert.AreEqual(json, result.Metadata);
Could you please clarify? There is no exception and the metadata matches the input.
Hi Vincent,
I'm getting the following exception: Error reading string. Unexpected token: StartObject. Path 'payments[0].metadata', line 1, position 235.
at Newtonsoft.Json.JsonReader.ReadAsString() in /_/Src/Newtonsoft.Json/JsonReader.cs:line 504
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) in /_/Src/Newtonsoft.Json/JsonReader.cs:line 1219
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 2433
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 485
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 1663
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 875
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 167
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in /_/Src/Newtonsoft.Json/JsonSerializer.cs:line 907
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer) in /_/Src/Newtonsoft.Json/Linq/JToken.cs:line 2070
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType) in /_/Src/Newtonsoft.Json/Linq/JToken.cs:line 2034
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 2159
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 1032
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 2386
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 485
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 167
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in /_/Src/Newtonsoft.Json/JsonSerializer.cs:line 907
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) in /_/Src/Newtonsoft.Json/JsonConvert.cs:line 828
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) in /_/Src/Newtonsoft.Json/JsonConvert.cs:line 786
at Mollie.Api.Client.BaseMollieClient.<ProcessHttpResponseMessage>d__12`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Mollie.Api.Client.BaseMollieClient.<GetListAsync>d__8`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Mollie.Api.Client.SettlementsClient.<GetSettlementPaymentsListAsync>d__5.MoveNext()
From the following json being returned: https://api.mollie.com/v2/settlements/stl_7q3J6Amn2P/payments?limit=1
{
"_embedded":{
"payments":[
{
"resource":"payment",
"id":"tr_3aHjSkFttm",
"mode":"live",
"createdAt":"2017-05-21T20:04:22+00:00",
"amount":{
"value":"10.00",
"currency":"EUR"
},
"description":"Opwaardering",
"method":"sofort",
"metadata":{
"ReferenceNumber":null,
"OrderID":null,
"UserID":"534721"
},
"status":"paid",
"paidAt":"2017-05-21T20:09:10+00:00",
"amountRefunded":{
"value":"0.00",
"currency":"EUR"
},
"amountRemaining":{
"value":"35.00",
"currency":"EUR"
},
"locale":"nl_NL",
"countryCode":"BE",
"profileId":"pfl_Smmn7x2gbx",
"settlementId":"stl_7q3J6Amn2P",
"sequenceType":"oneoff",
"redirectUrl":"******",
"webhookUrl":"******",
"settlementAmount":{
"value":"10.00",
"currency":"EUR"
},
"details":{
"consumerName":"*******",
"consumerAccount":"******",
"consumerBic":"*****"
},
"_links":{
"self":{
"href":"https://api.mollie.com/v2/payments/tr_3aHjSkFttm",
"type":"application/hal+json"
},
"settlement":{
"href":"https://api.mollie.com/v2/settlements/stl_7q3J6Amn2P",
"type":"application/hal+json"
}
}
}
]
},
"count":1,
"_links":{
"documentation":{
"href":"https://docs.mollie.com/reference/v2/settlements-api/list-settlement-payments",
"type":"text/html"
},
"self":{
"href":"https://api.mollie.com/v2/settlements/stl_7q3J6Amn2P/payments?limit=1",
"type":"application/hal+json"
},
"previous":null,
"next":{
"href":"https://api.mollie.com/v2/settlements/stl_7q3J6Amn2P/payments?from=tr_r7saaD3WMq&limit=1",
"type":"application/hal+json"
}
}
}
Hi BlackWolves-nl,
Thanks for giving me the JSON response that was causing the exception. With your help I have managed to reproduce the issue and have implemented a fix for this bug in the development-2.0.3.0 branch.
Kind regards, Vincent
The issue should now be resolved in version 2.0.3.0, which is available for download.
Tested and it works. Thanks
If metadata does not contains a valid string it fails to parse while retrieving the payments list of a settlement. MetaData property looks like this: "metadata": { "ReferenceNumber": null, "OrderID": null, "UserID": "534721" }
So there needs to be some converter that reads the metadata property as a raw string.