omnipay icon indicating copy to clipboard operation
omnipay copied to clipboard

isSuccessful method confusion

Open sergiodlopes opened this issue 7 years ago • 1 comments
trafficstars

Hi all,

Thanks for the great library.

Using Omnipay 2.6 and I'm confused as to what the isSuccessful() is supposed to check.

When I developed the gateway, when reading the comment on Omnipay\Common\Message\ResponseInterface::isSuccessful(), "Is the response successful?", It made me think it meant that the response was successful from the remote server, but by reading some documentation on gateways (even official), it appears to mean that the payment was successful.

So I started planning to change my gateway implementations to the latter, but after thinking about it I think that the former is indeed useful, IMHO, as a developer, having a way to know that the request and respective response from the remote server was successful or not before checking the payment status.

Can someone please clarify this to me, so that my implementation better goes for the community standards?

Thanks!

Sérgio

sergiodlopes avatar Jul 30 '18 12:07 sergiodlopes

Hi,

You are right, the isSuccessful() tells you whether or not the payment was successful. It sounds like you would want to catch any Exceptions thrown due to the request failing rather than this being handled by Omnipay.

It's usually a good idea to wrap your Gateway::purchase() in a try catch so that you can catch these errors.

DrRoach avatar Aug 20 '18 10:08 DrRoach