Forums / Addon Payment Modules / using the payment module function get_error

using the payment module function get_error

Views: 4,871

Results 1 to 6 of 6
22 Feb 2016, 9:39 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

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:

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:

  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

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

22 Feb 2016, 11:44 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Feb 2016, 9:24 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using the payment module function get_error

It works as expected.
Using

www.shop.com/index.php?main_page=checkout_payment&payment_error=payment_module_name&error=PAYMENT DENIED

you get the text "PAYMENT DENIED" in a red block under the breadcrumb.

The bit I missed was in the payment module:

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.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

26 Feb 2016, 6:04 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

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.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Nov 2024, 10:02 AM
#5
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using the payment module function get_error

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.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

7 Nov 2024, 8:46 PM
#6
oldngrey avatar

oldngrey

Zen Follower

Join Date:
Apr 2008
Location:
Qld, Australia
Posts:
429
Plugin Contributions:
0

Re: using the payment module function get_error

Clarification for anyone searching for this function. It is
$messageStack->add_session(

OldNGrey
ZC222 PHP 8.4.16
MySQL 11.8.5-MariaDB