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

56 lines
1.2 KiB
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.
*
2013-03-19 22:35:19 +00:00
* @package Checkout
2010-11-29 22:41:08 +00:00
* @category Models
* @author Deon George
2013-03-19 22:35:19 +00:00
* @copyright (c) 2009-2013 Open Source Billing
2010-11-29 22:41:08 +00:00
* @license http://dev.osbill.net/license.html
*/
class Model_Checkout extends ORM_OSB {
protected $_has_many = array(
'account'=>array('through'=>'account_billing','foreign_key'=>'checkout_plugin_id'),
'payment'=>array(),
);
protected $_sorting = array('name'=>'ASC');
protected $_form = array('id'=>'id','value'=>'name');
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
}
}
?>