• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP整合PayPal支付_php技巧

php 搞代码 4年前 (2022-01-26) 31次浏览 已收录 0个评论

简单整理一下PHP项目整合PayPal支付功能。

一、表单的构建:


二、IPN验证部分

paypal_url);      // generate the post string from the _POST vars aswell as load the      // _POST vars into an arry so we can play with them from the calling      // script.      $post_str = '';      foreach ($_POST as $field=>$value) {        $this->ipn_data["$field"] = $value;        $post_str .= $field.'<div>本文来*源gaodai^.ma#com搞#代!码网</div><pre>搞gaodaima代码

=’.urlencode(stripslashes($value)).’&’;      }      $post_str.=”cmd=_notify-validate”; // append ipn command      // open the connection to paypal      $fp = fsockopen($url_par[host],”80″,$errnum,$errstr,30);      if(!$fp) {        // could not open the connection.        return false;      } else {        // Post the data back to paypal        fputs($fp, “POST “.$url_par[path].” HTTP/1.1\r\n”);        fputs($fp, “Host: “.$url_par[host].”\r\n”);        fputs($fp, “Content-type: application/x-www-form-urlencoded\r\n”);        fputs($fp, “Content-length: “.strlen($post_str).”\r\n”);        fputs($fp, “Connection: close\r\n\r\n”);        fputs($fp, $post_str . “\r\n\r\n”);        // loop through the response from the server and append to variable        while(!feof($fp)) {          $this->validate_ipn_response .= fgets($fp, 1024);        }        fclose($fp); // close connection     }    if (eregi(“VERIFIED”,$this->validate_ipn_response)) {      return true;    } else {      return false;    }  }}?>

以上所述就是本文的全部内容了,希望大家能够喜欢。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP整合PayPal支付_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址