Jump to content

[SOLVED] Restrict products from being checked out using paypal!


Recommended Posts

Help Please!

I run a supplement / vitamins shop and one of my payment options is PayPal. Well paypal contacted me and restricted my account until I stop taking payment for these products or remove them of my website.

If possible can someone please assist me in not allowing these selects products from being checked out using paypal! I've been researching for the last 5 hours :( but can't find any solution for this.

Any help will be greatly appreciated.


Thanks a million.

Link to comment
Share on other sites

I don't understand why Paypal would do this! What's wrong with your products?

Ny the way, do you mean you have some other products still will use Paypal and only some of them are not allowed?
In this case, I think need some coding work to be done.

Here is a solution to your issue and some guidance I can think.
1. Set all those product in one category
2. Make some changes in Paypal module to check if there is any product in carts from specific category,if it is, then does not show up in payment selection.

  • Like 1
Link to comment
Share on other sites

Yes it's actually products that PayPal considers high risk! This is one of them:
http://www.east2westnutrition.com/weight-loss-energy/896-muscletech-hydroxycut-hardcore-pro-series.html

So what I need to do is to make sure when customers try to check this product and the other 2 products that if they choose Paypal it will deny the checkout.

I'm not a coder at all! So I looking for a way to do this without code, if not possible I can follow directions really well.
I'm in desperate need of help.

Any direction will be greatly appreciated.

Thanks in advance.

Link to comment
Share on other sites

try to replace hookPayment function in file /modules/paypal/paypal.php with following code

   public function hookPayment($params)
   {
       global $cart;

       $products = $cart->getProducts();
       foreach($products as $product)
       {
           $results =  Db::getInstance()->ExecuteS('
               SELECT *
               FROM `'._DB_PREFIX_.'category_product` WHERE id_product=' . $product['id_product'] . ' AND id_category=111111');
           if(isset($results) AND count($results)>0)return;
       }

       if (!$this->active)
           return ;

       return $this->display(__FILE__, 'paypal.tpl');
   }



Please note, you also have to replace 111111 in above code to the exact ID of the category you set for those products not pay by paypal.

Hope this works for you.

Link to comment
Share on other sites

Hey shokinro, I was just working on this issue on my paypal module and I came across the area where you suggested me to replace the “hookPayment function” but I noticed there’s 2 area’s on the paypal.php that have the “hookPayment function”! I was wondering you could kindly point out where I should replace the code?

Thank in advance.

Here is the 2 parts where it shows "hookpayment" on my paypal.php

<--Start Code-->

public function hookPayment($params)
{
if (!$this->active)
return ;

return $this->display(__FILE__, 'paypal.tpl');
}

public function hookPaymentReturn($params)
{
if (!$this->active)
return ;

return $this->display(__FILE__, 'confirmation.tpl');
}

public function getL($key)
{
$translations = array(
'mc_gross' => $this->l('Paypal key \'mc_gross\' not specified, can\'t control amount paid.'),
'payment_status' => $this->l('Paypal key \'payment_status\' not specified, can\'t control payment validity'),
'payment' => $this->l('Payment: '),
'custom' => $this->l('Paypal key \'custom\' not specified, can\'t rely to cart'),
'txn_id' => $this->l('Paypal key \'txn_id\' not specified, transaction unknown'),
'mc_currency' => $this->l('Paypal key \'mc_currency\' not specified, currency unknown'),
'cart' => $this->l('Cart not found'),
'order' => $this->l('Order has already been placed'),
'transaction' => $this->l('Paypal Transaction ID: '),
'verified' => $this->l('The PayPal transaction could not be VERIFIED.'),
'connect' => $this->l('Problem connecting to the PayPal server.'),
'nomethod' => $this->l('No communications transport available.'),
'socketmethod' => $this->l('Verification failure (using fsockopen). Returned: '),
'curlmethod' => $this->l('Verification failure (using cURL). Returned: '),
'curlmethodfailed' => $this->l('Connection using cURL failed'),
'Please wait, redirecting to Paypal... Thanks.' => $this->l('Please wait, redirecting to Paypal... Thanks.'),
'Cancel' => $this->l('Cancel'),
'My cart' => $this->l('My cart'),
'Return to shop' => $this->l('Return to shop'),
'Paypal error: (invalid or undefined business account email)' => $this->l('Paypal error: (invalid or undefined business account email)'),
'Paypal error: (invalid address or customer)' => $this->l('Paypal error: (invalid address or customer)')
);
return $translations[$key];
}

function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false)
{
if (!$this->active)
return ;

parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars);
}
}

