note 59660 added to ref.pfpro
| From: | spamtrap at acme dot com | Date: | Mon, 12 Dec 2005 20:09:26 +0000 |
| Subject: | note 59660 added to ref.pfpro | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100021@lists.php.net to get a copy of this message | ||
If you are on a shared host, and you want to use Payflow Pro in PHP, odds are you're not going
to be able to use this extension.
Instead, you can use the exec() (see http://www.php.net/manual/en/ref.exec.php)
function to call the Payflow Pro binary. In order to do this, safe_mode must be *off*. Secondly,
there are two potential security risks in doing this:
1) You must make sure you escape/cleanup any user submitted data *before* you send it to the
exec() function, or eventually some jerk will insert "; rm -rf *" in one of your
parameters, and kill your server.
2) The shell processes spawned by exec() will be visible via a ps listing, along with their
parameters (which is to say, CC numbers. If nobody on the shared host has commandline access, or the
host prevents users from seeing other users' processes, then this may not be a big deal.
OK, if you're willing and able to deal with the above, then what you do next is:
1) Get a copy of the appropriate SDK from VeriSign Manager (https://payments.verisign.com/manager).
2) Transfer the following 3 files from the SDK to your host:
a) verisign/payflowpro/<platform>/bin/pfpro
b) verisign/payflowpro/<platform>/lib/libpfpro.so
c) verisign/payflowpro/<platform>/certs/f73e89fd.0
It doesn't matter where you put them under your directory, just make sure you know the *full*
absolute path to them. Make sure that the files are fully *readable* and *executable* on the system.
If you use FTP to transfer the files, please make sure to transfer in BIN mode, and not ASCII.
3) Edit the code below to fill in the appropriate values for $user, $vendor, $partner, $pwd,
$binary, $library, and the path specified for PFPRO_CERT_PATH, and...
4) adapt as necessary.
<?php
// This script shows:
// a) how to use the Payflow Pro commandline binary to process
// a transaction via PHP's system call, and
// b) the setup necessary to make sure that it will work
// Adjust these for your actual login parameters
$user = "myuser";
$vendor = "myvendor";
$partner = "VeriSign";
$pwd = "mysecret";
$host = "test-payflow.verisign.com";
$port = "443";
// Adjust these next two paths appropriately; i.e. where did
// you actually put these two files?
$binary = '/usr/local/bin/pfpro';
$library = '/usr/local/lib/libpfpro.so';
$newld = dirname($library);
// this is necessary to prevent RESULT=-31 errors; make sure
// it's a *directory* that contains the cert file that came
// with the SDK, and *don't* put a trailing slash on it
putenv("PFPRO_CERT_PATH=/path/to/your/certs/dir");
// This next chunk of stuff assumes you're having linker issues, and
// attempts to fix or work around them.
// Now, let's fix the linker path:
$original_ld_path = getenv("LD_LIBRARY_PATH");
$newld .= ":$original_path";
putenv("LD_LIBRARY_PATH=$newld");
// having set the linker to find the library, now call the binary:
$cmd =
"\"TRXTYPE=S&TENDER=C&PWD=$pwd&USER=$user&VENDOR=$vendor";
$cmd .=
"&PARTNER=$partner&ACCT=4222222222222&EXPDATE=1209&AMT=14.42";
$cmd .= "&INVNUM=1234567890&STREET=5199 JOHNSON&ZIP=94588\" 30";
$result = exec("$binary $host $port $cmd", $result_array, $exit_value);
$valArray = explode('&', $result);
foreach($valArray as $val) {
$valArray2 = explode('=', $val);
$pfpro[$valArray2[0]] = $valArray2[1];
}
// To look at the array structure
print_r($pfpro);
// This should be equal to the RESULT that came back. If you
// get no result string back, but the exit_value here is 126 or 127,
// you've got linker or permission problems.
echo "the exit value of the system call to pfpro was $exit_value";
?>
----
Manual Page -- http://www.php.net/manual/en/ref.pfpro.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59660
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59660&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59660&report=yes
Search -- http://master.php.net/manage/user-notes.php