diff --git a/application/classes/Controller/Reseller/Account.php b/application/classes/Controller/Reseller/Account.php index 178edf69..2fb1b48c 100644 --- a/application/classes/Controller/Reseller/Account.php +++ b/application/classes/Controller/Reseller/Account.php @@ -63,8 +63,9 @@ class Controller_Reseller_Account extends Controller_Account { public function action_view() { $ao = ORM::factory('Account',$this->request->param('id')); - if (! $ao->loaded() OR ! $ao->status) - HTTP::redirect(URL::link('reseller','welcome')); + + if (! $ao->loaded() OR ! $ao->status OR ! Auth::instance()->authorised($ao)) + throw HTTP_Exception::factory(403,'Account either doesnt exist, or you are not authorised to see it'); Block::factory() ->title(sprintf('Active Service for Account: %s',$ao->accnum())) diff --git a/application/classes/HTTP/Exception/403.php b/application/classes/HTTP/Exception/403.php deleted file mode 100644 index 9d78aa48..00000000 --- a/application/classes/HTTP/Exception/403.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/application/classes/HTTP/Exception/404.php b/application/classes/HTTP/Exception/404.php deleted file mode 100644 index d1277d63..00000000 --- a/application/classes/HTTP/Exception/404.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/application/classes/HTTP/Exception/501.php b/application/classes/HTTP/Exception/501.php deleted file mode 100644 index e1afe147..00000000 --- a/application/classes/HTTP/Exception/501.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/application/classes/Kohana/Exception.php b/application/classes/Kohana/Exception.php index da988205..463bb109 100644 --- a/application/classes/Kohana/Exception.php +++ b/application/classes/Kohana/Exception.php @@ -46,6 +46,7 @@ class Kohana_Exception extends Kohana_Kohana_Exception { try { if (Kohana::$config->load('debug')->show_errors) { return parent::response($e); + } else { SystemMessage::add(array( 'title'=>'An Error Occured.', @@ -57,6 +58,7 @@ class Kohana_Exception extends Kohana_Kohana_Exception { $response = Response::factory(); $response->status(302); $response->headers('Location',URL::site()); + return $response; } diff --git a/modules/cart/views/cart/payment.php b/modules/cart/views/cart/payment.php index 93b96233..9da8c803 100644 --- a/modules/cart/views/cart/payment.php +++ b/modules/cart/views/cart/payment.php @@ -16,7 +16,7 @@
- Clear + 'btn')); ?>
diff --git a/modules/checkout/classes/Checkout/Plugin/Paypal.php b/modules/checkout/classes/Checkout/Plugin/Paypal.php index 6ccaa659..5f482132 100644 --- a/modules/checkout/classes/Checkout/Plugin/Paypal.php +++ b/modules/checkout/classes/Checkout/Plugin/Paypal.php @@ -13,6 +13,9 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { protected $url_prod = 'www.paypal.com'; protected $url_test = 'www.sandbox.paypal.com'; private $ipn_test = '173.0.82.126'; + protected $email_prod = ''; // @todo This should be in the DB + protected $email_test = ''; // @todo This should be in the DB + protected $test_mode = FALSE; protected $curlopts = array( CURLOPT_CONNECTTIMEOUT => 60, @@ -31,13 +34,12 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { * User return from Paypal after payment */ public function after(Cart $co) { - SystemMessage::add(array( - 'title'=>_('Payment Processing'), - 'type'=>'info', - 'body'=>sprintf('Thank you for your payment with paypal. It will be processed and applied to your cart items automatically in due course.'), - )); + SystemMessage::factory() + ->title(_('Payment Processing')) + ->type('info') + ->body(_('Thank you for your payment with paypal. It will be processed and applied to your cart items automatically in due course.')); - HTTP::redirect('/'); + HTTP::redirect(URL::link('user','welcome')); } /** @@ -61,7 +63,7 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { // If testing if (! $cno->status OR $cno->processed OR ($debug_mode AND Request::$client_ip == $this->ipn_test)) - return ('Thank you'); + return _('Thank you'); $co = Cart::instance(isset($cno->data['custom']) ? $cno->data['custom'] : ''); @@ -83,7 +85,8 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { case 'VERIFIED': // Verify that the IPN is for us. // @todo This should be in the DB. - if ($cno->data['business'] == 'deon_1260578114_biz@graytech.net.au') { + if ($cno->data['business'] == ($this->test_mode ? $this->email_test : $this->email_prod)) { + switch ($cno->data['payment_status']) { case 'Completed': // Our cart items total. @@ -91,7 +94,7 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { $po = ORM::factory('Payment'); // Does the payment cover the cart total? - if ($this->co->fee_passon AND $cno->data['mc_gross'] == $total+$this->co->fee($total)) { + if ($this->co->fee_passon AND $cno->data['mc_gross'] === (string)($total+$this->co->fee($total))) { // Store the amounts in an array, so we can pro-rata the fee to each item. $amts = array(); @@ -135,7 +138,10 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { } - $po->old_add_item($cio->module_item)->alloc_amt = $cno->data['mc_gross_'.$c]; + $pio = $po->payment_item; + $pio->alloc_amt = $cno->data['mc_gross_'.$c]; + $pio->invoice_id = $cio->module_item; + $po->add_item($pio); break; @@ -156,7 +162,9 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { $po->date_payment = strtotime($cno->data['payment_date']); $po->checkout_id = $this->co->id; $po->notes = $cno->data['txn_id']; - $po->save(); + + if (! $po->save()) + $cno->result = array('msg'=>'Failed to save PO?','po'=>$po); // Clear the cart if (! $debug_mode) @@ -166,13 +174,19 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin { // Ignore the fee } else { -echo Debug::vars('IPN doesnt match cart total'); + $cno->result = array( + 'msg'=>'IPN doesnt match cart total', + 't'=>$total, + 'tt'=>(string)($total+$this->co->fee($total)), + 'g'=>$cno->data['mc_gross'], + 'fpo'=>$this->co->fee_passon, + 't1'=>($cno->data['mc_gross'] === (string)($total+$this->co->fee($total))), + ); + // If there is more than 1 item in the cart, we'll leave it to an admin to process. if ($cno->data['num_cart_items'] == 1) { -echo Debug::vars('Apply to cart item'); } else { // @todo - add the payment, with no payment items -echo Debug::vars('Leave for admin'); } } @@ -194,9 +208,10 @@ echo Debug::vars('Leave for admin'); $cno->status = FALSE; } - $cno->processed = TRUE; if (! $debug_mode) - $cno->save(); + $cno->processed = TRUE; + + $cno->save(); return _('Processed, thank you!'); } diff --git a/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php b/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php index fe111afa..dc2913f3 100644 --- a/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php +++ b/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php @@ -10,8 +10,6 @@ * @license http://dev.osbill.net/license.html */ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal { - private $test_mode = FALSE; - /** * Set payment via Paypal */ @@ -25,7 +23,7 @@ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal { ->set('cart',$co); $output .= Form::hidden('cmd','_cart'); - $output .= Form::hidden('business',$this->test_mode ? 'deon_1260578114_biz@graytech.net.au' : 'deon@graytech.net.au'); + $output .= Form::hidden('business',$this->test_mode ? $this->email_test : $this->email_prod); $output .= Form::hidden('bn','Graytech_BuyNow_WPS_AU'); $output .= Form::hidden('cancel_return',URL::site('checkout/cancel/'.$this->co->id,TRUE)); $output .= Form::hidden('custom',$co->id()); diff --git a/modules/checkout/classes/Controller/Checkout.php b/modules/checkout/classes/Controller/Checkout.php index ea1ae6c4..fcd9ba4f 100644 --- a/modules/checkout/classes/Controller/Checkout.php +++ b/modules/checkout/classes/Controller/Checkout.php @@ -79,6 +79,8 @@ class Controller_Checkout extends Controller_TemplateDefault { $this->response->body($cno->process()); } catch (Exception $e) { + Kohana_Exception::log($e); + $this->response->body('Received, thank you!'); } diff --git a/modules/lnApp b/modules/lnApp index 319b4b29..f3066fd3 160000 --- a/modules/lnApp +++ b/modules/lnApp @@ -1 +1 @@ -Subproject commit 319b4b29db9c1e467b34f75bb03d1d908d17afbc +Subproject commit f3066fd383a9211336c035acde462e32c38546e2 diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php index b70e0d8b..fcf86694 100644 --- a/modules/payment/classes/Model/Payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -69,7 +69,7 @@ class Model_Payment extends ORM_OSB { foreach ($this->items('ALLOC') as $pio) $result -= $pio->alloc_amt; - return $format ? Currency::display($result) : $result; + return $format ? Currency::display($result) : Currency::round($result); } /** @@ -81,7 +81,7 @@ class Model_Payment extends ORM_OSB { foreach ($this->items('CREDIT') as $pio) $result += $pio->alloc_amt*-1; - return $format ? Currency::display($result) : $result; + return $format ? Currency::display($result) : Currency::round($result); } /** diff --git a/modules/ssl/classes/Task/Ssl/Renew.php b/modules/ssl/classes/Task/Ssl/Renew.php index 35627d17..b7ccb3a8 100644 --- a/modules/ssl/classes/Task/Ssl/Renew.php +++ b/modules/ssl/classes/Task/Ssl/Renew.php @@ -19,7 +19,7 @@ class Task_SSL_Renew extends Minion_Task { * Renew a certificate */ protected function _execute(array $params) { - ORM::factory('Service',$params['id'])->plugin()->renew($params['force']); + ORM::factory('Service',$params['id'])->plugin()->renew(Minion_CLI::options('force')); } } ?>