Php 找不到';取消返回';paypal沙箱页面上的选项,使用codeigniter和paypal库

Php 找不到';取消返回';paypal沙箱页面上的选项,使用codeigniter和paypal库,php,codeigniter,paypal,paypal-sandbox,Php,Codeigniter,Paypal,Paypal Sandbox,我正在尝试在我的Codeigniter项目中使用paypal库 我能够导航到paypal n在沙盒上为产品付费,问题是 paypal上没有取消重新运行选项 付款完成后没有返回url 下面的代码是我的控制器代码 $this->load->library('paypal'); $config['business'] = 'QD8HYTTSE4M38'; $config['cpp_header_image'] = ''; //Image h

我正在尝试在我的Codeigniter项目中使用paypal库

我能够导航到paypal n在沙盒上为产品付费,问题是

  • paypal上没有取消重新运行选项
  • 付款完成后没有返回url
  • 下面的代码是我的控制器代码

    $this->load->library('paypal');
    
        $config['business']             = 'QD8HYTTSE4M38';
        $config['cpp_header_image']     = ''; //Image header url [750 pixels wide by 90 pixels high]
        $config['return']               = 'main/viewAds/info.php';
        //echo $config['return'];
    
        $config['cancel_return']        = $this->config->base_url() .'main/viewAds/22';
        $config['notify_url']   = $this->config->base_url() .'main/viewAds/30';
    
        $config['production']           = FALSE; //Its false by default and will use sandbox
    
        $config["invoice"]              = '843843'; //The invoice id
    
        $this->load->library('paypal',$config);
    
        #$this->paypal->add(<name>,<price>,<quantity>[Default 1],<code>[Optional]);
    
        $this->paypal->add('T-shirt',1,1); //First item
    
    
        $this->paypal->pay(); //Proccess the payment
    
    下面是图书馆

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    */ 类贝宝{

    var $config         = Array();
    var $production_url = 'https://www.paypal.com/cgi-bin/webscr?';
    var $sandbox_url    = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
    var $item           = 1;
    
    /**
     * Constructor
     *
     * @param   string
     * @return  void
     */
    public function __construct($props = array())
    {
        $this->__initialize($props);
        log_message('debug', "Paypal Class Initialized");
    }
    // --------------------------------------------------------------------
    
    /**
     * initialize Paypal preferences
     *
     * @access  public
     * @param   array
     * @return  bool
     */
    function __initialize($props = array())
    {
        #Account information
        $config["business"]     = 'QD8HYTTSE4M38'; //Account email or id
        $config["cmd"]          = '_cart'; //Do not modify
    
        $config["production"]   = FALSE;
    
        #Custom variable here we send the billing code-->
        $config["custom"]   = '';
        $config["invoice"]  = ''; //Code to identify the bill
    
        #API Configuration-->
        $config["upload"]        = '1'; //Do not modify
        $config["currency_code"] = 'USD'; //http://bit.ly/anciiH
        $config["disp_tot"] = 'Y';
    
        #Page Layout -->
        $config["cpp_header_image"]         = ''; //Image header url [750 pixels wide by 90 pixels high]
        $config["cpp_cart_border_color"]    = '000'; //The HTML hex code for your principal identifying color
        $config["no_note"]  = 1; //[0,1] 0 show, 1 hide
    
        #Payment Page Information -->
        $config["return"]           = ''; //The URL to which PayPal redirects buyers’ browser after they complete their payments.
        $config["cancel_return"]    = ''; //Specify a URL on your website that displays a “Payment Canceled†page.
        $config["notify_url"]       = '';  //The URL to which PayPal posts information about the payment (IPN)
        $config["rm"] = '2'; //Leave this to get payment information 
        $config["lc"] = 'EN'; //Languaje [EN,ES]
    
        #Shipping and Misc Information -->
        $config["shipping"]     = '';
        $config["shipping2"]    = '';
        $config["handling"]     = '';
        $config["tax"]          = '';
        $config["discount_amount_cart"] = ''; //Discount amount [9.99]
        $config["discount_rate_cart"]   = ''; //Discount percentage [15]
    
        #Customer Information -->
        $config["first_name"]       = '';
        $config["last_name"]        = '';
        $config["address1"]         = '';
        $config["address2"]         = '';
        $config["city"]             = '';
        $config["state"]            = '';
        $config["zip"]              = '';
        $config["email"]            = '';
        $config["night_phone_a"]    = '';
        $config["night_phone_b"]    = '';
        $config["night_phone_c"]    = '';
    
        /*
         * Convert array elements into class variables
         */
        if (count($props) > 0)
        {
            foreach ($props as $key => $val)
            {
                $config[$key] = $val;
            }
        }
        $this->config = $config;
    }
    
    // -------------------------------------------------------------------- 
    
    /**
     * Perform payment process
     *
     * @access  public
     * @param   array
     * @return  void
     */ 
    function pay(){
    
        #Convert the array to url encode variables 
        $vars =  http_build_query($this->config);
    
        if($this->config['production'] == TRUE){
            header('LOCATION:'.$this->production_url.$vars);
        }else{
            header('LOCATION:'.$this->sandbox_url.$vars);
        }
    }
    
    // -------------------------------------------------------------------- 
    
    /**
     * Add a product to the list
     *
     * @access  public
     * @param   array
     * @return  void
     */ 
    function add($item_name = '',$item_amount = NULL,$item_qty = NULL,$item_number = NULL){
        $this->config['item_name_'.$this->item]     = $item_name;
        $this->config['amount_'.$this->item]        = $item_amount;
        $this->config['quantity_'.$this->item]      = $item_qty;
        $this->config['item_number_'.$this->item]   = $item_number;
        $this->item++;
    }   
    
    } //结束贝宝类

    /*文件末尾Paypal.php/ /位置:./application/libraries/Paypal.php*/

    这是我得到的交易页面

    我期待它回到我的网站,但它只是停留在那里


    请告诉我该怎么做。谢谢。

    您使用的这个库显然使用的是PayPal标准,这并不保证用户会返回您的站点

    您可以在PayPal帐户配置文件中启用自动返回功能,但是,如果用户在重定向发生之前关闭浏览器或转到其他位置,他们将无法返回

    如果你想确保你总是回到贝宝,你需要切换到,这确实保证了用户最终会回到你的网站。我有一个很好的方法,可以让你很简单。这是我继续维护的主要版本,它与Composer一起工作,所以您可以使用它自动加载并使其在CI中可用

    或者,我有一个旧的,你可能想用它来代替。现在它已经落后不远了,但我不会像我是第一个那样保持它

    无论哪种方式,你都会和他一起工作

    我还建议你看看。它将允许您根据进入您帐户的交易实时自动化任务,而不管用户是否返回您的站点

    var $config         = Array();
    var $production_url = 'https://www.paypal.com/cgi-bin/webscr?';
    var $sandbox_url    = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
    var $item           = 1;
    
    /**
     * Constructor
     *
     * @param   string
     * @return  void
     */
    public function __construct($props = array())
    {
        $this->__initialize($props);
        log_message('debug', "Paypal Class Initialized");
    }
    // --------------------------------------------------------------------
    
    /**
     * initialize Paypal preferences
     *
     * @access  public
     * @param   array
     * @return  bool
     */
    function __initialize($props = array())
    {
        #Account information
        $config["business"]     = 'QD8HYTTSE4M38'; //Account email or id
        $config["cmd"]          = '_cart'; //Do not modify
    
        $config["production"]   = FALSE;
    
        #Custom variable here we send the billing code-->
        $config["custom"]   = '';
        $config["invoice"]  = ''; //Code to identify the bill
    
        #API Configuration-->
        $config["upload"]        = '1'; //Do not modify
        $config["currency_code"] = 'USD'; //http://bit.ly/anciiH
        $config["disp_tot"] = 'Y';
    
        #Page Layout -->
        $config["cpp_header_image"]         = ''; //Image header url [750 pixels wide by 90 pixels high]
        $config["cpp_cart_border_color"]    = '000'; //The HTML hex code for your principal identifying color
        $config["no_note"]  = 1; //[0,1] 0 show, 1 hide
    
        #Payment Page Information -->
        $config["return"]           = ''; //The URL to which PayPal redirects buyers’ browser after they complete their payments.
        $config["cancel_return"]    = ''; //Specify a URL on your website that displays a “Payment Canceled†page.
        $config["notify_url"]       = '';  //The URL to which PayPal posts information about the payment (IPN)
        $config["rm"] = '2'; //Leave this to get payment information 
        $config["lc"] = 'EN'; //Languaje [EN,ES]
    
        #Shipping and Misc Information -->
        $config["shipping"]     = '';
        $config["shipping2"]    = '';
        $config["handling"]     = '';
        $config["tax"]          = '';
        $config["discount_amount_cart"] = ''; //Discount amount [9.99]
        $config["discount_rate_cart"]   = ''; //Discount percentage [15]
    
        #Customer Information -->
        $config["first_name"]       = '';
        $config["last_name"]        = '';
        $config["address1"]         = '';
        $config["address2"]         = '';
        $config["city"]             = '';
        $config["state"]            = '';
        $config["zip"]              = '';
        $config["email"]            = '';
        $config["night_phone_a"]    = '';
        $config["night_phone_b"]    = '';
        $config["night_phone_c"]    = '';
    
        /*
         * Convert array elements into class variables
         */
        if (count($props) > 0)
        {
            foreach ($props as $key => $val)
            {
                $config[$key] = $val;
            }
        }
        $this->config = $config;
    }
    
    // -------------------------------------------------------------------- 
    
    /**
     * Perform payment process
     *
     * @access  public
     * @param   array
     * @return  void
     */ 
    function pay(){
    
        #Convert the array to url encode variables 
        $vars =  http_build_query($this->config);
    
        if($this->config['production'] == TRUE){
            header('LOCATION:'.$this->production_url.$vars);
        }else{
            header('LOCATION:'.$this->sandbox_url.$vars);
        }
    }
    
    // -------------------------------------------------------------------- 
    
    /**
     * Add a product to the list
     *
     * @access  public
     * @param   array
     * @return  void
     */ 
    function add($item_name = '',$item_amount = NULL,$item_qty = NULL,$item_number = NULL){
        $this->config['item_name_'.$this->item]     = $item_name;
        $this->config['amount_'.$this->item]        = $item_amount;
        $this->config['quantity_'.$this->item]      = $item_qty;
        $this->config['item_number_'.$this->item]   = $item_number;
        $this->item++;
    }