我是 codeigniter 的新手,到目前为止,我在开发我的第一个应用程序方面做得很好。但是,当我尝试将 CI_MERCHANT 库集成到该站点时,我被重定向到贝宝就好了,我什至可以成功完成交易并被重定向到我的网站。但是,除了提取此信息并将其发布到数据库之外,我还停留在如何验证贝宝发送到我的应用程序的“隐藏信息”上。
在我的控制器中,我有这个:
public function place_order($id=NULL){
$this->merchant->load('paypal_express');
$id=$this->session->userdata('id');
$customer_id=$id;
$rules=$this->order_m->rules_place_order;
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == FALSE) // validation hasn't been passed
{
$this->data['subview']='customer/order_view';
$this->load->view('templates/header_customer');
$this->load->view('customer/_layout_main',$this->data);
$this->load->view('templates/footer_customer');
}
else // passed validation proceed to post success logic
{
// build array for the model
$data=$this->order_m->array_from_order(array('topic_title','discipline','academic_level','type_of_service','paper_format','pages','no_of_sources','no_of_slides','paper_details','deadline','timezones'));
$data['customer_id']=$id;
$this->order_m->save_data($data);
$this->db->where('customer_id',$id);
//get the last inserted id
$no=$this->db->insert_id();
$settings=$this->merchant->default_settings();
//payment for order
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => 'http://localhost/customers/order/paypal',
'cancel_url' => 'http://localhost/customers/order'
);
$response=$this->merchant->purchase($params);
}
}
public function paypal(){
var_dump($_GET);
$this->merchant->load('paypal_express');
$settings=$this->merchant->default_settings();
$params = array(
'amount' => 100.00,
'currency' => 'USD',
);
$response=$this->merchant->purchase_return($params);
var_dump($response);
if ($response->status() == Merchant_response::AUTHORIZED)
{
echo "status is AUTHORIZED";
}
if ($response->status() == Merchant_response::FAILED)
{
echo "status is FAILED";
}
if ($response->status() == Merchant_response::REDIRECT)
{
echo "status is REDIRECT";
}
if ($response->status() == Merchant_response::COMPLETE)
{
echo "status is COMPLETE";
}
if ($response->status() == Merchant_response::REFUNDED)
{
echo "status is REFUNDED";
}
这将我成功重定向到贝宝,我可以完成交易。但是,我无法从这里继续,因为我是付款处理的新手。请为我指明正确的方向: 1. 使用贝宝验证每笔交易,并能够将这些信息可视化并发布到我的数据库中。2. 将我在将客户重定向到贝宝之前发布到数据库的信息与我从贝宝收到的信息进行比较。