pfpro_process

(PHP 4 >= 4.0.2, PHP 5)

pfpro_process -- Process a transaction with Payflow Pro

Description

array pfpro_process ( array parameters [, string address [, int port [, int timeout [, string proxy_address [, int proxy_port [, string proxy_logon [, string proxy_password]]]]]]] )

Returns: An associative array containing the response

pfpro_process() processes a transaction with Payflow Pro. The first parameter is an associative array containing keys and values that will be encoded and passed to the processor.

The second parameter is optional and specifies the host to connect to. By default this is "test.signio.com", so you will certainly want to change this to "connect.signio.com" in order to process live transactions.

The third parameter specifies the port to connect on. It defaults to 443, the standard SSL port.

The fourth parameter specifies the timeout to be used, in seconds. This defaults to 30 seconds. Note that this timeout appears to only begin once a link to the processor has been established and so your script could potentially continue for a very long time in the event of DNS or network problems.

The fifth parameter, if required, specifies the hostname of your SSL proxy. The sixth parameter specifies the port to use.

The seventh and eighth parameters specify the logon identity and password to use on the proxy.

The function returns an associative array of the keys and values in the response.

注: Be sure to read the Payflow Pro Developers Guide for full details of the required parameters.

例子 1. Payflow Pro example

<?php

pfpro_init
();

$transaction = array('USER'    => 'mylogin',
                     
'PWD'     => 'mypassword',
                     
'PARTNER' => 'VeriSign',
                     
'TRXTYPE' => 'S',
                     
'TENDER'  => 'C',
                     
'AMT'     => 1.50,
                     
'ACCT'    => '4111111111111111',
                     
'EXPDATE' => '0904'
                    
);

$response = pfpro_process($transaction);

if (!
$response) {
  die(
"Couldn't establish link to Verisign.\n");
}

echo
"Verisign response code was " . $response['RESULT'];
echo
", which means: " . $response['RESPMSG'] . "\n";

echo
"\nThe transaction request: ";
print_r($transaction);

echo
"\nThe response: ";
print_r($response);

pfpro_cleanup();

?>

add a note add a note User Contributed Notes
php at spamisbad dot markjrubin dot com
25-Mar-2005 01:12
Regarding glaw at thebook dot com's comment.

There is another solution.

Determine where the actual certificate is (/usr/local/verisign/payflowpro/linuxrh9/certs for example).

The pfpro_process function looks for certificates in PFPRO_CERT_PATH if it's been set but *also* looks in the current directory for a folder named certs.

Create a symbolic link to the actual certificate folder.
-sh-2.05b$ cd httpsdocs/
-sh-2.05b$ ln -s  /usr/local/verisign/payflowpro/linuxrh9/certs certs

This worked for me.

Regards,
Mark J Rubin
glaw at thebook dot com
24-Jun-2003 03:33
The following:

putenv("PFPRO_CERT_PATH=/path/to/certs/");

doesn't work if you have safe mode on. 

One way around this is to put the following in your
apache <virtualhost> block:

SetEnv PFPRO_CERT_PATH /path/to/certs/

If you don't have access to this, ask your sys admin
jb at greendogfilm dot com
23-Jun-2003 03:44
A quick addition to ewtNOSPAM at macNOSPAM dot com
note above about including VENDOR to the array.  One must also include the PARTNER name value pair as well.  This annoying little tidbit was only found after calling Verisign to see why the User Authentication error was continually being received.  The default value (for now) for PARTNER is the username.  Cute, eh?
php at burntpopcorn dot net
15-May-2003 10:03
a "drop in" replacement for pfpro_process for windows using the pfpro.exe file. It saves having to migrate to unix for payflo support (no matter how much I want to migrate to unix) :)

doesn't support the proxy stuff because I'm not entirely sure how they work, and we don't have a proxy so they aren't worth implementing. Good luck.

function pfpro_process($params, $server, $port, $timeout) {
   $str = "";
   foreach ($params as $key=>$value) {
       $str .= ($str?"&":"").$key."=".$value;
   }
   $pfprodir = "c:\\payflo\\verisign\\payflowpro\\win32\\certs";
   putenv("PFPRO_CERT_PATH=$pfprodir");
   $pfret = `c:\payflo\verisign\payflowpro\win32\bin\pfpro $server $port "$str" $timeout`;
   $results = array();
   $keyvalues = explode("&", $pfret);
   foreach ($keyvalues as $keyvalue) {
       $temp = explode("=", $keyvalue);
       if (count($temp) == 2) {
           $results[$temp[0]] = $temp[1];
       }
   }
   return $results;
}
ewtNOSPAM at macNOSPAM dot com
06-Aug-2002 07:54
If you get the response "Verisign response code was -31, which means: The certificate chain did not validate, no local certificate found," then you must set the environment variable PFPRO_CERT_PATH to point to the directory that contains the file f73e89fd.0.

One way to do this is to include the following right before calling pfpro_process:

<?php
putenv
("PFPRO_CERT_PATH=/path/to/certs/");
?>

In my Linux installation, that path is /usr/local/verisign/payflowpro/linux/certs/
php_at_chikki_dot_net
22-May-2002 05:35
When using the transaction, dont forget to include the PARTNER tag - otherwise you will get a code 1 return: User authentication failed.

so the full $transaction Array as given above will be:

$transaction = array(USER    => 'mylogin',
             PWD    => 'mypassword',
             PARTNER    => 'VeriSign',
             TRXTYPE    => 'S',
             TENDER    => 'C',
             AMT    => 1.50,
             ACCT    => '4111111111111111',
             EXPDATE    => '0904'
             );

The default partner is VeriSign.

Please note you may also have to copy the cert to a certs/ directory (with respect to where the script is executed)
tjw at webteam dot net
06-Jun-2001 01:22
4.0.6RC2 uses 'test.signio.com' as the pfpro.defaulthost.

That host doesn't appear to work anymore.  Instead, use 'test-payflow.verisign.com'.

$response = pfpro_process($transaction, "test-payflow.verisign.com");