新提交的贝宝|重要提示

时间:2018-09-23 06:42:52

标签: codeigniter

我有可以通过贝宝(Paypal)购买的代码,可以正常工作..

我想在“付款表”中添加新的文件插入,但是当我添加新文件时,代码未将我的付款保存到“付款表”中。.

  

这里购买功能

 function buy(){

    // Set variables for paypal form
    $returnURL = base_url().'paypal/success';
    $cancelURL = base_url().'paypal/cancel';
    $notifyURL = base_url().'paypal/ipn';

    // Get product data from the database
    $products = $this->product->getRows($id);

    // Get current user ID from the session

    $userID = 6;
    //$_SESSION['userID'];
    $type =$products['type'] ;

    // Add fields to paypal form
    $this->paypal_lib->add_field('return', $returnURL);
    $this->paypal_lib->add_field('cancel_return', $cancelURL);
    $this->paypal_lib->add_field('notify_url', $notifyURL);
    $this->paypal_lib->add_field('item_name', $products['name']);
    $this->paypal_lib->add_field('item_number',  $products['id']);
    $this->paypal_lib->add_field('amount',  $products['price']);
    $this->paypal_lib->add_field('custom',  $userID); 

//我将其添加为从产品标签中获取产品类型

    $this->paypal_lib->add_field('os0', $type ); /// THIS THIS THIS 

    // Render paypal form
    $this->paypal_lib->paypal_auto_form();
}
  

此处IPN功能

function ipn(){
    // Paypal posts the transaction data
    $paypalInfo = $this->input->post();

    if(!empty($paypalInfo)){
        // Validate and get the ipn response
        $ipnCheck = $this->paypal_lib->validate_ipn($paypalInfo);

        // Check whether the transaction is valid
        if($ipnCheck){

            // Insert the transaction data in the database    // change here
            $data['user_id']        = $paypalInfo["custom"];
            $data['product_id']        = $paypalInfo["item_number"];
            $data['txn_id']            = $paypalInfo["txn_id"];
            $data['payment_gross']    = $paypalInfo["mc_gross"];
            $data['currency_code']    = $paypalInfo["mc_currency"];
            $data['payer_email']    = $paypalInfo["payer_email"];
            $data['payment_status'] = $paypalInfo["payment_status"];
            //////MY CHANGE HERE

             $data['product_type'] = $paypalInfo["os0"]; // THIS THIS THIS 

            $this->product->insertTransaction($data);
        }
    }
}
  

此处结束

<?php if(!empty($products)){ foreach($products as $row){ ?>
<div class="col-sm-4 col-lg-4 col-md-4">
    <div class="thumbnail">

     <div class="caption">
     <h4 class="pull-right">$<?php echo $row['price']; ?> USD</h4>
     <input type="text" name="os1" value="<?php echo $row['type']; ?>">
      <h4><a href="javascript:void(0);"><?php echo $row['name']; ?></a></h4>
     </div>

      <a href="<?php echo base_url('products/buy/'.$row['id']); ?>">

            </a>

        </div>
    </div>
</div>
    

未找到产品...

  

如果您有更好的选择,就永远不会更改完整的代码

0 个答案:

没有答案