circleinteractive / uk.co.circleinteractive.payment.sagepay

Sagepay Extension for CiviCRM
4 stars 12 forks source link

Some IPN responses not formatted correctly #7

Open judgej opened 8 years ago

judgej commented 8 years ago

Example here:

https://github.com/circleinteractive/uk.co.circleinteractive.payment.sagepay/blob/master/ipn.php#L241

An internal error in the data sent or the data stored, results in just a text message being echoed out. This leaves the user in Sage Pay with the error message:

Server error 5006: Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.

So the user is left in a bit of limbo, stuck on Sage Pay, with no cancel button and a difficulty in using the back button due to the POST submissions.

If there is an internal data inconsistency, then return the status ERROR to Sage Pay, with the details in the normal format. That way it can be handled correctly and the user returned to site. If the data sent is so wrong that no contribution can be determined, then send them to the home page of the site at least.

There are (I think) four places that just end with a echo "Something kind of unexpected happened"

andy-walker commented 8 years ago

I'll take a look at those. The usual cause of the 5006 error though is something going wrong further up in Civi when it's trying to complete the transaction, so if you're getting that, I would check your Civi logs for some more info about what's going wrong. It happens because the site is WSoDing before it has a chance to echo the appropriate response.

But there is probably something we can do with exception handling to get an appropriately formatted response returned in those cases - I'll take a look when I get a minute.

judgej commented 8 years ago

Just a note: the response should be INVALID in these circumstances. ERROR is only used in exceptional circumstances, such as not being able to contact the database, or failing to load a class. ERROR means, "an issue at my end and I'm bailing out". INVALID means, "I don't like your data at all" for any number of reasons.