Viincenttt / MollieApi

This project allows you to easily add the Mollie payment provider to your application.
MIT License
149 stars 85 forks source link

Add support for HTTP error code "Conflict" #372

Closed sebbertho closed 3 months ago

sebbertho commented 3 months ago

Currently, only the following status codes are mapped to a MollieApiException:

HttpStatusCode.BadRequest HttpStatusCode.Unauthorized HttpStatusCode.Forbidden HttpStatusCode.NotFound HttpStatusCode.MethodNotAllowed HttpStatusCode.UnsupportedMediaType HttpStatusCode.Gone (HttpStatusCode) 422: Unprocessable Entity

The documentation mentions two additional status codes:

409 | Conflict – You are making a duplicate API call that was probably a mistake (only in v2). 429 | Too Many Requests – Your request has hit a rate limit. You can try again after a short period. Especially status code 409 is important to handle in an application, so it would be beneficial to have these mapped as well.

Viincenttt commented 3 months ago

Good suggestion, I have created PR #374 to fix this issue. In this PR, I changed the error handling to always throw a MollieApiException and attempt to parse the error. If the parsing fails because the response is not in the expected format, the MollieApiException.Details property contains the raw response and HTTP code.

Viincenttt commented 3 months ago

Hi @sebbertho ,

This change is now live in version 4.1.0.0 of the NuGet package. Let me know if you have any feedback.

Kind regards, Vincent