Implementing PayPal Payflow link in Zen Cart and Silent Post URL

Ever had a problem with implementing PayPal Payflow Link in Zen Cart and making Silent Post URL to work?
I had for a while and it was a challenge. I made a whole site in Zen Cart (Web Design Beach favorite shopping cart solution) and couldn’t just give up at the end, because of Silent Post URL problem. There was only one way out - either to find someone to fix it for me or me, myself and I against PayPal’s Payflow link, Silent Post URL and Zen Cart.

To make the matter even worse I couldn’t find necessary information anywhere on the internet. Everybody was asking the same question and there was no answer. Now I’ll explain in few easy steps how to handle Silent Post URL in PayPal’s manager and implement it successfully in Zen Cart and save at least some time to the ones that might need it in future.

1. Downloading Payflow link module.
You need to download Payflow link module for Zen Cart, and you can find it at here. When you finish downloading the Payflow module, just upload those files via FTP to your server - it is pretty good explained in read me file.

2. Modifying file “verisignreturn.php” - file you have downloaded in previous step.
Open verisignreturn.php in text editor you prefer most, and feel free to delete everything inside, and just paste this:

if($_POST['RESULT']==0){  // check if transaction was finished successfully
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PROCESS, zen_get_all_get_params()));}

This piece of code is just checking if Payflow link returned 0 - that means that transaction finished successfully (credit card number was ok, etc.) and if result is equal to zero, then redirect to checkout process page, where order will be submitted.

3. Specifying the Silent POST URL
You will need to login to your PayFlow account, and specify the POST return URL (from top menu go to Service Settings -> Configuration) which is: (non secure site) or (secure site)
Also don’t forget to specify Return URL, that is where user will be redirected in case he pressed the button… Maybe the best solution would be to redirect user to your home page.

4. Modifying checkout_process.php
In previous step you defined Silent POST URL, so when the client finishes purchase, and gets redirected to Paypal, Silent POST URL should automatically pass all necessary information to your site. But it will not happen simply because session will be destroyed and poor Zen Cart will be unable to find necessary information like cart ID, clients name etc.
So, now we need to manually fill session array with necessary information, and then Silent POST URL will pass back info to Zen Cart, but this time successfully. Open checkout_process.php, which is located in includes/modules, and add this code anywhere you like:

function unserializesession($data) {
for($i=0; $vars[$i]; $i++) $result[$vars[$i++]]=unserialize($vars[$i]);
return $result;

I took this function from, it’s pretty nice one, and you’ll use it to unserialize session which is stored in Zen Cart’s Database.

Now paste this piece of code:

$skey = $_POST['USER2'];
$sql = “SELECT value from zen_sessions WHERE sesskey like ‘$skey’”;
$res = $db->Execute($sql);
$data = $res->fields['value'];
$session_array = unserializesession($data);
foreach($session_array as $key => $val){
$_SESSION[''.$key.''] = $val;
just after part -
if (!defined(’IS_ADMIN_FLAG’)) {
die(’Illegal Access’);

That’s pretty much it. Hope it helped a bit at least and if anyone has any better idea or knows how to do this differently your comments at Beach Bar will be appreciated.

Tags: , , ,


3 Responses to “Implementing PayPal Payflow link in Zen Cart and Silent Post URL”

  1. usd6 Says:

    This is a great article, very helpful to me, thank you!

  2. devz Says:

    awesome post

  3. Francisco Says:

    Great an easy explanation. Very useful for my site. Thanks.