using the payment module function get_error
While investigating this, I see it is used only by /pages/checkout_payment/header_php.php,
for example
In the header:
PHP Code:
if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) { $messageStack->add('checkout_payment', $error['error'], 'error');}
In the payment module:
PHP Code:
function get_error() {
$error = array(
'title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_ERROR,
'error' => stripslashes(urldecode($_GET['error'])));
return $error;
}
I am assuming this is a way to show a relevant error message to the user when an (offsite?) payment fails and they are redirected back to the checkout_payment page by the gateway.
I cannot get this to work, I assume that the url should have something like:
?payment_error=the_module_name&error=message
but this just goes to page not found.
I find no mention of this anywhere so can someone please explain how to use it.
thanks
Steve
Re: using the payment module function get_error
So here's how I see it working, first of all there needs to be a main_page= which the prefix to that is typically the question mark as it is the first parameter following the page (index.php), then somewhere as a parameter whether first, last or indifferent, is a value x such as parameter_error=x where $x is a variable/object in the define of the code up to that point. Also on that url is a parameter error of value y such that error=y.
If the above parameter list is "correct" then it would seem as if the main_page= part was missing. Of course all necessary information would have to be present to make it up to and including the line provided above from the checkout_payment header file plus whatever other validation is needed to continue processing on, whether posted data, other parameters on the uri, etc...
That's my take on it anyways without too much other "magic" happening outside of that.
Re: using the payment module function get_error
It works as expected.
Using
Quote:
www.shop.com/index.php?main_page=checkout_payment&payment_error=payment_module_name&error=PAY MENT DENIED
you get the text "PAYMENT DENIED" in a red block under the breadcrumb.
The bit I missed was in the payment module:
Quote:
function get_error() {
$error = array('title' => 'REDSYS ERROR',
'error' => stripslashes(urldecode($_GET['error'])));
return $error;
}
I didn't initially spot the change of the default return "false" to the array name.
Obviously this function can be further modified to return language-specific and error-specific messages.
Re: using the payment module function get_error
The get_error() function is rapidly being deprecated in favour of simply doing direct $messageStack->addSession() calls from within the payment module instead.
There are presently no plans to retain it moving forward past the v1.5.x series.
Re: using the payment module function get_error
Quote:
Originally Posted by
DrByte
The get_error() function is rapidly being deprecated in favour of simply doing direct $messageStack->addSession() calls from within the payment module instead.
There are presently no plans to retain it moving forward past the v1.5.x series.
If that is the case, perhaps it should be removed from the core payment modules to prevent that being used as a template for new payment modules...or make one module the recommended starting point for a new module.
Re: using the payment module function get_error
Clarification for anyone searching for this function. It is
$messageStack->add_session(