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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?