douqiangchuai7674 2017-07-11 13:23
浏览 100
已采纳

Paypal沙箱错误:您已请求过期的PayPal版本

enter image description here

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;  
        }

}
?>
  • 写回答

2条回答 默认 最新

  • douchen4547 2017-07-14 05:55
    关注

    The problem was occuring due to this line:

    <input type="hidden" name="cmd" value="" />
    

    I replaced it with:

    <input type="hidden" name="cmd" value="_xclick" />
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。