接入指引
<h3><strong>1. 开发规范 接入准备</strong></h3>
<ul>
<li>接入前准备进件资料进行入网</li>
<li>获取支付参数,包括inst_no(机构号)、key(机构秘钥)、mch_no(平台商户号)</li>
</ul>
<h3><strong>2. 开发规范</strong></h3>
<p><strong>报文规范</strong>
请求方式:POST
请求头信息:Content-Type → application/json;charset=utf-8
编码格式:UTF-8</p>
<h3><strong>3.约束说明</strong></h3>
<table>
<thead>
<tr>
<th>符号</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>M</td>
<td>必须填写的字段</td>
</tr>
<tr>
<td>C</td>
<td>某条件成立时必须填写的字段</td>
</tr>
<tr>
<td>O</td>
<td>自选填写的字段</td>
</tr>
</tbody>
</table>
<p><strong>签名规则</strong></p>
<p>第一步 获得请求的参数,待签名的JSON参数,参数值为空字符串参与,参数值为null不参与</p>
<pre><code>{
&quot;inst_no&quot;: &quot;900024&quot;,
&quot;mch_no&quot;: &quot;851811130002&quot;,
&quot;pay_type&quot;: &quot;400&quot;,
&quot;pay_trace_no&quot;: &quot;18588dbd1c6e4572b915a2b33fcdc62e&quot;,
&quot;pay_time&quot;: &quot;20190101125959&quot;,
&quot;auth_code&quot;: &quot;134573607383541818&quot;,
&quot;total_amount&quot;: 1
}</code></pre>
<p>第二步 拼接参数,将JSON参数名首字母,按ASCII码顺序拼接,首字母相同则比较第二位,以此类推,生成字符串A</p>
<pre><code>String A = &quot;auth_code=134573607383541818&amp;inst_no=900024&amp;mch_no=851811130002&amp;pay_time=20190101125959&amp;pay_trace_no=18588dbd1c6e4572b915a2b33fcdc62e&amp;pay_type=400&amp;total_amount=1&quot;;</code></pre>
<p>第三步 拼接密钥,在字符串尾部拼接机构密钥,生成字符串B</p>
<pre><code>String B = A + &quot;&amp;key=8a9bd64e6585c6d8016585c6c8980002&quot;;</code></pre>
<p>第四步 生成签名,对字符串B进行md5算法加密,获得的32位小写字符串即为签名结果字符串</p>
<p>String sign = md5(B);</p>
<p>第五步 获得最后的请求参数,在请求参数中加入签名参数sign即可</p>
<pre><code>{
&quot;inst_no&quot;: &quot;900024&quot;,
&quot;mch_no&quot;: &quot;851811130002&quot;,
&quot;pay_type&quot;: &quot;400&quot;,
&quot;pay_trace_no&quot;: &quot;18588dbd1c6e4572b915a2b33fcdc62e&quot;,
&quot;pay_time&quot;: &quot;20190101125959&quot;,
&quot;auth_code&quot;: &quot;134573607383541818&quot;,
&quot;total_amount&quot;: 1,
&quot;sign&quot;:&quot;841387ec9bd3ea78a580bd4629cab010&quot;
}</code></pre>
<p><code>备注</code>
文档中的接口,未特殊说明的,均在请求参数附加一个名为sign的参数;
对于平台回调通知这类服务端发起的请求进行验签,先取出sign参数,剩下的参数按上述规则生成签名,最后与之前取出的sign参数进行比对。</p>