You have requested an outdated version of PayPal. This error often results from the use of bookmarks.
I get this error when I login via a buyer account in sandbox mode.
my view file:
<html>
<body>
<form method="post" action ="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="return" value="<?php echo $this->config->item('returnurl');?>" />
<input type="hidden" name="cmd" value=" " />
<input type="hidden" name="business" value="<?php echo $this->config->item('business');?>" />
<!--product 1-->
<input type="hidden" name="item_name_1" value="prod 1" />
<input type="hidden" name="item_number_1" value="p1" />
<input type="hidden" name="amount_1" value="2" />
<input type="hidden" name="quantity_1" value="1" />
<input type="submit" name="paypalbtn" value="buy with paypal">
</form>
</body>
</html>
my config file : paypal.php
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
$config['authtoken']='IDENTITY_TOKEN';
$config['posturl']='https://www.sandbox.paypal.com/cgi-bin/webscr';
$config['business']='DUMMY_FACILITATOR_EMAIL_ID';
$config['returnurl']='http://localhost/events/event_pay/success/';
$config['cancel_return']='http://localhost/events/event_pay/pay_fail';
?>
my controller file:
<?php
class event_pay extends MX_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('mdl_pay');
}
function index()
{
$this->load->view('demo');
}
function showplans()
{
$this->load->view('vw_header');
$this->load->view('vw_eventplans');
$this->load->view('vw_footer');
}
function check_events_by_user()
{
$u_id=37;
$numberofrows =$this->mdl_pay->has_paid($u_id);
echo $numberofrows;
}
function pay_success($data)
{
echo "return url function";
$this->load->view('success',$data);
}
function pay_fail()
{
echo "payment failed";
}
function success()
{
$res = $this->verifyWithPayPal($_GET['tx']);
$this->load->view('success_pay',$res);
}
function successdemo()
{
$this->load->view('vw_success_pay');
}
public function verifyWithPayPal($tx)
{
$token = $this->config->item('authtoken');
$paypal_url = $this->config->item('posturl').'?cmd=_notify-synch&tx='. $tx.'&at='.$token;
$curl= curl_init($paypal_url);
$data=array(
"cmd"=>"_notify-synch",
"tx"=>$tx,
"at"=>$token
);
$data_string=json_encode($data);
curl_setopt($curl,CURLOPT_HEADER, 0);
curl_setopt($curl,CURLOPT_POST, 1);
curl_setopt($curl,CURLOPT_POSTFIELDS,$data_string);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$headers= array(
'Content-Type:application/x-www-form-urlencoded',
'Host: www.sandbox.paypal.com',
'Connection: close'
);
curl_setopt($curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
curl_setopt($curl,CURLOPT_HTTPHEADER, $headers);
$response= curl_exec($curl);
$lines= explode("
", $response);
$keyarray = array();
if(strcmp($lines[0],"SUCCESS")==0){
for($i=1;$i<count($lines)-1; $i++){
list($key,$val)=explode("=",$lines[$i]);
$keyarray[urldecode($key)]=urldecode($val);
}
$this->getListProducts($keyarray);
}
}
public function getListProducts($result)
{
$i=1;
$data = array();
foreach($result as $key => $value)
{
if(0===strpos($key,'item_number')){
$product = array(
'buyer_firstname' => $result['first_name'],
'buyer_lastname' => $result['last_name'],
'buyer_street' => $result['address_street'],
'buyer_city' => $result['address_city'],
'buyer_zip' => $result['address_zip'],
'buyer_state' => $result['address_state'],
'buyer_country' => $result['address_country'],
'buyer_country_code' => $result['address_country_code'],
'buyer_address_status' => $result['address_status'],
'buyer_pp_email' => $result['payer_email'],
'receiver_pp_email' => $result['receiver_email'],
'transaction_id' => $result['txn_id'],
'transaction_type' => $result['txn_type'],
'buy_date' => $result['payment_date'],
'buyer_pp_id' => $result['payer_id'],
//'address_name' => $result['address_name'],
'receiver_pp_id' => $result['receiver_id'],
'receiver_pp_email' => $result['receiver_email'],
'itemnumber' => $result['item_number'],
'itemname' => $result['item_name'],
'itemquantity' => $result['quantity'],
'mc_currency' => $result['mc_currency'],
'mc_fee' => $result['mc_fee'],
'mc_gross' => $result['mc_gross'],
'payment_gross' => $result['payment_gross'] ,
'paypal_pay_time' => date('Y-m-d H:i:s'),
);
$this->mdl_pay->insert_record($product);
echo "<script>alert('Payment Successful!')</script>";
}
}
echo "return statement:at end of for loop ";
return $product;
}
}
?>