Reputation: 51
I am a newbie to codeigniter and so far I have been doing great in developing my first application. However, when I tried to integrate CI_MERCHANT library to the site I am getting redirected to paypal just fine and I can even complete the transaction successfully and get redirected to my website. However, I am stuck on how to verify the "hidden information" sent by paypal to my application in addition to extracting this information and posting it to the database.
in my controller I have this:
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";
}
This redirects me successfully to paypal and I can complete the transaction. However, I am unable to proceed from here since I am a newbie to payment processing. Kindly point me in the right direction on how to: 1. Verify every transaction with paypal and be able to visualize and post this information to my database. 2. Compare the information I posted to the database prior to redirecting the customer to paypal with what I receive from paypal.
Upvotes: 2
Views: 1769
Reputation: 13263
You need to call the purchase_return() method when the customer is sent to your return_url. This will confirm the transaction with PayPal.
Upvotes: 0
Reputation: 35404
First check the detailed info about IPN
here
When you are creating button in step3 you can specify IPN the url
Key points
You will receive the data at IPN url in $_POST
variable
read that $_POST
variable with mail('email', 'subject', 'data with $_POST')
or writing into the log file
Upvotes: 1