0

我正在一个网站上工作,其他人将通过贝宝在网站上出售他们的东西,在从贝宝成功交易后,我很困惑如何在我的网站的个人资料中添加相同的金额。

4

1 回答 1

0

此页面显示了您在处理付款后可以从 PayPal 取回的内容。

IPN 和 PDT 变量

这是我在 Codeigniter 中制作的示例。

/* Receives a form data from paypal that is processed after payment goes through.
 * It will update the database entry with a transaction id. 
 */
 function epayment_notify(){
    $this->load->model('pament_notice_model');

    echo "Hi<br>";
    $postvars = isset($_POST)? $_POST : array("no post");
    /* echo "</pre>Post Vars:<br><pre>";
    print_r($postvars);
    echo "</pre>Refurl:<br><pre>";
    Check for the transaction ID and put it in the pament_notice table if possible. 
    */
    if (isset($postvars['item_number']) &&  $postvars['item_number'] > 0 && isset($postvars['txn_id'])){

        /* make sure that payment_number is empty on this row. */ 
        log_message('info',"PayPal transaction received.");

        if ($this->pament_notice_model->make_sure_payment_number_is_empty($postvars['item_number'])){   
            //writes the message to the local log file in CI
            log_message('debug',"PayPal payment number is empty.");

            /* set the txn_id in the slot */
            $data = array('payment_number' => $postvars['txn_id']);
            $this->db->where('entry_id',$postvars['item_number']);
            $this->db->update('pament_notice',$data);
            log_message('debug',"payment number updated. item:".$postvars['item_number']);
            log_message('debug',"payment actual cost. payment_gross:".$postvars['payment_gross']);

        }  else {
            log_message('error',"PayPal transaction attempted on non-empty payment number.");
            if (isset($postvars['item_number']))
                log_message('error',"failed request item_number :".$postvars['item_number']);
            if (isset($postvars['txn_id']))
                log_message('error',"failed request txn_id:". $postvars['txn_id']); 
        }   

    } else {
        log_message('info',"PayPal payment transaction sent with invalid data.");
        if (!isset($postvars['item_number']))
            log_message('error',"item_number is not set");

        if (isset($postvars['item_number']))
            log_message('error',"failed request item_number :".$postvars['item_number']);

        if (!isset($postvars['txn_id']))
            log_message('error',"txn_id is not set\n");

        if (isset($postvars['txn_id']))
            log_message('error',"failed request txn_id:". $postvars['txn_id']); 
    }
}
于 2013-04-20T12:31:19.310 回答