1

所以我正在更新一个使用 Zend 框架的慈善网页。我以前从未使用过它,但它几乎用于网站上的所有内容。我已经能够弄清楚大多数东西,但这有点超出我的能力。

他们想要的是让他们的用户(必须先登录)从他们的页面中选择一些项目,然后通过 PayPal 支付这些项目的能力。为了实现这一点,我在 PHP 中使用了带有 curl 的 PayPal REST 函数。

问题是用户第一次登录我们的网站,选择他们的项目,然后被发送到贝宝页面进行支付(然后又被踢回我们的网站),它会将他们从我们的网站中注销。这导致了一堆问题,最明显的是我无法执行交易,所以用户认为他们已经付款但我们不会收到钱。

奇怪的是,如果用户重新登录到我们的页面,然后再次尝试相同的操作,它会完美运行(即不会将它们注销)。

在下面的代码中,我已经有了我的 PayPal 令牌并且 $data 设置正确(并且我删除了一些不相关的内容):

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.paypal.com/v1/payments/payment");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                                           "Content-Type: application/json",
                                           "Authorization: Bearer " . $jsontoken->access_token, 
                                           "Content-length: ".strlen($data))
           );                   

$curlresult2 = curl_exec($ch);

foreach ($json_resp['links'] as $link)
{
    if($link['rel'] == 'approval_url')
    {
        $payment_detail_url = $link['href'];
        $payment_detail_method = $link['method'];
    }
}

session_write_close();
$this->_redirect($payment_detail_url);
4

0 回答 0