openfun / joanie

👛 A headless ERP for education to manage course enrollment/subscription, payment and certificates delivery.
MIT License
22 stars 2 forks source link

🐛 (backend) Error with payment provider are raised and not fail silently #812

Closed jonathanreveille closed 4 months ago

jonathanreveille commented 4 months ago

Purpose

This PR will solve the following issues : #811 , #813

If there is an error, the payment provider should raise an exception.

With an exception, the error never silently fails, it can prevent or at least show a bug.

We have implemented a custom exception that will raise when an request fails on the payment provider API side.

The exception is captured when a request failed on the following payment backend methods : create_payment, create_one_click_payment and create_zero_click_payment.

When calling the endpoint submit_installment_payment and an error occurs on the API of the payment provider, a 400 BAD_REQUEST is raised.

I've checked for payplug payment provider, there is already a BadRequest exception raised when failling with a request with the API of Payplug. Only Lyra was missing a custom exception to return a BAD_REQUEST when the request failed.

Proposal