2012-05-20 13 views
0

我正在使用CI IPN庫,並且就其功能而言,一切運行順利,並且所有txn信息都被提交到數據庫,這意味着該腳本被調用並運行。 但是,當我嘗試在成功的txn的情況下添加我自己的指令 - 即向客戶端發送電子郵件並將其詳細信息添加到數據庫 - 它完全忽略了我的代碼。我試圖刪除「如果成功」的條件,但它仍然不起作用。 需要注意的是,當我通過另一個控制器的直接調用在IPN控制器之外運行這些模型時,它們完美運行。 下面是代碼:CodeIgniter的IPN庫 - 腳本忽略我的代碼

class Ipn extends CI_Controller { 

    // To handle the IPN post made by PayPal (uses the Paypal_Lib library). 
    public function index() 

    { 

    $this->load->library('PayPal_IPN'); // Load the library 

    // Try to get the IPN data. 
    if ($this->paypal_ipn->validateIPN()) 
    { 
     // Succeeded, now let's extract the order 
     $this->paypal_ipn->extractOrder(); 

     // And we save the order now 
     $this->paypal_ipn->saveOrder(); 

     // Now let's check what the payment status is and act accordingly 
     if ($this->paypal_ipn->orderStatus == PayPal_IPN::PAID) 
     { 
      $this->load->model("register_model"); // my own code 
      $this->register_model->insert(); // my own code 
      $this->register_model->email_customer(); //my own code 
     } // end if PAID 
    } 
    else // Just redirect to the root URL 
    { 
     $this->load->helper('url'); 
     redirect('/', 'refresh'); 
    } // end if validates 
    } // end function 
} // end class 

TIA的善意幫助。 Matanya

+0

嘗試調試$ this-> paypal_ipn-> orderStatus。 btw什麼是paypal_ipn和orderStatus? –

+0

paypal_ipn是在腳本開始時調用的庫(一個類)的名稱。 orderStatus是該類的一種方法,它返回訂單的狀態 - 付款(即完成),等待(即等待)或拒絕。正如我所說,即使當我刪除這種情況下,我的代碼不會運行 – Matanya

回答

1

調試您的貝寶IPN代碼可能有點噩夢,我有類似的麻煩,並最終將我的控制器內的變量記錄到一個文件。

您確定您的「register_model」模型沒有問題嗎?也許嘗試添加幾個logs,檢查您收到的變量。如果它記錄並且看起來都正確,則需要查看「register_model」模型。