Thanks once again.

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

I think it should work for 1.4 too.<br/>and there sould be some similiar code there.

 

I cannot get this to work on version 1.4, once i get to the payment method selection a blank page appears,

 

any help will be very much apprecaited.

 

Kind regards

Nick

Link to comment
Share on other sites

I think it should work for 1.4 too.<br/>and there sould be some similiar code there.

 

I cannot get this to work on version 1.4, once i get to the payment method selection a blank page appears,

 

any help will be very much apprecaited.

 

Kind regards

Nick

 

Just checking I am using PayPal v2.4, I could really do with some help regarding this. I do not mind paying, currently paypal has restricted my account.

 

Kind regards

Nick

Link to comment
Share on other sites

there is no reason the code does not work in the new Paypal version, because it should be working. I guess there must be some thing wrong with something else.

 

try to get the error message to see what is the cause.

set "display_errors" to "on" in file /config/config.inc/php to see what happens.

Link to comment
Share on other sites

there is no reason the code does not work in the new Paypal version, because it should be working. I guess there must be some thing wrong with something else.

 

try to get the error message to see what is the cause.

set "display_errors" to "on" in file /config/config.inc/php to see what happens.

 

Thank you so much for the quick response,

 

public function hookPayment($params)
{
	global $smarty;

	if (!$this->active)
		return ;
	/*
	 * PAYMENT METHOD:
	 * 0: Integral
	 * 1: Option +
	 * 2: Integral Evolution
	 */
	if (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_EVOLUTION_)
		return $this->display(__FILE__, 'integral_evolution/paypal.tpl');
	elseif (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_ OR Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_OPTION_PLUS_)
	{
		if ($this->_isPayPalAPIAvailable())
		{
			$smarty->assign('integral', (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0 ? 1 : 0));
			$smarty->assign('logo', _MODULE_DIR_.$this->name.'/paypal.gif');
			return $this->display(__FILE__, 'payment/payment.tpl');
		}
		else
			return $this->display(__FILE__, 'standard/paypal.tpl');
	}
	else
		die($this->l('No valid payment method selected'));
}

 

So do I replace all of this with your code.

 

Kind regards

Nick

Link to comment
Share on other sites

there is no reason the code does not work in the new Paypal version, because it should be working. I guess there must be some thing wrong with something else.

 

try to get the error message to see what is the cause.

set "display_errors" to "on" in file /config/config.inc/php to see what happens.

 

Thank you so much for the quick response,

 

public function hookPayment($params)
{
	global $smarty;

	if (!$this->active)
		return ;
	/*
	 * PAYMENT METHOD:
	 * 0: Integral
	 * 1: Option +
	 * 2: Integral Evolution
	 */
	if (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_EVOLUTION_)
		return $this->display(__FILE__, 'integral_evolution/paypal.tpl');
	elseif (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_ OR Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_OPTION_PLUS_)
	{
		if ($this->_isPayPalAPIAvailable())
		{
			$smarty->assign('integral', (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0 ? 1 : 0));
			$smarty->assign('logo', _MODULE_DIR_.$this->name.'/paypal.gif');
			return $this->display(__FILE__, 'payment/payment.tpl');
		}
		else
			return $this->display(__FILE__, 'standard/paypal.tpl');
	}
	else
		die($this->l('No valid payment method selected'));
}

 

So do I replace all of this with your code.

 

Kind regards

Nick

 

Hi,

 

I have managed to get it working, I have a long list of sub categories within a category but it does not let work when select the top category is, I was hoping that if the top category was selected it would then restrict for items in all sub categories? is there away this can be done?, or can I select more than one cateogry id.

 

I look forward to hearing from you.

 

Kind regards

Nick

Link to comment
Share on other sites

  • 2 weeks later...

Hi, there is one slight issue,

 

Since applying this code text is missing from from the paypal payment method button.

 

I have added text in the file modules/paypal/paypal.tpl as you can see below, but it is not appearing on the site.

 

<p class="payment_module">
<a href="modules/paypal/standard/redirect.php" title="{l s='Pay with PayPal' mod='paypal'}">
 <img src="{$base_dir_ssl}modules/paypal/paypal.gif" alt="{l s='Pay with PayPal' mod='paypal'}" />
[b]  {l s='Pay with PayPal and Credit / Debit Cards' mod='paypal'}[/b]

 

Can you please advise how I can get this text to appear.

 

Kind regards

Nick

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...