First of all I had my sandbox merchant account configured to receive IPN. I will show you the first half of my codes that is sent to Paypal:
function process() {
$my_email = '[email protected]';
$item_name = $this->input->post('item_name');
$amount = $this->input->post('amount');
$function = $this->input->post('function');
$return_url = base_url() . 'order/'.$function;
$cancel_url = 'http://cancel.com';
$notify_url = base_url() . 'test';
$querystring .= "?business=" . urlencode($my_email) . "&";
$querystring .= "item_name=" . urlencode($item_name) . "&";
$querystring .= "amount=" . urlencode($amount) . "&";
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
$querystring .= "return=" . urlencode($return_url) . "&";
$querystring .= "cancel_return=" . urlencode($cancel_url) . "&";
$querystring .= "notify_url=" . urlencode($notify_url);
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr' . $querystring);
}
The customer is redirected to PayPal to complete payment. When the Pay button is clicked, I checked to see if any POST variable is received:
class Test extends CI_Controller{
function index(){
foreach ($_POST as $key => $value) {
echo $key . ' ' . $value . '<br/>';
}
}
}
But there is none received and I do not know where the problem is. Please give your advices, thanks!
It isn't. PayPal invokes the
notifyURL
separately at a later time, not 'when the Pay button is clicked'. When PayPal returns to your site, all you know is that they have been to PayPal. In any case you shouldn't do anything of value for the customer until PayPal tells you that you actually have the money.