Home > Backend Development > PHP Tutorial > 支付宝支付开发的防垂钓的时代已经到来

支付宝支付开发的防垂钓的时代已经到来

WBOY
Release: 2016-06-13 12:27:56
Original
1432 people have browsed it

支付宝支付开发的防钓鱼的时代已经到来

跳转到支付页面后,支付宝的收银台提示:

支付存在钓鱼风险

错误吗:AE130001040

找到了相应页面:https://cshall.alipay.com/enterprise/help_detail.htm?help_id=474059

在发起支付页面跳转的地方,增加参数“anti_phishing_key”,赋值为

<code class="sourceCode php"><span class="st">&#39;anti_phishing_key&#39;</span> => <span class="fu">urlencode</span><span class="ot">(</span><span class="kw">$this</span>->query_timestamp<span class="ot">()),</span></code>
Copy after login

<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">&#39;UTF-8&#39;</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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template