我坚持在codeigniter上集成paypal支付网关我正在使用当前的库https://github.com/romaldyminaya/ci_paypal
由于库只包含项目的静态值,但我需要获取来自我的购物车的商品,我怎样才能将它们带到 $this->paypal->add('T-shirt',2.99,6);
my controller function:
public function do_purchase(){
$config['business'] = 'babar.seller@gmail.com';
$config['cpp_header_image'] = ''; //Image header url [750 pixels wide by 90 pixels high]
$config['return'] = 'http://localhost/final-project/index.php/mysite/modify_payment';
$config['cancel_return'] = 'http://final-project/mysite/canceled.php';
$config['notify_url'] = 'process_payment.php'; //IPN Post
$config['production'] = FALSE; //Its false by default and will use sandbox
$config["invoice"] = random_string('numeric',8); //The invoice id
$this->load->library('paypal',$config);
#$this->paypal->add(<name>,<price>,<quantity>[Default 1],<code>[Optional]);
$this->paypal->add('T-shirt',2.99,6); //First item
$this->paypal->add('Pants',40); //Second item
$this->paypal->add('Blowse',10,10,'B-199-26'); //Third item with code
$this->paypal->pay(); //Proccess the payment
}
public function modify_payment(){
$received_data = print_r($this->input->post(),TRUE);
echo "<pre>".$received_data."<pre>";
$this->load->view('mysite/modify_payment',$received_data);
}
public function cart()
{
$cart = $this->cart->contents();
//print_r($cart);
//die;
//$data['user_id']=$this->mainmodel->get_user_i($user_id);
$this->load->view('mysite/cart');
$this->load->view('mysite/include/footer');
}
cart view :
<?php $i = 1; ?>
<?php foreach ($this->cart->contents() as $items): ?>
<?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
<tr>
<td> <input name="qty[<?php echo $items['rowid'];?>]" id="qty" type="text" value="<?php echo $items['qty']?>" class="input" />
</td>
<td>
<?php echo $items['name']; ?>
<?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
<p>
<?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
<strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?>
<?php endforeach; ?>
</p>
<?php endif; ?>
1 回答
我所做的是有一个paypal库类处理添加,只是简单地硬编码一些产品