Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Verisign Payflow Pro Functions : pfpro_process

pfpro_process

Process a transaction with Payflow Pro (PHP 4 >= 4.0.2, PHP 5 <= 5.0.5)
array pfpro_process ( array parameters [, string address [, int port [, int timeout [, string proxy_address [, int proxy_port [, string proxy_logon [, string proxy_password]]]]]]] )

Example 2610. Payflow Pro example

<?php

pfpro_init
();

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

$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();

?>

Code Examples / Notes » pfpro_process

php_at_chikki_dot_net

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)


glaw

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


php

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


ewtnospam

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/


jb

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

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;
}


tjw

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");


Change Language


Follow Navioo On Twitter
pfpro_cleanup
pfpro_init
pfpro_process_raw
pfpro_process
pfpro_version
eXTReMe Tracker