2013-01-15 06:07:54 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides PAYPAL CART support
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Checkout
|
2013-01-15 06:07:54 +00:00
|
|
|
* @category Plugins
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
2013-01-15 06:07:54 +00:00
|
|
|
*/
|
|
|
|
class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
|
2013-02-26 03:19:32 +00:00
|
|
|
private $test_mode = FALSE;
|
2013-01-15 06:07:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set payment via Paypal
|
|
|
|
*/
|
|
|
|
public function before(Cart $co) {
|
|
|
|
$output = '';
|
|
|
|
|
|
|
|
$output .= View::factory('checkout/plugin/paypal/before')
|
|
|
|
->set('checkout',$this->co)
|
|
|
|
->set('cart',$co);
|
|
|
|
|
|
|
|
$output .= Form::open(sprintf('https://%s/cgi-bin/webscr',$this->test_mode ? $this->url_test : $this->url_prod),array('method'=>'POST'));
|
|
|
|
$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('bn','Graytech_BuyNow_WPS_AU');
|
|
|
|
$output .= Form::hidden('cancel_return',URL::site('checkout/cancel/'.$this->co->id,TRUE));
|
|
|
|
$output .= Form::hidden('custom',$co->id());
|
|
|
|
// @todo This should be dynamic
|
|
|
|
$output .= Form::hidden('currency_code','AUD');
|
|
|
|
$output .= Form::hidden('notify_url',URL::site('checkout/notify/'.$this->co->id,TRUE));
|
|
|
|
$output .= Form::hidden('return',URL::site('checkout/after/'.$this->co->id,TRUE));
|
|
|
|
$output .= Form::hidden('upload','1');
|
|
|
|
|
|
|
|
$c = 1;
|
|
|
|
foreach ($co->contents() as $cio) {
|
|
|
|
$output .= Form::hidden('item_number_'.$c,$cio->id);
|
|
|
|
$output .= Form::hidden('item_name_'.$c,$cio->item()->i);
|
|
|
|
$output .= Form::hidden('amount_'.$c,$cio->item()->t);
|
|
|
|
$c++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= Form::hidden('item_number_'.$c,'0:PAYFEE');
|
|
|
|
$output .= Form::hidden('item_name_'.$c,'Paypal Fee');
|
|
|
|
$output .= Form::hidden('amount_'.$c,$this->co->fee($co->total()));
|
|
|
|
|
|
|
|
$output .= Form::submit('submit','Pay Now');
|
|
|
|
$output .= Form::close();
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|