Forums / Addon Payment Modules / Show CC payment method if cart is within admin controlled min/max settings

Show CC payment method if cart is within admin controlled min/max settings

Locked

Views: 2,077

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
13 Sep 2008, 7:07 PM
#1
alisonken1 avatar

alisonken1

New Zenner

Join Date:
Feb 2008
Location:
Rancho Cucamonga, CA, USA
Posts:
5
Plugin Contributions:
0

Show CC payment method if cart is within admin controlled min/max settings

THANKS FOR THE HELP FROM THE ONLINE GUYS AT #zencart at freenode.net

This mod will allow you to show credit card payment method depending on the shopping cart total. For this example, the following settings are used:

  • Online CC gateway has $2500 limit
  • Authroize.net-AIM module installed, configured, and enabled (with mods)
  • Manual CC processing module installed, configured, and enabled (with mods)
  • Check/COD module installed, configured, and enabled
  • Some of your single-item products+shipping+tax/vat may exceed $2500 limit

At checkout time cart total $2350.75. Following options will be presented:

  • Credit Card
  • Check/COD

At checkout time cart total $3505.60. Following options will be presented:

  • Credit Card
  • Check/COD

In scenario 1 where cart is under limit, the CC payment will be processed online by Authorize.net gateway and an email from Authorize.net will be sent to the admin email.

In scenario 2 where cart is over the limit, the CC payment will be forwarded to the admin email for manual processing the credit card.

In both cases, only 1 credit card payment method is presented to the customer.

===== [ZENCART_BASE]/includes/modules/payment/cc.php

This part retrieves the limits from the configuration options

function cc() {
    // first part skipped - add the next 2 lines towards the end
    $this->cc_min = MODULE_PAYMENT_CC_MIN; // ** Add this
    $this->cc_max = MODULE_PAYMENT_CC_MAX; // ** Add this

    if (is_object($order)) $this->update_status(); // ** Leave this alone
}

This part checks if we want to show this CC payment option

function selection() {
    global $order;

    /**
     * The following 2 lines check if cart total is within the limits
     * If outside of limits, then disable module for processing for this transaction only
     */
    $this->enabled = (($this->enabled && $this->cc_min > 0 && $order->info["total"] < $this->cc_min) ? false : $this->enabled );
    $this->enabled = (($this->enabled && $this->cc_max > 0 && $order->info["total"] >= $this->cc_max) ? false : $this->enabled );

    // Wrap the rest of the function in an enabled check
    if ( $this->enabled) {
        for ($i=1; $i<13; $i++) {
          // rest of function stays the same
        }
    }     // ** Add closing bracket here for if .... statement
  }

This part adds limit options in admin->modules->payment->manual cc module configuration

  function install() {
    // add at the end of the function
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Charge Amount', 'MODULE_PAYMENT_CC_MIN', '0', 'Would you like to set a MINIMUM charge amount for this payment option? Leave at 0 for no mimimum. Whole dollar amounts only.', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Charge Amount', 'MODULE_PAYMENT_CC_MAX', '0', 'Would you like to set a MAXIMUM charge amount for this payment option? Leave at 0 for no maximum. Whole dollar amounts only.', '6', '0', now())");
  }

The following adds the MIN/MAX keys to they will be enabled

function keys() {
// ** Add MODULE_PAYMENT_CC_MIN
// ** Add MODULE_PAYMENT_CC_MAX

return array('MODULE_PAYMENT_CC_STATUS', 'MODULE_PAYMENT_CC_EMAIL', 'MODULE_PAYMENT_CC_ZONE', 'MODULE_PAYMENT_CC_ORDER_STATUS_ID', 'MODULE_PAYMENT_CC_SORT_ORDER', 'MODULE_PAYMENT_CC_COLLECT_CVV', 'MODULE_PAYMENT_CC_MIN', 'MODULE_PAYMENT_CC_MAX' );
}

===== [ZENCART_BASE]/includes/modules/payment/authorizenet_aim.php

Do the same changes to authorizenet_aim.php except:

instead of changing function cc(), make changes to function authorizenet_aim()

Other function changes are the same.

With possible minor alterations, the same code could be used for other CC processing modules.

13 Sep 2008, 7:20 PM
#2
alisonken1 avatar

alisonken1

New Zenner

Join Date:
Feb 2008
Location:
Rancho Cucamonga, CA, USA
Posts:
5
Plugin Contributions:
0

Re: Show CC payment method if cart is within admin controlled min/max settings

Missed the editing window - but.

  • Authorize.net AIM limits MINIMUM=0 MAXIMUM=2500
  • Manual CC limits MINIMUM=2500 MAXIMUM=0
13 Sep 2008, 10:35 PM
#3
alisonken1 avatar

alisonken1

New Zenner

Join Date:
Feb 2008
Location:
Rancho Cucamonga, CA, USA
Posts:
5
Plugin Contributions:
0

Re: Show CC payment method if cart is within admin controlled min/max settings

Once the above mods are in place, just login to admin, then

  • Remove the module if already installed
  • Install the module

The option limits will now be in the configuration for the module