Jump to content

【请教】Moderator,请问PS怎么接收支付网关传过来的参数呢?


ding

Recommended Posts

我现在做一个支付网关,参考的是PAYPAL1.6的,但是不知道怎么接收由网关传过来的参数,无法进行校验,我见他里面有notify_url和return 两个地址,一个是校验地址,一个是返回地址,但是我现在用的网关只有一个返回地址,参数会返给这个返回地址,我现在就想接收这些参数,但是一直找不到切入点,请问有人知道没?谢谢

Link to comment
Share on other sites

理解/modules/paypal/validation.php里的这段代码:

// Getting PayPal data...
if (function_exists('curl_exec'))
{
   // curl ready
   $ch = curl_init('https://' . $paypalServer . '/cgi-bin/webscr');

   // If the above fails, then try the url with a trailing slash (fixes problems on some servers)
    if (!$ch)
       $ch = curl_init('https://' . $paypalServer . '/cgi-bin/webscr/');

   if (!$ch)
       $errors .= $paypal->getL('connect').' '.$paypal->getL('curlmethodfailed');
   else
   {
       curl_setopt($ch, CURLOPT_POST, true);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       curl_setopt($ch, CURLOPT_HEADER, false);
       curl_setopt($ch, CURLOPT_TIMEOUT, 30);
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

       $result = curl_exec($ch);

       if ($result != 'VERIFIED')
           $errors .= $paypal->getL('curlmethod').$result.' cURL error:'.curl_error($ch);
       curl_close($ch);
   }
}
elseif (($fp = @fsockopen('ssl://' . $paypalServer, 443, $errno, $errstr, 30)) || ($fp = @fsockopen($paypalServer, 80, $errno, $errstr, 30)))
{
   // fsockopen ready
   $header = 'POST /cgi-bin/webscr HTTP/1.0'."\r\n" .
         'Host: '.$paypalServer."\r\n".
         'Content-Type: application/x-www-form-urlencoded'."\r\n".
         'Content-Length: '.Tools::strlen($params)."\r\n".
         'Connection: close'."\r\n\r\n";
   fputs($fp, $header.$params);

    $read = '';
    while (!feof($fp))
   {
       $reading = trim(fgets($fp, 1024));
       $read .= $reading;
       if (($reading == 'VERIFIED') || ($reading == 'INVALID'))
       {
            $result = $reading;
           break;
       }
    }
   if ($result != 'VERIFIED')
       $errors .= $paypal->getL('socketmethod').$result;
   fclose($fp);
}
else
   $errors = $paypal->getL('connect').$paypal->getL('nomethod');

Link to comment
Share on other sites

多谢Moderator,我现在很不理解paypal 的payment机制,paypal里有两个参数地址,一个验证地址(notify_url),一个是返回地址(return),我不明白验证是在前还是在后,要是在前的话,还没支付就知道支付结果??要是在后,那这个验证地址和返回地址是不是重了,一次只能有一个返回地址吧???

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...