首頁  >  文章  >  後端開發  >  易寶網上支付平台的PHP介面代碼

易寶網上支付平台的PHP介面代碼

WBOY
WBOY原創
2016-08-08 09:23:201599瀏覽

本程式碼參考自韓順平149講影片後5講,需要學習的朋友可以參考本程式碼

這是測試圖片:

以下是程式碼部分:

<span> 1</span> <?<span>php
</span><span> 2</span><span> 3</span><span> 4</span><span>function</span> HmacMd5(<span>$data</span>, <span>$key</span><span>)
</span><span> 5</span><span>{
</span><span> 6</span><span> 7</span><span>//</span><span>需要配置环境支撑iconv,否则中文参数不能正常处理</span><span> 8</span><span>$key</span> = <span>iconv</span>("GB2312", "UTF-8", <span>$key</span><span>);
</span><span> 9</span><span>$data</span> = <span>iconv</span>("GB2312", "UTF-8", <span>$data</span><span>);
</span><span>10</span><span>$b</span> = 64<span>;
</span><span>11</span><span>if</span> (<span>strlen</span>(<span>$key</span>) > <span>$b</span><span>) {
</span><span>12</span><span>$key</span> = <span>pack</span>("H*", <span>md5</span>(<span>$key</span><span>));
</span><span>13</span><span>    }
</span><span>14</span><span>$key</span> = <span>str_pad</span>(<span>$key</span>, <span>$b</span>, <span>chr</span>(0x00<span>));
</span><span>15</span><span>$ipad</span> = <span>str_pad</span>('', <span>$b</span>, <span>chr</span>(0x36<span>));
</span><span>16</span><span>$opad</span> = <span>str_pad</span>('', <span>$b</span>, <span>chr</span>(0x5c<span>));
</span><span>17</span><span>$k_ipad</span> = <span>$key</span> ^ <span>$ipad</span><span>;
</span><span>18</span><span>$k_opad</span> = <span>$key</span> ^ <span>$opad</span><span>;
</span><span>19</span><span>return</span><span>md5</span>(<span>$k_opad</span> . <span>pack</span>("H*", <span>md5</span>(<span>$k_ipad</span> . <span>$data</span><span>)));
</span><span>20</span><span>}
</span><span>21</span><span>//</span><span>我们把易宝支付要求怎样生成一个签名串
</span><span>22</span><span>    //把各个请求参数凭借作为$data传入: $key 就是易宝给商家分配的密钥</span><span>23</span><span>24</span> ?>
pay.php

<span> 1</span> <html>
<span> 2</span> <head>
<span> 3</span> <meta http-equiv="content-type" c />
<span> 4</span> </head>
<span> 5</span> <form action="payConfirm.php" method="post">
<span> 6</span> <table>
<span> 7</span>     <tr>
<span> 8</span>         <td colspan="4">
<span> 9</span>         订单号:<input type="text" name="p2_Order" /> 
<span>10</span>         支付金额:<input type="text" name="p3_Amt" />
<span>11</span>         </td>
<span>12</span>     </tr>
<span>13</span>     <tr>
<span>14</span>     <td colspan="4">请选择支付银行</td>
<span>15</span>     </tr>
<span>16</span>     <tr>
<span>17</span>     <td><input type="radio" name="pd_FrpId" value="CMBCHINA-NET-B2C" />招商银行</td>
<span>18</span>     <td><input type="radio" name="pd_FrpId" value="ICBC-NET-B2C" />工商银行</td>
<span>19</span>     <td><input type="radio" name="pd_FrpId" value="ABC-NET-B2C" />农业银行</td>
<span>20</span>     <td><input type="radio" name="pd_FrpId" value="CCB-NET-B2C" />建设银行</td>
<span>21</span>     </tr>
<span>22</span>     <tr>
<span>23</span>     <td colspan="4"><input type="submit" value="确认支付" /></td>
<span>24</span>     </tr>
<span>25</span> </table>
<span>26</span> </form>
<span>27</span> </html>
以上就介紹了易寶網上支付平台的PHP介面代碼,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn