Cart work for payments and Paypal work to test
This commit is contained in:
@@ -11,58 +11,38 @@
|
||||
* @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(),
|
||||
);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give a cart, this will present the available checkout options
|
||||
*
|
||||
* Trial Products are NEW products
|
||||
* Cart items are NEW products
|
||||
* Invoice items are RE-OCCURING items (ie: carts are not re-occuring)
|
||||
*
|
||||
* Return the object of the checkout plugin
|
||||
*/
|
||||
public function payment_options_cart() {
|
||||
$cart = Cart::instance();
|
||||
public function plugin($type='') {
|
||||
$c = Kohana::classname('Checkout_Plugin_'.$this->plugin);
|
||||
|
||||
$available_payments = array();
|
||||
if (! $this->plugin OR ! class_exists($c))
|
||||
return NULL;
|
||||
|
||||
if ($cart->has_trial())
|
||||
$this->and_where('allow_trial','=',TRUE);
|
||||
$o = new $c($this);
|
||||
|
||||
$this->and_where('allow_new','=',TRUE);
|
||||
|
||||
foreach ($this->list_active() as $item) {
|
||||
// Check that the cart total meets the minimum requirement
|
||||
if ($item->total_minimum AND $cart->total() < $item->total_minimum)
|
||||
continue;
|
||||
|
||||
// Check the cart total meets the maximum requirement
|
||||
if (($item->total_maximum AND $cart->total() > $item->total_maximum) OR ($item->total_maximum == '0' AND $cart->total()))
|
||||
continue;
|
||||
|
||||
// Check that the payment option is available to this client based on groups
|
||||
// @todo Enable this test
|
||||
|
||||
// Check that the payment option is not prohibited by an SKU item
|
||||
// @todo Enable this test
|
||||
|
||||
// Check if this payment method is a default payment method
|
||||
// @todo Enable this test
|
||||
// By Amount
|
||||
// By Currency
|
||||
// By Group
|
||||
// By Country
|
||||
|
||||
// This payment option is valid
|
||||
array_push($available_payments,$item);
|
||||
// Sort the checkout options
|
||||
// @todo Is this required?
|
||||
}
|
||||
|
||||
return $available_payments;
|
||||
return $type ? $o->$type : $o;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user