Cart work for payments and Paypal work to test
This commit is contained in:
56
modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php
Normal file
56
modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides PAYPAL CART support
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Plugins/Paypal
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal {
|
||||
private $test_mode = TRUE;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user