This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/checkout/classes/Model/Checkout.php

49 lines
1002 B
PHP
Raw Normal View History

2010-11-29 22:41:08 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides checkout capabilities.
*
* @package OSB
* @subpackage Checkout
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Checkout extends ORM_OSB {
2010-11-29 22:41:08 +00:00
/**
* Calcuale the fee for this checkout method
2010-11-29 22:41:08 +00:00
*
* @param $amt The amount the fee will be based on
2010-11-29 22:41:08 +00:00
*/
public function fee($amt) {
if (! $this->fee_passon)
return 0;
2010-11-29 22:41:08 +00:00
$net = $amt;
2010-11-29 22:41:08 +00:00
if (! is_null($this->fee_fixed))
$net += $this->fee_fixed;
2010-11-29 22:41:08 +00:00
if (! is_null($this->fee_variable))
$net /= (1-$this->fee_variable);
2010-11-29 22:41:08 +00:00
return Currency::round($net-$amt);
}
2010-11-29 22:41:08 +00:00
/**
* Return the object of the checkout plugin
*/
public function plugin($type='') {
$c = Kohana::classname('Checkout_Plugin_'.$this->plugin);
2010-11-29 22:41:08 +00:00
if (! $this->plugin OR ! class_exists($c))
return NULL;
2010-11-29 22:41:08 +00:00
$o = new $c($this);
2010-11-29 22:41:08 +00:00
return $type ? $o->$type : $o;
2010-11-29 22:41:08 +00:00
}
}
?>