I've just completed coding an INCLUDE file that emulates the pfpro functions:
pfpro_init();
pfpro_cleanup();
pfpro_version();
pfpro_process();
pfpro_process_raw();
Simply include this file within your script(s) and call the functions. I've posted this code under http://www.php.net/manual/en/ref.pfpro.php and submitted it to Versign for potential inclusion into their pfpro SDK.
--- CODE ---
<?php
/* { PHP_PFPRO.INC }
This file effectively acts as a fill-in or replacement for the missing PHP_PFPRO.DLL extension
for Win32 Platforms. This INCLUDE file was written and tested using PHP 4.0.6.
For instructions on how to use these functions, please go to:
http://www.php.net/manual/en/ref.pfpro.php
IMPORTANT: Before you use this INCLUDE file, you must set the following environment
variable, or this script will not work.
PFPRO_CERT_PATH = C:\Verisign\payflowpro\win32\certs <- or whatever your path is.
The following functions are present, but do nothing -- they are here for compatibility
only. I put them here so that when the PHP_PFPRO.DLL becomes available, you won't have
to change your code.
functions:
pfpro_init() : returns NULL
pfpro_cleanup() : returns NULL
pfpro_version() normally returns the version string of the PayFlowPro Library.
However, the function in this INCLUDE file returns the version of the executable.
It was frustrating indeed trying to figure out why the pfpro stuff wasn't working... I spent
a couple of days in News Groups and on the phone with Verisign... no one knows... Ahhhh... the
joy of Open Source -- I decided something had to be done (gosh darn-it) -- so I took it upon
myself to write a solution and end my frustration, and the frustration of countless others out
there fighting with the same annoying issue. A hero am I, no! -- just a geek on a mission.
In a nutshell, these functions should work nearly identical to the coming soon pfpro extension,
although, I am not totally certain, as I've never seen the official pfpro functions in action, I'm
only going by what the PHP manual says they are suppose to do... plus, I think, a little of what
I want them to do... so having said that, use this INCLUDE file at your own risk, there is no
warranty, guarantee or otherwise.
It's now 2am, and I've finished all the testing... man, I am zonked!
Enjoy,
Jason Caldwell (10.06.2001)
jason@thinkingman.org */
/* You have the choice of either setting your Defaults within this script (the default), or
pulling the defaults from the PHP.INI file.
Set $READ_PHP_INI to 0 (zero) to define the constants within this script, or 1 (one) to grab the
constants from the PHP.INI file.
FYI: The php_pfpro.dll extension pulls the info from the PHP.INI file only! Just remember, if you decide
to set your constants within this script, when you move to the extension, you'll have to make
the necessary changes in the PHP.INI file. */
$READ_PHP_INI = 0;
/ Define Constants Here Pull Constants from PHP.INI
-------------------------- --------------------------- /
define(pfpro_defaulthost, ($READ_PHP_INI == 0) ? 'test-payflow.verisign.com' : get_cfg_var('pfpro.defaulthost'));
define(pfpro_defaultport, ($READ_PHP_INI == 0) ? 443 : get_cfg_var('pfpro.defaultport'));
define(pfpro_defaulttimeout, ($READ_PHP_INI == 0) ? 30 : get_cfg_var('pfpro.defaulttimeout'));
define(pfpro_proxyaddress, ($READ_PHP_INI == 0) ? NULL : get_cfg_var('pfpro.proxyaddress'));
define(pfpro_proxyport, ($READ_PHP_INI == 0) ? NULL : get_cfg_var('pfpro.proxyport'));
define(pfpro_proxylogin, ($READ_PHP_INI == 0) ? NULL : get_cfg_var('pfpro.proxylogin'));
define(pfpro_proxypassword, ($READ_PHP_INI == 0) ? NULL : get_cfg_var('pfpro.proxypassword'));
define(PFPRO_EXE_PATH, 'C:\Verisign\payflowpro\win32\bin\pfpro.exe');
function pfpro_init()
{
/ This function is here for
compatibility only. Returns
NULL (nothing) /
return(NULL);
}
function pfpro_cleanup()
{
/ This function is here for
compatibility only. Returns
NULL (nothing) /
return(NULL);
}
function pfpro_version()
{
@(PFPRO_EXE_PATH, $result);
$version = substr($result[0], strlen($result[0])-4, 4);
return($version);
}
function pfpro_process($transaction, $url=pfpro_defaulthost, $port=pfpro_defaultport, $timeout=pfpro_defaulttimeout,
$proxy_url=pfpro_proxyaddress, $proxy_port=pfpro_proxyport, $proxy_logon=pfpro_proxylogin,
$proxy_password=pfpro_proxypassword)
{
if(!(is_array($transaction)))
return(NULL);
/ destruct (transaction) array into (trans) string
and dynamically add LENGTH TAGS /
foreach($transaction as $val1=>$val2)
$parmsArray[] = $val1 . '[' . strlen($val2) . ']=' . $val2;
$parmsString = implode($parmsArray, '&');
$trans = PFPRO_EXE_PATH . ' ';
$trans .= $url . ' ';
$trans .= $port . ' "';
$trans .= $parmsString . '" ';
$trans .= $timeout . ' ';
$trans .= $proxy_url . ' ';
$trans .= $proxy_port . ' ';
$trans .= $proxy_logon . ' ';
$trans .= $proxy_password;
/ run transaction, if result blank, return(NULL) /
@($trans, $result);
if($result[0] == NULL)
return(NULL);
/ construct (pfpro) array out of (result) string /
$valArray = explode('&', $result[0]);
foreach($valArray as $val)
{
$valArray2 = explode('=', $val);
$pfpro[$valArray2[0]] = $valArray2[1];
}
return($pfpro);
}
function pfpro_process_raw($transaction, $url=pfpro_defaulthost, $port=pfpro_defaultport, $timeout=pfpro_defaulttimeout,
$proxy_url=pfpro_proxyaddress, $proxy_port=pfpro_proxyport, $proxy_logon=pfpro_proxylogin,
$proxy_password=pfpro_proxypassword)
{
/* This function is as RAW as it gets ... no conversions... you are responsible for
any LENGTH TAGS to avoid potential '&' and '=' problems that may arise -- it is advisable
to simply not use this function and stick only to pfpro_process().
This function merely receives a string, processes it, and then returns a results string. */
if(!(is_string($transaction)))
return(NULL);
$trans = PFPRO_EXE_PATH . ' ';
$trans .= $url . ' ';
$trans .= $port . ' "';
$trans .= $transaction . '" ';
$trans .= $timeout . ' ';
$trans .= $proxy_url . ' ';
$trans .= $proxy_port . ' ';
$trans .= $proxy_logon . ' ';
$trans .= $proxy_password;
/ run transaction, if result blank, return(NULL) /
@($trans, $result);
if($result[0] == NULL)
return(NULL);
return($result[0]);
}
?>