There's an even better way, which now means you won't have to edit the PayPal PHP file anymore!
That line that's replaced the part you were inserting before now allows the logic for your custom change to be handled by another file altogether. And that means it's easier for you to maintain the list without having to hunt through a huge long file to re-make the changes whenever an upgrade happens, or when you want to add another ID to the list.
Create two new files on your server, as follows:
1. /includes/auto_loaders/config.paypal_restricted_buyers.php
Code:
<?php
/**
* Autoloader to instantiate observer class
*/
$autoLoadConfig[200][] = array('autoType'=>'class',
'loadFile'=>'observers/class.paypal_restricted_buyers.php');
$autoLoadConfig[200][] = array('autoType'=>'classInstantiate',
'className'=>'paypal_restricted_buyers',
'objectName'=>'paypal_restricted_buyers');
2. /includes/classes/observers/class.paypal_restricted_buyers.php
Code:
<?php
/**
* Deny certain PayPal buyers (intended only to be used when certain buyers are chronic refunders or fraudulent but PayPal isn't shutting them down)
*
* @package observers
* @copyright Copyright 2003-2011 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: class.paypal_restricted_buyers.php 18039 2011-03-08 20:53:35Z drbyte $
*/
class paypal_restricted_buyers extends base {
/** constructor method !
*
* Attach observer class to the global $zco_notifier and watch for a single notifier event.
*/
//function paypal_restricted_buyers() { //use this line if using old version of PHP (4 or lower), instead of the next line
function __construct() {
$this->attach($this, array('NOTIFY_PAYPAL_EXPRESS_CHECKOUT_PAYERID_DETERMINED'));
}
/** Actual Method that does the desired activity
*
* Called by observed class when any of the notifiable events occur
*
* @param object $class
* @param string $eventID
*/
function update(&$class, $eventID, $paramsArray = array()) {
$denied = array();
// Set list of denied PayPal PAYERIDs here:
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
$denied[] = 'PUT_PAYER_ID_HERE';
//repeat additional lines ABOVE as needed, following the same pattern
//---------------------------------------------------
// Do not touch below:
foreach($denied as $key=>$val) {
if ($val != '' && $val != 'PUT'. '_PAYER_ID_' . 'HERE') {
if ($paramsArray == $val) {
$class->terminateEC('Sorry, your transaction cannot be completed at this time.', true, FILENAME_CHECKOUT_SHIPPING);
}
}
}
}
}
The part in red is the only thing you'll edit. Everything else should work exactly as-is.
I recommend testing with your own ID for verification.
Bookmarks