我正在尝试整合 PHP APIPAYPAL Express Checkout . 根据Paypal提供的文档,所有代码都很好 . 我添加了商家电子邮件,所有参数都是正确的 .

但后来我用来测试,打开一个弹出窗口并成功登录沙盒帐户 . 项目详细信息显示在那里,然后单击“立即付款”按钮,弹出窗口将关闭,我将离开此页面:

https://www.sandbox.paypal.com/webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow?execution=e1s2

并且永远不会返回商家网站 . 以下是将用户发送到paypal的控制器代码:

/**
     * Purchase the item and then redirect to the paypal page
     * @param type $id
     */
    public function purchase($id = '') {
        //Loading the required helpers and the libraries which is to be used in this function
        $this->load->helper('paypal');
        //Get all the item fields from the database
        //----------------------------------------------------------------------
        $item_fields = itemsfieldsquery::create()->filterByitemid($id)->find();
        //Fetch the requested item form the database with its detail 
        //----------------------------------------------------------------------
        $item = itemsquery::create()->filterByid($id)->findOne();

        //Fetch the item author detail from the database
        //----------------------------------------------------------------------
        $user_detail = userprofilequery::create()->filterByid(useritemsquery::create()->filterByitemid($id)->findOne()->getuserid())->findOne();
        //set the array wit the kay 
        foreach ($item_fields as $fields) {
            $data[categoriesfieldquery::create()->filterByid($fields->getfieldid())->findOne()->getfieldtype()] = $fields->getfieldvalue();
        }

        // ==================================
        // PayPal Express Checkout Module
        // ==================================
        //'------------------------------------
        //' The paymentAmount is the total value of
        //' the purchase.
        //'
        //' TODO: Enter the total Payment Amount within the quotes.
        //' example : $paymentAmount = "15.00";
        //'------------------------------------
        $paymentAmount = $data['item_price'];

        //'------------------------------------
        //' The currencyCodeType
        //' is set to the selections made on the Integration Assistant
        //'------------------------------------
        $currencyCodeType = "USD";
        $paymentType = "Sale";

        //'------------------------------------
        //' The returnURL is the location where buyers return to when a
        //' payment has been succesfully authorized.
        //'
        //' This is set to the value entered on the Integration Assistant
        //'------------------------------------
        $returnURL = site_url('item/transaction');

        //'------------------------------------
        //' The cancelURL is the location buyers are sent to when they hit the
        //' cancel button during authorization of payment during the PayPal flow
        //'
        //' This is set to the value entered on the Integration Assistant
        //'------------------------------------
        $cancelURL = site_url('item/transaction');

        //'------------------------------------
        //' Calls the SetExpressCheckout API call
        //'
        //' The CallSetExpressCheckout function is defined in the file PayPalFunctions.php,
        //' it is included at the top of this file.
        //'-------------------------------------------------

        $items = array();
        $items[] = array('name' => $item->getitemname(), 'amt' => $paymentAmount, 'qty' => 1, 'custom' => $id);

        //::ITEMS::
        // to add anothe item, uncomment the lines below and comment the line above
        // $items[] = array('name' => 'Item Name1', 'amt' => $itemAmount1, 'qty' => 1);
        // $items[] = array('name' => 'Item Name2', 'amt' => $itemAmount2, 'qty' => 1);
        // $paymentAmount = $itemAmount1 + $itemAmount2;
        // assign corresponding item amounts to "$itemAmount1" and "$itemAmount2"
        // NOTE : sum of all the item amounts should be equal to payment amount

        $resArray = SetExpressCheckoutDG($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $items);

        $ack = strtoupper($resArray["ACK"]);
        if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
            $token = urldecode($resArray["TOKEN"]);
            //Redirect user to the paypal 
            RedirectToPayPalDG($token);
        } else {
            //Display a user friendly Error on the page using any of the 
            //following error information returned by PayPal
            //------------------------------------------------------------------
            $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
            $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
            $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
            $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);

            $data['error'] = "SetExpressCheckout API call failed. ";
            $data['error'] .= "Detailed Error Message: " . $ErrorLongMsg;
            $data['error'] .= "Short Error Message: " . $ErrorShortMsg;
            $data['error'] .= "Error Code: " . $ErrorCode;
            $data['error'] .= "Error Severity Code: " . $ErrorSeverityCode;
            //Paint the page if we got the error
            //------------------------------------------------------------------
            $this->stencil->paint('item/thanks', $data);
        }
        return;
    }

任何人都可以帮我解决这个错误或有任何想法吗?