Sina-Soltani / Parbad

A free, open-source, integrated and extensible library which connects your web applications to online payment gateways. Gateways can be added or developed by you.
GNU Lesser General Public License v3.0
371 stars 81 forks source link

JsonSerializationException when using ZarinPal gateway #310

Closed WatchDogsDev closed 1 year ago

WatchDogsDev commented 2 years ago

Bug description (wIthout specifiing the sensitive data) When I updated Parbad.Gateway.ZarinPal to latest version (1.3.0), I got this error in Parbad library without changing any code.

POST https://api.zarinpal.com/pg/v4/payment/request.json [200]

Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Parbad.Gateway.ZarinPal.Internal.ZarinPalRequestResultModel' 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 'data', line 1, position 9.

Package name and version

Web application type:

Sina-Soltani commented 2 years ago

I'll take a look at it soon

amirreza58 commented 2 years ago

same error here : Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Parbad.Gateway.ZarinPal.Internal.ZarinPalRequestResultModel' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo 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.\r\nPath 'data', line 1, position 9.

Helius01 commented 2 years ago

I debugged the Parbad library and caught the reason of error
the error thrown from Zarinpal api as internal server error (500) I will try to contact Zarinpal support