Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Price dependant payment module

Recommended Posts

I can successfully enable/disable worldpay module by price so i can now seperate cheap (50p) debit card transactions, and expensive (4.5%) credit card transactions and use cheaper nochex as necessary.


worldpay.php: Disable if amount is less than ?11


$this->enabled = ((MODULE_PAYMENT_WORLDPAY_DC_STATUS == 'True')? true : false);

if ( $order->info['total' ] < 11) {

$this ->enabled = false;



If I set $this ->enabled = true; it works but the condition is not what I want it will not disable if less than ?11.


What is more baffling is that I have another worldpay module called worldpay_cc.php


$this-> enabled = (( MODULE_PAYMENT_WORLDPAY_CC_STATUS == 'True') ? true : false);

if ( ( $order->info['total' ] < 300) && ( $order->info['total' ] > 11)) {

$this ->enabled = false;



This one works no problem, if I copy this if statement to the other worldpay.php that works as well.


The problem is that dependent on the if condition worldpay works or does not work, I get error in worldpay website:


Sorry, there was an error in processing this transaction:

The information sent from the merchant's site is invalid or incomplete. Please send the following information to the merchant:

The transaction cannot be processed due to one or more of the following:


the installation ID field is blank or contains invalid characters

a different submission protocol is required. For instance, a more secure submission may be required

the installation number is invalid


I have searched the forums but no-one seems to have tested this in v1.6/1.8 which has global $order;

Link to comment
Share on other sites

Thank God! Solved it after much prayer and loads of frustrating nights?


Looks like payment modules get called twice, before being sent off to card companies.


Once at checkout_payment.php, and again at checkout_confirmation.php


$order->info['total' ] is ok the first time, which is what I use for checking the order value, the second time it is null, so I simply make sure it is not null when disabling the payment module, works with worldpay and nochex?.

// BOM
// Dynamic disable mod 24/05/06 Disable for trades less than ?11
	if ( ($this->enabled == true) && ( $order->info['total' ] < 11) && ( $order->info['total' ] !=null) ) {
	  $this->enabled = false;
// EOM

Can anyone tell me if my mod will cause problems elsewhere? As I am not brilliant at php, and only worked this out by echoing variables during the checkout process.

Edited by hrhstephen
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...