Home   Best Sellers   Blogging   Coding & Design   Technology   SEO   Travel & living   Career   Videos   Tips   Online tools     
Home  »     »     »     »     »  How to fix "PAYMENTECH_HOME must be defined for CGI applications to work" error while using paymentech Orbital Perl SDK?

How to fix "PAYMENTECH_HOME must be defined for CGI applications to work" error while using paymentech Orbital Perl SDK?

Friday, April 11, 2014

"PAYMENTECH_HOME must be defined for CGI applications to work" - How to fix this error happened while using Chase paymentech Orbital Perl SDK?

This topic cover the issue of not passing of Environment variables from Apache to CGI scripts

Following error is occuring some times when trying to use PAYMENTECH perl SDK:

Software error:
PAYMENTECH_HOME must be defined for CGI applications to work
BEGIN failed--compilation aborted at /usr/local/share/perl5/Paymentech/CGI.pm line 47.
Compilation failed in require at paymentprocessor.pl line 25.
BEGIN failed--compilation aborted at paymentprocessor.pl line 25.

Chase Paymentech offers Payment gateways for processing credit card payments for eCommerce websites. One of their products, Orbital Payment Gateway which uses a Perl SDK which is to installed on the server and a perl script will use this SDK to generate calls to paymentech server to process the payment and return the result of transaction to the user.

Process happens something like this:

Suppose your site is a PHP driven ECommerce website, After the checkout process , website submits payment info along with Credit card information to a Perl script on your server's CGI location. The perl script will be using the SDK which is installed on the server and the script uses the SDK function to process the payment info and return the result of the transaction to the user.

The above mentioned error happened in the "paymentprocessor.pl" script and this is the page where the payment info is submitted from the PHP side of the website.

There will be statement like the one given below, which will try to load the SDK module

use Paymentech::CGI;

But on some conditions CGI script may not be able to access the Environment variable PAYMENTECH_HOME which tells the location of SDK. That is sometimes when CGI sciript runs under apache the system doesn't pass the PAYMENTECH_HOME variable to the script.

One reason for this is, when the CGI (common gateway interface) is running in a suEXEC environment, the environment variable may get unaccessible. The suexec module gets readded or uncommented within the apache configuration file so in order to fix this issue, we have to comment out the line and restart apache. Perl Payment scripts required an environment variable, PAYMENTECH_HOME, to be set. As suEXEC scrubs the environment that is passed to the CGI scripts, this variable is not being passed correctly, which was causing perl script failing. to fix this disable suEXEC module completely. This happens when the Plesk or Apache is updated and config file is rewritten.

To disable suEXEC, the following line was commented in /etc/httpd/conf/httpd.conf and Apache was restarted:

#LoadModule suexec_module modules/mod_suexec.so

Another situation:

If I define it like
export $PAYMENTECH_HOME=/usr/local/paymentech from the shell before I run perl script.cgi everything works fine.But if I run it under apache the system doesn't pass the PAYMENTECH_HOME variable to the script.

- One option is to define the Environment variable in Environment variable file. Find the File so you could put your definition right in somewhere near the top of the file. Ie, add an export MYVAR=value line to envvars (should be located in /etc/apache2) or the script that starts apache (in /etc/init.d), and add your PassEnv MYVAR where it's wanted in your apache configuration.

export PAYMENTECH_HOME=/usr/local/paymentech

- Other option is to use the "PassEnv" and "SetEnv" directives in httpd.conf to tell apache to pass certain environment variables from its own environment to any CGI scripts being run.

Apache Module mod_env has the functions for this. click MOD_ENV to learn more about this Apache module or visit : http://httpd.apache.org/docs/2.2/mod/mod_env.html

Reference links:
  • Apache.org suEXEC :www.httpd.apache.org/docs/2.2/suexec.html 
  • What Wiki pedia says about SuEXEC : http://en.wikipedia.org/wiki/SuEXEC
  • Environment Variables in Apache : http://httpd.apache.org/docs/2.2/env.html
  • Apache Module mod_env : http://httpd.apache.org/docs/2.2/mod/mod_env.html
  • Common gateway interface (CGI) : http://en.wikipedia.org/wiki/Common_Gateway_Interface
  • Start Apache web server : https://httpd.apache.org/docs/2.2/invoking.html
  • Stop Apache web server : https://httpd.apache.org/docs/2.2/stopping.html
  • Restart Apache web server : http://webdesign.about.com/cs/apache/ht/htapacherestart.htm

What is suExec
The suEXEC feature provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web server. Apache suEXEC is a feature of the Apache Web server. It allows users to run CGI and SSI applications as a different user - normally, all web server processes run as the default web server user (often wwwrun, Apache or nobody). The suEXEC feature consists of a module for the web server and a binary executable which acts as a wrapper. suEXEC was introduced in Apache 1.2 and is often included in the default Apache package provided by most Linux distributions.

Share this!

How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
How to fix "PAYMENTECH_HOME must be defined for CGI applications to work" error while using paymentech Orbital Perl SDK?.

comments powered by Disqus

This Weeks 7 Popular Posts

Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   

Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »