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 Permalink Normal View History

2013-10-10 02:44:53 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides checkout capabilities.
*
* @package Checkout
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Checkout extends ORM_OSB {
protected $_has_many = array(
'payment'=>array(),
2014-05-20 11:49:52 +00:00
'service'=>array('through'=>'account_billing','foreign_key'=>'checkout_id'),
2013-10-10 02:44:53 +00:00
);
protected $_sorting = array('name'=>'ASC');
protected $_form = array('id'=>'id','value'=>'name');
2013-10-10 02:44:53 +00:00
/**
* Calcuale the fee for this checkout method
*
* @param $amt The amount the fee will be based on
*/
public function fee($amt) {
if (! $this->fee_passon)
return 0;
$net = $amt;
if (! is_null($this->fee_fixed))
$net += $this->fee_fixed;
if (! is_null($this->fee_variable))
$net /= (1-$this->fee_variable);
return Currency::round($net-$amt);
}
/**
* Return the object of the checkout plugin
*/
public function plugin($type='') {
$c = Kohana::classname('Checkout_Plugin_'.$this->plugin);
if (! $this->plugin OR ! class_exists($c))
return NULL;
$o = new $c($this);
return $type ? $o->$type : $o;
}
}
?>