These are chat archives for Payum/Payum

4th
Oct 2016
Toni Rudolf
@toooni
Oct 04 2016 06:07

hi @makasim I just created a new gateway for Postfinance, a local PSP/bank here in switzerland. Now I wanted you to ask how you would implement the forwarding of error messages from the api to my symfony app. For example, if something is wrong with the expiration date of the credit-card I just get an error code in the response and want to add an error to the expiration date of the form.
I had two solutions in mind:

  • Check the status code directly in the API and throw exceptions like "InvalidExpirationDate" directly in the API and catch those in the controller
  • Check the status code in my payment event listener (onPostExecute), and throw the exceptions there (so the logic is decoupled from the gateway)

What is the way to go? I checked some other gateways but I didn't find something comparable.

Max Kotliar
@makasim
Oct 04 2016 07:38

The api should not do anything like that, it just send some raw data to the payment gateway and returns the response.
The response is stored in the payment details, It is your state of the payment.

Here you have options what to do next:

  1. You can create an extension, or listener to specific for this particular gateway. It check details and act according to it.
  2. You can also create a new request let's say GetCreditCardErrors and an action able to populate those errors from the details.
I personally prefer the second approach as you kind of building the domain language. And it is clear what is going on, any magic that happens in the extension.
I dont think the exception is a good way to go here. It is not an exceptional situation.
Toni Rudolf
@toooni
Oct 04 2016 10:58
Thank you very much! This will do the job..