Archive for September, 2008

Realex payments error 505 “You cannot use this service from there”

September 2, 2008

Did a booking engine for a hotel lately, and I wanted to record the booking details before redirecting the user to the payment processor’s site (realex in this case), so the final form was submitted to my own application, then I used php’s curl functions to get the payment page from realex.

In the response from realex’s server to the http request sent by curl I was getting an error with error code 505 and the message “You cannot use this service from there”. Before payment goes live for an account, realex asks for the url that you’ll be redirecting to their system from (the “incoming url”, they call it) and then they reject requests from any other “incoming url”. What this means, it turns out, is they check the “Referer” header in your incoming http request and make sure it matches the “incoming url” you’ve supplied to them. The request I was sending via curl wasn’t sending a “Referer” header, hence the error. Solved the problem like this:

$ch = curl_init(PAYMENT_PAGE_URL);
curl_setopt(...);
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Referer: <myurl>"));
curl_exec($ch);
curl_close($ch);