支付宝支付开发的防钓鱼的时代已经到来
跳转到支付页面后,支付宝的收银台提示:
支付存在钓鱼风险
错误吗:AE130001040
找到了相应页面:https://cshall.alipay.com/enterprise/help_detail.htm?help_id=474059
在发起支付页面跳转的地方,增加参数“anti_phishing_key”,赋值为
<code class="sourceCode php"><span class="st">'anti_phishing_key'</span> => <span class="fu">urlencode</span><span class="ot">(</span><span class="kw">$this</span>->query_timestamp<span class="ot">()),</span></code>
<code class="sourceCode php"><span class="co">/**</span><span class="co"> * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数</span><span class="co"> * 注意:该功能PHP5环境及以上支持,因此必须服务器、本地电脑中装有支持DOMDocument、SSL的PHP配置环境。建议本地调试时使用PHP开发软件</span><span class="co"> * return 时间戳字符串</span><span class="co"> */</span> <span class="kw">private</span> <span class="kw">function</span> query_timestamp<span class="ot">(</span><span class="kw">$partner</span><span class="ot">)</span> { <span class="kw">$url</span> = <span class="kw">$this</span>->gateway_new . <span class="st">"service=query_timestamp&partner="</span> . <span class="fu">trim</span><span class="ot">(</span><span class="fu">strtolower</span><span class="ot">(</span><span class="kw">$partner</span><span class="ot">)</span> . <span class="st">"&_input_charset="</span> . <span class="fu">trim</span><span class="ot">(</span><span class="fu">strtolower</span><span class="ot">(</span><span class="st">'UTF-8'</span><span class="ot">));</span> <span class="kw">$encrypt_key</span> = <span class="st">""</span><span class="ot">;</span> <span class="kw">$doc</span> = <span class="kw">new</span> <span class="kw">DOMDocument</span><span class="ot">();</span> <span class="kw">$doc</span>->load<span class="ot">(</span><span class="kw">$url</span><span class="ot">);</span> <span class="kw">$itemEncrypt_key</span> = <span class="kw">$doc</span>->getElementsByTagName<span class="ot">(</span><span class="st">"encrypt_key"</span><span class="ot">);</span> <span class="kw">$encrypt_key</span> = <span class="kw">$itemEncrypt_key</span>->item<span class="ot">(</span><span class="dv">0</span><span class="ot">)</span>->nodeValue<span class="ot">;</span> <span class="kw">return</span> <span class="kw">$encrypt_key</span><span class="ot">;</span> }</code>